REST API methods available to smart contracts¶
Important
REST API methods for Docker smart contracts are are being phased out.
Docker container-based smart contracts can use the node REST API. For a general tutorial on how to create smart contracts using the REST API, see the article Docker smart contracts with the use of the node REST API.
Not all REST API methods are available to Docker smart contract developers. Below is a list of REST API node methods that a smart contract can use directly from the Docker container.
‘Addresses’ methods
‘Crypto’ methods
‘Privacy’ methods
‘Transactions’ methods
‘Contracts’ methods
In order to enhance performance, a smart contract can use the Contracts methods via a dedicated /internal/contracts/
route, that are fully identical to the plain Contracts methods.
PKI methods
Authorization of a Docker smart contract¶
In order to work with the node REST API, a smart contract requires authorization. To ensure a correct interaction of a Docker contract with the API methods, following actions should be performed:
Define following variables as environment variables of a Docker contract:
NODE_API
- URL to the node REST API.
API_TOKEN
- Docker contract authorization token.
COMMAND
- commands for creation and call of a Docker contract.
TX
- transaction required by a Docker contract for work (codes 103 - 107).
A Docker contract developer assigns an
API_TOKEN
value to the header of theX-Contract-Api-Token
request. Node writes to theAPI_TOKEN
variable a JWT authorization token during creation and execution of a contract.A contract code should transfer a received token in the header of the (
X-Contract-Api-Token
) request in every access to the node API.