Installation and usage of the platform

REST API: transactions

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

Methods of the transactions group are provided to work with transactions.

Signing and sending transactions

The node REST API uses a JSON representation of a transaction to send requests.

The basic principles of work with transactions are given in the Transactions of the blockchain platform. A description of the fields for each transaction is given in the Description of transactions section.

POST /transactions/sign

The POST /transactions/sign method is used to sign transactions. This method signs the transaction with the sender’s private key stored in the keystore of the node. To sign requests with the key from the keystore of the node, be sure to specify the key pair password in the password field.

Important

The /transactions​/sign method is not available when PKI is used, that is, when the node configuration file parameter node.crypto.pki.mode is set to ON. The method can be used in PKI test mode (node.crypto.pki.mode = TEST) or with PKI disabled (node.crypto.pki.mode = OFF).

Example signature request transaction 3:

The POST /transactions/sign method in the response returns the fields needed to publish the transaction.

Example response with transaction 3:

POST /transactions/broadcast

The POST /transactions/broadcast method is designed to broadcast a transaction. The response fields of the sign method are input to this method. A transaction can also be sent to the blockchain using other tools given in the article Transactions of the blockchain platform.

When a new user, who is not the node owner, makes his first transaction, he must fill in the certificates query field with his certificate chain. In other cases, the certificates field is not required.

Note

The certificates field in the RegisterNode transaction broadcast request is mandatory when using PKI in operating or test mode (i.e. when the node configuration file parameter node.crypto.pki.mode is set to ON or TEST. In this case, the certificates field must contain a certificate chain that matches the public key in the target transaction field.

An example of a POST /transactions/broadcast method request

If the transaction is published successfully, the method returns a json with the transaction and the 200OK message.

POST /transactions/signAndBroadcast

In addition to the separate methods for signing and broadcasting transactions, there is a combined method: POST /transactions/signAndBroadcast. This method signs and sends the transaction to the blockchain without intermediate transfer of information between the methods.

Important

The /transactions​/signAndBroadcast method is not available when PKI is used, that is, when the node configuration file parameter node.crypto.pki.mode is set to ON. The method can be used in PKI test mode (node.crypto.pki.mode = TEST) or with PKI disabled (node.crypto.pki.mode = OFF).

When a new user, who is not the node owner, makes his first transaction, he must fill in the certificates query field with his certificate chain. In other cases, the certificates field is not required.

Note

The certificates field in the RegisterNode transaction broadcast request is mandatory when using PKI test mode (i.e. when the node configuration file parameter node.crypto.pki.mode is set to TEST. In this case, the certificates field must contain a certificate chain that matches the public key in the target transaction field.

Example request and response of the method with transaction 112:

Information about transactions

The transactions group also includes the following methods of obtaining information about transactions in the blockchain:

GET /transactions/info/{id}

Obtaining information about a transaction by its {id} identifier. The transaction identifier is specified in the POST /transactions/sign or POST /transactions/signAndBroadcast methods response.

The method returns transaction data similar to the POST /transactions/broadcast and POST /transactions/signAndBroadcast methods responses.

Response example:

GET /transactions/address/{address}/limit/{limit}

The method returns the data of the last {limit} transactions of the address {address}.

For each transaction, data similar to the POST /transactions/broadcast and POST /transactions/signAndBroadcast methods responses are returned.

Response example with one transaction:

GET /transactions/unconfirmed

The method returns the data of all transactions from the UTX pool of the node.

For each transaction, data similar to the POST /transactions/broadcast and POST /transactions/signAndBroadcast methods responses are returned.

Response example with one transaction:

GET /transactions/unconfirmed/size

The method returns the number of transactions in the UTX pool as a number.

Response example:

GET /unconfirmed/info/{id}

The method returns the data of the transaction that is in the UTX pool by its {id}.

The method response contains transaction data similar to the POST /transactions/broadcast and POST /transactions/signAndBroadcast methods’ responses.

Response example:

POST /transactions/calculateFee

The method returns the amount of commission for the sent transaction.

The request specifies parameters similar to POST /transactions/broadcast request. The method’s response returns the identifier of the asset where the commission is charged (null for WAVES).

Response example: