REST API methods available to smart contracts¶
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.
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:
A Docker contract developer assigns an
API_TOKENvalue to the header of the
X-Contract-Api-Tokenrequest. Node writes to the
API_TOKENvariable 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.