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.

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:

POST /transactions/sign:
{
   "type": 3,
   "version": 2,
   "name": "Test Asset 1",
   "quantity": 100000000000,
   "description": "Some description",
   "sender": "3FSCKyfFo3566zwiJjSFLBwKvd826KXUaqR",
   "decimals": 8,
   "reissuable": true,
   "password": "1234",
   "fee": 100000000
}

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

Example response with transaction 3:

POST /transactions/sign:
{
    "type": 3,
    "id": "DnK5Xfi2wXUJx9BjK9X6ZpFdTLdq2GtWH9pWrcxcmrhB",
    "sender": "3N65yEf31ojBZUvpu4LCo7n8D73juFtheUJ",
    "senderPublicKey": "C1ADP1tNGuSLTiQrfNRPhgXx59nCrwrZFRV4AHpfKBpZ",
    "fee": 100000000,
    "timestamp": 1549378509516,
    "proofs": [ "NqZGcbcQ82FZrPh6aCEjuo9nNnkPTvyhrNq329YWydaYcZTywXUwDxFAknTMEGuFrEndCjXBtrueLWaqbJhpeiG" ],
    "version": 2,
    "assetId": "DnK5Xfi2wXUJx9BjK9X6ZpFdTLdq2GtWH9pWrcxcmrhB",
    "name": "Test Asset 1",
    "quantity": 10000,
    "reissuable": true,
    "decimals": 8,
    "description": "Some description",
    "chainId": 84,
    "script": "base64:AQa3b8tH",
    "height": 60719
}

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.

In addition to separate methods for signing and sending 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.

Example request and response of the method with transaction 112:

POST ​/transactions​/signAndBroadcast:

Query:

{
"sender": "3NkZd8Xd4KsuPiNVsuphRNCZE3SqJycqv8d",
"policyName": "Policy for sponsored v1",
"password":"sfgKYBFCF@#$fsdf()*%",
"recipients": [
  "3NkZd8Xd4KsuPiNVsuphRNCZE3SqJycqv8d",
  "3NotQaBygbSvYZW4ftJ2ZwLXex4rTHY1Qzn",
  "3Nm84ERiJqKfuqSYxzMAhaJXdj2ugA7Ve7T",
  "3NtNJV44wyxRXv2jyW3yXLxjJxvY1vR88TF",
  "3NxAooHUoLsAQvxBSqjE91WK3LwWGjiiCxx"
],
"fee": 100000000,
"description": "Privacy for sponsored",
"owners": [
  "3NkZd8Xd4KsuPiNVsuphRNCZE3SqJycqv8d",
  "3NotQaBygbSvYZW4ftJ2ZwLXex4rTHY1Qzn",
  "3Nm84ERiJqKfuqSYxzMAhaJXdj2ugA7Ve7T"
],
"type": 112
}

Response:

{
  "senderPublicKey": "3X6Qb6p96dY4drVt3x4XyHKCRvree4QDqNZyDWHzjJ79",
  "policyName": "Policy for sponsored v1",
  "fee": 100000000,
  "description": "Privacy for sponsored",
  "owners": [
    "3NkZd8Xd4KsuPiNVsuphRNCZE3SqJycqv8d",
    "3NotQaBygbSvYZW4ftJ2ZwLXex4rTHY1Qzn",
    "3Nm84ERiJqKfuqSYxzMAhaJXdj2ugA7Ve7T"
  ],
  "type": 112,
  "version": 2,
  "sender": "3NkZd8Xd4KsuPiNVsuphRNCZE3SqJycqv8d",
  "feeAssetId": "G16FvJk9vabwxjQswh9CQAhbZzn3QrwqWjwnZB3qNVox",
  "proofs": [
     "3vDVjp6UJeN9ahtNcQWt5WDVqC9KqdEsrr9HTToHfoXFd1HtVwnUPPtJKM8tAsCtby81XYQReLj33hLEZ8qbGA3V"
  ],
  "recipients": [
    "3NkZd8Xd4KsuPiNVsuphRNCZE3SqJycqv8d",
    "3NotQaBygbSvYZW4ftJ2ZwLXex4rTHY1Qzn",
    "3Nm84ERiJqKfuqSYxzMAhaJXdj2ugA7Ve7T",
    "3NtNJV44wyxRXv2jyW3yXLxjJxvY1vR88TF",
    "3NxAooHUoLsAQvxBSqjE91WK3LwWGjiiCxx"
  ],
  "id": "EyymzQcM2LrsgGDFFxeGn8DhahJbFYmorcBrEh8phv5S",
  "timestamp": 1585307711344
}

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/info/{id}:
{
  "type": 4,
  "id": "52GG9U2e6foYRKp5vAzsTQ86aDAABfRJ7synz7ohBp19",
  "sender": "3NBVqYXrapgJP9atQccdBPAgJPwHDKkh6A8",
  "senderPublicKey": "CRxqEuxhdZBEHX42MU4FfyJxuHmbDBTaHMhM3Uki7pLw",
  "recipient": "3NBVqYXrapgJP9atQccdBPAgJPwHDKkh6A8",
  "assetId": "E9yZC4cVhCDfbjFJCc9CqkAtkoFy5KaCe64iaxHM2adG",
  "amount": 100000,
  "fee": 100000,
  "timestamp": 1549365736923,
  "attachment": "string",
  "signature": "GknccUA79dBcwWgKjqB7vYHcnsj7caYETfncJhRkkaetbQon7DxbpMmvK9LYqUkirJp17geBJCRTNkHEoAjtsUm",
  "height": 7782
}

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/address/{address}/limit/{limit}:
[
[
  {
    "type": 2,
    "id": "4XE4M9eSoVWVdHwDYXqZsXhEc4q8PH9mDMUBegCSBBVHJyP2Yb1ZoGi59c1Qzq2TowLmymLNkFQjWp95CdddnyBW",
    "fee": 100000,
    "timestamp": 1549365736923,
    "signature": "4XE4M9eSoVWVdHwDYXqZsXhEc4q8PH9mDMUBegCSBBVHJyP2Yb1ZoGi59c1Qzq2TowLmymLNkFQjWp95CdddnyBW",
    "sender": "3NBVqYXrapgJP9atQccdBPAgJPwHDKkh6A8",
    "senderPublicKey": "CRxqEuxhdZBEHX42MU4FfyJxuHmbDBTaHMhM3Uki7pLw",
    "recipient": "3N9iRMou3pgmyPbFZn5QZQvBTQBkL2fR6R1",
    "amount": 1000000000
  }
]
]

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:
[
  {
    "type": 4,
    "id": "52GG9U2e6foYRKp5vAzsTQ86aDAABfRJ7synz7ohBp19",
    "sender": "3NBVqYXrapgJP9atQccdBPAgJPwHDKkh6A8",
    "senderPublicKey": "CRxqEuxhdZBEHX42MU4FfyJxuHmbDBTaHMhM3Uki7pLw",
    "recipient": "3NBVqYXrapgJP9atQccdBPAgJPwHDKkh6A8",
    "assetId": "E9yZC4cVhCDfbjFJCc9CqkAtkoFy5KaCe64iaxHM2adG",
    "amount": 100000,
    "fee": 100000,
    "timestamp": 1549365736923,
    "attachment": "string",
    "signature": "GknccUA79dBcwWgKjqB7vYHcnsj7caYETfncJhRkkaetbQon7DxbpMmvK9LYqUkirJp17geBJCRTNkHEoAjtsUm"
  }
]

GET /transactions/unconfirmed/size

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

Response example:

GET /unconfirmed/info/{id}:
{
  "size": 4
}

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:

GET /unconfirmed/info/{id}:
{
  "type": 4,
  "id": "52GG9U2e6foYRKp5vAzsTQ86aDAABfRJ7synz7ohBp19",
  "sender": "3NBVqYXrapgJP9atQccdBPAgJPwHDKkh6A8",
  "senderPublicKey": "CRxqEuxhdZBEHX42MU4FfyJxuHmbDBTaHMhM3Uki7pLw",
  "recipient": "3NBVqYXrapgJP9atQccdBPAgJPwHDKkh6A8",
  "assetId": "E9yZC4cVhCDfbjFJCc9CqkAtkoFy5KaCe64iaxHM2adG",
  "amount": 100000,
  "fee": 100000,
  "timestamp": 1549365736923,
  "attachment": "string",
  "signature": "GknccUA79dBcwWgKjqB7vYHcnsj7caYETfncJhRkkaetbQon7DxbpMmvK9LYqUkirJp17geBJCRTNkHEoAjtsUm",
  "height": 7782
}

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:

GET /unconfirmed/info/{id}:
{
  "feeAssetId": null,
  "feeAmount": 10000
}
See also