Installation and usage of the platform

REST API: hash calculation, working with scripts and sending auxiliary queries

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

For hashing, scripting and sending auxiliary requests to the node, there is a group of utils methods:

Hashing: utils/hash

POST /utils/hash/fast

The method returns the hash sum of the string passed in the query.

The incoming string is converted to UTF-8 bytes and the hash is calculated from these bytes. The Blake2b256 algorithm is used for Waves cryptography. The result is converted to Base58 format.

Response example:

POST /utils/hash/fast:
{
  "message": "ridethewaves!",
  "hash": "DJ35ymschUFDmqCnDJewjcnVExVkWgX7mJDXhFy9X8oQ"
}

POST /utils/hash/secure

The method returns the double hash sum of the string passed in the query. Blake2b256 algorithm is applied in WAVES cryptography (the node.crypto.type parameter is assigned the WAVES value in the node configuration file).

Response example:

POST /utils/hash/secure:
{
  "message": "ridethewaves!",
  "hash": "H6nsiifwYKYEx6YzYD7woP1XCn72RVvx6tC1zjjLXqsu"
}

Working with scripts: utils/script

This group of methods is designed to convert script code into base64 format and decode them. Scripts are bound to accounts using the 13 transactions (binding a script to an address) and 15 (binding a script to an asset for an address).

POST /utils/script/compile

The method converts the script code to base64 format.

Query example:

POST /utils/script/compile:
let x = 1
(x + 1) == 2

Parameters returned in the method response:

  • script - script body in base64 format;

  • complexity - a number from 1 to 100 representing the amount of computing resources required to execute the script;

  • extraFee - fee for outgoing transactions set by the script.

Response example:

POST /utils/script/compile:
{
  "script": "3rbFDtbPwAvSp2vBvqGfGR9nRS1nBVnfuSCN3HxSZ7fVRpt3tuFG5JSmyTmvHPxYf34SocMRkRKFgzTtXXnnv7upRHXJzZrLSQo8tUW6yMtEiZ",
  "complexity": 11,
  "extraFee": 10001
}

POST /utils/script/estimate

The method is designed to decode and evaluate the complexity of a script passed in a request in base64 format.

Parameters returned in the method response:

  • script - script body in base64 format;

  • scriptText - the source code of the script;

  • complexity - a number from 1 to 100 representing the amount of computing resources required to execute the script;

  • extraFee - fee for outgoing transactions set by the script.

Response example:

POST /utils/script/compile:
{
  "script": "3rbFDtbPwAvSp2vBvqGfGR9nRS1nBVnfuSCN3HxSZ7fVRpt3tuFG5JSmyTmvHPxYf34SocMRkRKFgzTtXXnnv7upRHXJzZrLSQo8tUW6yMtEiZ",
  "scriptText": "FUNCTION_CALL(FunctionHeader(==,List(LONG, LONG)),List(CONST_LONG(1), CONST_LONG(2)),BOOLEAN)",
  "complexity": 11,
  "extraFee": 10001
}

Auxiliary queries

GET /utils/time

The method returns the current node time in two formats:

  • system - system time of the node PC;

  • ntp - network time.

Response example:

POST /utils/script/compile:
{
   "system": 1544715343390,
   "NTP": 1544715343390
}

POST /utils/reload-wallet

The method reloads a node’s keystore. It applies if a new key pair was added to the keystore without restarting the node.

Response example:

POST /utils/reload-wallet:
{
   "message": "Wallet reloaded successfully"
}
See also