Installation and usage of the platform

REST API: information about smart contracts

https://img.shields.io/badge/auth-required-orange.svg

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 - version of the smart contract;

  • active - status of the smart contract 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 executed transaction 103 to create a smart contract 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 - an address of transaction sender;

  • senderPublicKey – a public key of transaction sender;

  • txId - transaction identifier;

  • status - transaction status: successfully hit the block, confirmed, rejected;

  • code - error code (if any);

  • message - message about the status of the transaction;

  • 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:

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 - a 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 for a regular expression for sorting of keys.

Response example:

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: