API methods available to smart contract

Docker container-based smart contracts can use node REST API. Smart contract developers can use limited list of REST API methods. This list is represented below, these methods are available directly from the container.

Addresses methods

Crypto methods

Privacy methods

Transactions methods

Contracts methods

A smart contract can use Contracts methods implementing the separated /internal/contracts/ route, which is totally identical to the regular Contracts methods.

PKI methods

Docker contract authorization

A smart contract requires an authorization to use the node REST API. There are following steps for the correct REST API methods usage by the smart contract:

  1. The following variables should be defined in the Docker contract environment:

  • NODE_API - an URL address to the node REST API.

  • API_TOKEN - an authorization token of the Docker contract.

  • COMMAND - commands for the Docker contract creation and call.

  • TX - a transaction which is required to the Docker contract for work (103 - 107 codes).

  1. The Docker contract developer assigns the value of the variable API_TOKEN to the request header X-Contract-Api-Token. The node specifies JWT authorization token into the variable API_TOKEN for the contract creation and execution.

  2. The contract code should pass the received token in the request header (X-Contract-Api-Token) each time the node API is accessed.