Installation and usage of the platform
REST API: transactions¶
Methods of the transactions
group are provided to work with transactions:
Signing and sending transactions:
Retrieving information about 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.
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.
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.
Note
You can also use the Broadcast and BroadcastWithCerts gRPC methods to send transactions to the blockchain.
POST /transactions/signAndBroadcast¶
In addition to the separate methods for signing and broadcasting transactions (POST /transactions/sign and POST /transactions/broadcast), there is a combined POST /transactions/signAndBroadcast method.
This method signs the transaction with the sender`s private key and sends the transaction to the blockchain without intermediate information transfer between the methods.
In the request, the signAndBroadcast
method accepts the JSON of the transaction to be signed. JSON representations of transactions are given in the Description of transactions section. In the response, the method returns the 200
code if the transaction was successfully signed and sent, or an error code.
Method request example with the 103 CreateContract transaction:
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 the transactions in 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, that is, the number of transactions that have been sent to the network but have not yet been validated and mined.
Response example:
Note
Use the UtxInfo gRPC method to retrieve the UTX pool size in bytes and kilobytes.
GET /transactions/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: