Skip to content
Victor Zhang edited this page Apr 18, 2019 · 4 revisions

RPC interface list

Get current node information

curl --data '{"jsonrpc":"2.0", "id":1, "method":"getInfo", "params":[] }' http://127.0.0.1:6553

Example output from the command above:

{"last_mci":63136,"last_stable_mci":63136,"count_unhandled":0}

Which contains the following:

  • last_mci: The largest MCI (Main Chain Index) of the current node
  • last_stable_mci: The largest stable unit MCI of the current node
  • count_unhandled: Number of units to be processed by the current node

Query wallet address

curl --data '{"jsonrpc":"2.0", "id":1, "method":"getMyAddress", "params":[] }' http://127.0.0.1:6553

Query current balance

curl --data '{"jsonrpc":"2.0", "id":1, "method":"getBalance", "params":["4T7YVRUWMVAJIBSWCP35C7OGCX33SAYO"] }' http://127.0.0.1:6553

In the command above, params specifies the address to be queried. This command can only query the balance of a current Supernode address.

Note: The unit of the returned amounts are in Radians (RAD). 1 Ring (RNG) consists of 1,000,000 RADs.

Example output from the command above:

{"base":{"stable":27924300957,"pending":0}}

Which contains the following:

  • stable: The available balance (in RADs) in the current address
  • pending: Unconfirmed balance in current address

Creating a transaction

curl --data '{"jsonrpc":"2.0", "id":1, "method":"sendToAddress", "params":["BVVJ2K7ENPZZ3VYZFWQWK7ISPCATFIW3", 1000000] }' http://127.0.0.1:6553

Where params specifies the receiving address and the transfer amount in RADs.

Query transaction history

curl --data '{"jsonrpc":"2.0", "id":1, "method":"listTransactions", "params":[] }' http://127.0.0.1:6553

Returns historical transaction information related to the current node. Here is an example of some of the output:

[{"action":"sent","amount":17751564,"addressTo":"A3TEKUPJMRKNKJBO2NOKLGKONMFWLR7P","confirmations":1,"unit":"b18RhLdpfR6ZFDtmcnmP96Dbyjmw8zJeds9U1zdg4BA=","fee":0,"time":" 1554965692","level":72187,"mci":62847,"round_index":1503,"pow_type":3}]

Returns an array of all relevant transaction information, each of which includes:

  • action: Transaction type, including sent, received, moved, invalid, etc.
  • amount: Amount in RADs
  • addressTo: Recipient address
  • arrPayerAddresses: An array of payment addresses
  • confirmations: Transaction confirmation status (stable)
  • unit: Unit ID
  • fee: Transaction fee
  • level: Unit level
  • mci: Unit MCI (equivalent to blockheight)
  • round_index: Consensus round number (normal unit is empty)
  • pow_type: Unit type (normal unit is empty), (1.) mining unit, (2.) TrustME unit, (3.) Coinbase unit Example of passing parameters:
  1. Returns all relevant transaction information for a particular address:
curl --data '{"jsonrpc":"2.0", "id":1, "method":"listTransactions", "params":["JNA6YWLKFQG7PFF6F32KTXBUAHRAFSET"] }' http://127.0.0.1:6553
  1. Returns all relevant transaction information for the entire wallet:
curl --data '{"jsonrpc":"2.0", "id":1, "method":"listTransactions", "params":{} }' http://127.0.0.1:6553
  1. Returns any transactions occurring after the specified MCI:
curl --data '{"jsonrpc":"2.0", "id":1, "method":"listTransactions", "params":{ "since_mci":62800 } }' http://127.0.0.1:6553
  1. Gets the transaction information of a particular unit:
curl --data '{"jsonrpc":"2.0", "id":1, "method":"listTransactions", "params":{ "unit":"b18RhLdpfR6ZFDtmcnmP96Dbyjmw8zJeds9U1zdg4BA="} }' http://127.0. 0.1:6553

