Installation and usage of the platform
REST API: information about smart contracts¶
A set of methods from the contracts
group is provided to obtain information about smart contracts loaded on the network.
GET /contracts¶
The method returns information on all smart contracts uploaded to the network. For each smart contract, the following parameters are returned in the response:
contract_id
– smart contract identifier;image
– name of the Docker image of the smart contract, or its absolute path in the repository;imageHash
– hash sum of the smart contract;version
– smart contract version;active
– smart contract status at the time of sending the query:true
– running;false
– not running.
Response example for one smart contract:
POST /contracts¶
The method returns a set of “key:value” fields written to the stack of one or more smart contracts. The IDs of the requested smart contracts are specified in the contracts
field of the request.
Response example for one smart contract:
GET /contracts/status/{id}¶
The method returns the status of executable 103. CreateContract transaction or another contract call transaction (Call, Update) by transaction identifier {id}
. However, if the node is restarted after sending the transaction to the blockchain, the method will not return the correct status of that transaction.
Parameters returned in the method response:
sender
– transaction sender address;senderPublicKey
– the public key of the transaction sender;txId
– transaction identifier;status
– transaction status: successfully hit the block, confirmed, rejected;0
– successfully executed (SUCCESS);1
– business error, the contract is not executed, the call is rejected (ERROR);2
– system error during the execution of the smart contract (FAILURE).
code
– error code (if any);message
– transaction status message; contains additional information about the status specified in thestatus
field, for example,"message": "Smart contract transaction successfully mined";
timestamp
– the Unix Timestamp (in milliseconds);signature
– transaction signature.
Response example:
GET /contracts/{contractId}¶
The method returns the result of smart contract execution by its {contractId}
identifier.
Response example:
The GET /contracts/{contractId} and POST /contracts/{contractId} methods return the same response.
POST /contracts/{contractId}¶
The method returns key values from the {contractId}
smart contract state. The query specifies the following data:
contract_id
– smart contract identifier;limit
– the limit of number of data blocks to be obtained;offset
– number of data blocks to be missed in the method response;matches
– an optional parameter to compose a regular expression that filters the keys.
Response example:
The POST /contracts/{contractId} and GET /contracts/{contractId} methods return the same response.
GET /contracts/executed-tx-for/{id}¶
The method returns the result of smart contract execution by identifier of a transaction 105.
The method’s response returns transaction data 105, as well as the results of the execution in the results
field.
Response example if a smart contract has not been executed:
GET /contracts/{contractId}/{key}¶
Returns the {key} value of the executed smart contract by its identifier.
Response example: