Show / Hide Table of Contents

NEO Namespace

The NEO Namespace contains an API provided by the NEO blockchain. Methods of the API allow querying the blockchain and manipulation of the persistent store.

New and Deprecated tags denote changes between version 1.6 and version 2.0.

Read-only API

Blockchain Query API:

APIDescription
Neo.Blockchain.GetHeightGet the current block height
Neo.Blockchain.GetHeaderFind block header by block height or block hash
Neo.Blockchain.GetBlockFind block by block Height or block Hash
Neo.Blockchain.GetTransactionFind transaction via transaction ID
Neo.Blockchain.GetAccountGet an account based on the scripthash of the contract
Neo.Blockchain.GetValidators New Get the public key of the consensus node
Neo.Blockchain.GetAssetGet asset based on asset ID
Neo.Blockchain.GetContract New Get contract content based on contract hash

Block class API:

APIDescription
Neo.Header.GetHashGet the hash of the block
Neo.Header.GetVersionGet Block version number
Neo.Header.GetPrevHashGet the hash of the previous block
Neo.Header.GetIndexGet the current block height
Neo.Header.GetMerkleRootGet the Merkle Tree root for all transactions in that block
Neo.Header.GetTimestampGet the timestamp of the block
Neo.Header.GetConsensusDataGet consensus data for this block (pseudo-random number generated by consensus node)
Neo.Header.GetNextConsensusGet the hash value for the next bookkeeper contract
Neo.Block.GetTransactionCountGet the number of transactions in the current block
Neo.Block.GetTransactionsGet all transactions in the current block
Neo.Block.GetTransactionGet the transaction specified in the current block

Transaction class API:

APIDescription
Neo.Transaction.GetHashGet Hash for the current transaction
Neo.Transaction.GetTypeGet the current transaction type
Neo.Enrollment.GetPublicKey Deprecated Replaced with Neo.Blockchain.GetValidators
Neo.Transaction.GetAttributesQuery all properties of the current transaction
Neo.Transaction.GetInputsQuery all transactions for current transactions
Neo.Transaction.GetOutputsQuery all transaction output for current transaction
Neo.Transaction.GetReferencesQuery the transaction output referenced by all inputs of the current transaction
Neo.Attribute.GetUsageGet purpose of transaction
Neo.Attribute.GetDataGet extra data outside of the purpose of transaction
Neo.Input.GetHashGet the hash of the referenced previous transaction
Neo.Input.GetIndexThe index of the input in the output list of the referenced previous transaction
Neo.Output.GetAssetIdGet Asset ID
Neo.Output.GetValueGet the transaction amount
Neo.Output.GetScriptHashGet Script Hash

Account class API:

APIDescription
Neo.Account.GetScriptHashGet the script hash of the contract account
Neo.Account.GetVotesGet information of the votes that this account has casted
Neo.Account.GetBalanceGet the balance of this asset in the account given the asset ID

Asset class API:

APIDescription
Neo.Asset.GetAssetIdGet ID of the asset
Neo.Asset.GetAssetTypeGet the category of the asset
Neo.Asset.GetAmountGet the total amount of the asset
Neo.Asset.GetAvailableGet the quantity of the asset that has been issued
Neo.Asset.GetPrecisionGet the number of divisions for this asset, the number of digits after the decimal point
Neo.Asset.GetOwnerGet the owner of the asset (public key)
Neo.Asset.GetAdminObtain the administrator (contract address) of the asset
Neo.Asset.GetIssuerObtain the issuer (contract address) of the asset

Contract class API:

APIDescription
Neo.Contract.GetScriptGet the scripthash of the contract

Storage class API:

APIDescription
Neo.Storage.GetContext New Get the current store context
Neo.Storage.GetReturns the value in the persistent store based off the key given

Runtime class API:

APIDescription
Neo.Runtime.CheckWitness New Verifies that the calling contract has verified the required script hashes of the transaction/block
Neo.Runtime.Notify New Notifies the client with a notification during smart contract execution
Neo.Runtime.Log New Notifies the client with a log message during smart contract execution

Note: The source code can be found under NEO in the SmartContract/StateReader.cs file.

Read/Write API

This type of API will modify the status of the smart contract

APIDescription
Neo.Account.SetVotesSet the voting information of this account
Neo.Validator.Register New Register as a bookkeeper
Neo.Asset.Create New Register a new asset
Neo.Asset.Renew New Renew an asset
Neo.Contract.Create New Publish a smart contract
Neo.Contract.Migrate New Migrate/Renew a smart contract
Neo.Contract.Destroy New Destroy a smart contract
Neo.Contract.GetStorageContext New Get the storage context of the contract
Neo.Storage.PutInserts a value into the persistent store based off the given key
Neo.Storage.DeleteDeletes a value from the persistent store based off the given key

The source code for the above API can be found under NEO in the SmartContract/StateMachine.cs file.