Checking address validity

curl --data '{"jsonrpc":"2.0", "id":1, "method":"checkAddress", "params":["BVVJ2K7ENPZZ3VYZFWQWK7ISPCATFIW3"] }' http://127.0.0.1:6553

Where params specifies the address to be queried.

Query the total number of units in the current node

curl --data '{"jsonrpc":"2.0", "id":1, "method":"getTotalNumOfUnits", "params":[] }' http://127.0.0.1:6553

Query unit details

curl --data '{"jsonrpc":"2.0", "id":1, "method":"getUnitInfo", "params":["b18RhLdpfR6ZFDtmcnmP96Dbyjmw8zJeds9U1zdg4BA="] }' http://127.0.0.1:6553

Where params specifies the unit to be queried.

Get current peer list

curl --data '{"jsonrpc":"2.0", "id":1, "method":"getPeerList", "params":[] }' http://127.0.0.1:6553

Example output from the command above:

{"incoming connections":"[\"58.132.177.157:3463\"]","outgoing connections":"[\"ws://119.28.23.97:9193\",\"ws://119.28.128.192 :9193\",\"ws://119.28.191.240:9193\",\"ws://119.28.14.51:9193\",\"ws://119.28.143.96:9193\",\"ws ://119.28.44.246:9193\"]"}

among them:

  • incoming connections: all nodes connected to this node
  • outgoing connections: all nodes to which this node is connected

Create a deposit contract

curl --data '{"jsonrpc":"2.0", "id":1, "method":"createMinerAddress", "params":[1000000] }' http://127.0.0.1:6553

Among them, 1000000 is the amount of the deposit contract in RADs, the value can not be 0, and can not be greater than the amount of funds held in the SuperNode address.

If the deposit contract is created successfully, it will return the following format:

{"jsonrpc":"2.0","result":"W3MMU32YURN6XISK5YADI4QQXKRH5INK","id":1}

Among the results, "W3MMU32YURN6XISK5YADI4QQXKRH5INK" is the deposit contract address of the current node.

Mining status query

curl --data '{"jsonrpc":"2.0", "id":1, "method":"miningStatus", "params":[] }' http://127.0.0.1:6553

Example output from the command above:

{\"pow_count\":591,\"coinbase\":15806504738,\"balance\":{\"base\":{\"stable\":15906207226,\"pending\":0,\"is_private \":null}},\"current_round\":780,\"max_mci\":39983}

Which contains the following:

  • pow_count: Number of successful mining operations
  • coinbase: The total amount of Coinbase that has been obtained, in RADs
  • current_round: Current consensus round
  • max_mci: Current stable height
  • difficulty: Current difficulty value
  • totalMine: Total mining volume
  • totalPublishCoin: Total circulation
  • depositRatio: current mortgage rate
  • inflationRatio: annualized inflation rate

Note: The current round and current stable height of the local ledger may be less than the actual value of the entire net.

Get the duration of a round

curl --data '{"jsonrpc":"2.0", "id":1, "method":"getDurationByRoundIndex", "params":[1530] }' http://127.0.0.1:6553

Where the parameter is the consensus round number

{"jsonrpc":"2.0","result":278,"id":1}

The number in the result is in seconds.

Other information

Quickly check network connections with log files

tail -f log.txt | grep connection

Example of execution results:

Mon Apr 08 2019 16:43:09 GMT+0800 (CST): 13 incoming connections,
12 outgoing connections,
0 outgoing connections being opened

Notes:

  • This article applies to the Explorer and SuperNodes. For security reasons, the SuperNode's RPC interface only allows local access
  • Please confirm that the SuperNode program is the latest version, no need to delete the local database   - How to update the SuperNode program?
  • By modifying the rpcInterface and rpcPort values inside of the conf.js file, you can adjust the access permissions of the RPC interface. By default, 127.0.0.1 access is allowed, and the default port is 6553

Clone this wiki locally