json-rpc NV <= 1.2.7

( node version <= v1.2.7 )

JSON is a lightweight data exchange format. It can represent numbers, strings, ordered value sequences and key-value pairs.

JSON-RPC is a stateless, lightweight Remote Procedure Call (RPC) protocol. It defines several data structures and the relevant rules to handle them. JSON-RPC is transmission-agnostic, because it can be used in situations like process, socket, HTTP, or different message transmission environments. It uses JSON(RFC 4627) as the data format.

Curl Examples Explained

The curl options below might return a response where the node complains about the content type, this is because the --data option sets the content type to application/x-www-form-urlencoded .

JSON-RPC Support

Type

Supported?

JSON-RPC 1.0

JSON-RPC 2.0

Batch Requests

HTTP

WS

JSON-RPC Port

Default port:

Client

Type

Address

Go

jsonrpc-2.0

Go

http

Go

websocket

JSON-RPC List

Currently, there are several RPCs with different namespaces:

  • seele:node data manipulation and procurement / acquisition

  • txpool:transaction pool management

  • download:RPC collection provided for internal inquiry of blockchain node synchronization state.

  • network:connection management

  • miner:miner manipulation

  • debug:node debugging

  • monitor:node monitor

JSON-RPC Contents

Command

Full

Light

public

private

Command

Full

Light

public

private

Command

Full

Light

public

private

Command

Full

Light

public

private

Command

Full

Light

public

private

Command

Full

Light

public

private

seele

RPC collection provided for public for blockchain node and transaction manipulation.

GetInfo

This method returns the node information.

Type

Template

RPC

{"jsonrpc":"2.0","method":"seele_getInfo","params":[],"id":2}

Parameters

none

Returns

  • Coinbase:string - node address

  • CurrentBlockHeight:uint64 - current block height

  • HeaderHash:string - block hash

  • MinerStatus:string - miner status

  • Shard:int - shard number

Example

  • Request

    curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"seele_getInfo","params":[],"id":1}' localhost:8037
  • Result

    {
      "jsonrpc": "2.0",
      "id": 1,
      "result": {
          "Coinbase": "0x4c10f2cd2159bb432094e3be7e17904c2b4aeb21",
          "CurrentBlockHeight": 1722,
          "HeaderHash": "0x000001fa4cb11751fea2d4f7f9356303d44d2a02f37c3e62e657ffe29e5cb5fe",
          "Shard": 1,
          "MinerStatus": "Running"
      }
    }

GetBalance

This method returns the account balance give the account address.

Type

Template

RPC

{"jsonrpc":"2.0","method":"seele_getBalance","params":[string,string ,uint64],"id":1}

Parameters

  • Account:string - account

  • hexHash:string - hex form of a block hash, set to "" for the latest balance

  • height :uint64 - height of a block, set to -1 for the latest balance

    Returns

  • Account:string - account

  • Balance:big.Int - account balance

Example

  • Request

    curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"seele_getBalance","params":["0x4c10f2cd2159bb432094e3be7e17904c2b4aeb21","",-1],"id":1}' localhost:8037
  • Result

    {
      "jsonrpc": "2.0",
      "id": 1,
      "result": {
          "Account": "0x4c10f2cd2159bb432094e3be7e17904c2b4aeb21",
          "Balance": 265499990000
      }
    }

AddTx

This method submits a transaction to the node.

Type

Template

RPC

{"jsonrpc":"2.0","method":"seele_addTx","params":[types.Transaction],"id":1}

Parameters

  • tx:types.Transaction - transaction struct (client command sign could be used to get transaction hash and signature)

    • Hash:string - transaction hash

    • Data:json - transaction data

      • From:string - transaction sender

      • To:string - transaction receiver

      • Amount:uint64 - amount value, unit is fan

      • Fee:uint64 - transaction fee

      • Payload:string - transaction payload

      • AccountNonce:uint64 - transaction nonce

    • Signature : crypto.Signature - transaction signature struct

      type Signature struct {
         Sig []byte // [R || S || V] format signature in 65 bytes.
      }

Returns

  • result:bool - transaction send result

Example

  • Request

    curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"seele_addTx","params":[{"Hash": "0x3393e5566cb905d714599f2f888ecc6d223b83403887460fa5b2771e89a0436e","Data": {"From": "0x3b691130ec4166bfc9ec7240217fc8d08903cf21","To":"0x2a87b6504cd00af95a83b9887112016a2a991cf1","Amount": 1,"AccountNonce":0,"Fee": 0,"GasPrice":10, "GasLimit":21000},"Signature":{"Sig":"fAvgVTXDyJZbfv07NYBK4aSolfY4ycBPQRwnQFpHRMc7ooOZw27U50o4TBoRelYX3QCRyvKpbxVlxhu7AnSB6QE="}}],"id":1}' localhost:8037
  • Result

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

GetAccountNonce

This method is used to obtain the account nonce.

Type

Template

RPC

{"jsonrpc":"2.0","method":"seele_getAccountNonce","params":[string,string ,uint64],"id":1}

Parameters

  • account:string - account

  • hexHash:string - hex form of a block hash, set to "" for the latest nonce

  • height :uint64 - height of a block, set to -1 for the latest nonce

    Returns

  • result:uint64 - account nonce

Example

  • Request

    curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"seele_getAccountNonce","params":["0x4c10f2cd2159bb432094e3be7e17904c2b4aeb21","",-1],"id":1}' localhost:8037
  • Result

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

GetBlockHeight

This method is used to obtain the height of the blockchain.

Type

Template

RPC

{"jsonrpc":"2.0","method":"seele_getBlockHeight","params":[string],"id":1}

Parameters

none

Returns

  • result:uint64 - block height

Example

  • Request

    curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"seele_getBlockHeight","params":[],"id":1}' localhost:8037
  • Result

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

GetBlock

This method is used to obtain the block content based on block height or block hash.

Type

Template

RPC

{"jsonrpc":"2.0","method":"seele_getBlock","params":[string,string,bool],"id":1}

Parameters

  • hash:string - block hash

  • height:string - block height

  • fulltx, f:bool - whether to include detailed transaction information

Returns

  • debts:array - debts in block

    • Hash:string - debts hash

    • Data:json - debts data

    • TxHash:string - txhash in debt

    • Shard:int - shard number of seele node where debts on

    • Account:array - debt account

    • Amount:int64 - debt amount

    • Fee:int64 - debt fee

    • Code:string - debt code

  • hash:string - block hash

  • header:json - block header

    • PreviousBlockHash:string - previous block hash

    • Creator:string - creator address

    • TxHash:string - tx hash

    • ReceiptHash:string - Receipts hash

    • stateHash:string - state tree hash

    • TxDebtHash:string - debts hash

    • DebtHash:string - debts hash

    • Difficulty:big.Int - block difficulty

    • Height:unit64 - block height

    • CreateTimestamp:uint64 - create timestamp

    • Witness:string - block nonce

    • Consensus:int - consensus algorithm

    • ExtraData:string - extra data

  • totalDifficulty:big.Int - total difficulty

  • transactions:array - transaction array

    • accountNonce:unit64 - account nonce

    • amount:Int - transaction amount

    • from:string - transaction provider

    • gasLimit:Int - transaction gas limit

    • gasPrice:Int - transaction gas price

    • hash:string - transaction hash

    • payload:array - transaction payload

    • to:string - transaction receiver

  • txDebts:array - transaction debts

    • Hash:string - txDebts hash

    • Data:json - txDebts data

      • TxHash:string - transaction hash

      • From:string - transaction sender

      • Nonce:unit64 - sender nonce

      • Account:string - transaction account

      • Amount:int - transaction amount

      • Price:int - transaction gas price

      • Code:string - transaction code

Example

  • Request

    curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"seele_getBlock","params":["",19018,true],"id":1}' localhost:8037
  • Result

    {
      "jsonrpc": "2.0",
      "id": 1,
      "result": {
          "debts": [],
          "hash": "0x000002f75910694bf33a9a2f3e0cab454ac4b14ff9d32aee7b59efc20260f00c",
          "header": {
              "PreviousBlockHash": "0x000005f39610211ad1e888940a0e6affb538ea2397f73e08f1f894537997118c",
              "Creator": "0x4c10f2cd2159bb432094e3be7e17904c2b4aeb21",
              "StateHash": "0xde119fb11c8c74b34a71ce376589a1711af5acef99aaf36827fbaafaeb9fe617",
              "TxHash": "0xa5dea280e6e880af7547ffea5c54526b0a3fae9dcd977a0a5a00e14852eb08ce",
              "ReceiptHash": "0xd6efdf2db85d6a5ab3fdc14925f67b9c97fb7ebdb733e5b2bb5776c694bc9073",
              "TxDebtHash": "0x8fde2b990967a9e51cb5218acc3318faea7a50429760cef37867b12c62f30b78",
              "DebtHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
              "Difficulty": 2258387,
              "Height": 19018,
              "CreateTimestamp": 1548821456,
              "Witness": "MTI4ODU5Njk2MTcyODI5NzQ3MzM=",
              "Consensus": 0,
              "ExtraData": ""
          },
          "totalDifficulty": 52970343102,
          "transactions": [
              {
                  "accountNonce": 0,
                  "amount": 1200000000,
                  "from": "0x0000000000000000000000000000000000000000",
                  "gasLimit": 0,
                  "gasPrice": 0,
                  "hash": "0x0071c67a94f3619d9c7acb6fd40750956df24beb5dfaa5372e87a83bc06e219c",
                  "payload": "",
                  "to": "0x4c10f2cd2159bb432094e3be7e17904c2b4aeb21"
              },
              {
                  "accountNonce": 100,
                  "amount": 88,
                  "from": "0x3b691130ec4166bfc9ec7240217fc8d08903cf21",
                  "gasLimit": 63000,
                  "gasPrice": 10,
                  "hash": "0xf7288fbc1ab3bea992dd5f311644f220b1accf8011f59df4778ca526843d1f68",
                  "payload": "",
                  "to": "0x007d1b1ea335e8e4a74c0be781d828dc7db934b1"
              }
          ],
          "txDebts": [
              {
                  "Hash": "0xa0089462915e0a1b99ce3d75f6b51cdd5caf9a52691f327c9a27d222e0e38d57",
                  "Data": {
                      "TxHash": "0xf7288fbc1ab3bea992dd5f311644f220b1accf8011f59df4778ca526843d1f68",
                      "From": "0x3b691130ec4166bfc9ec7240217fc8d08903cf21",
                      "Nonce": 100,
                      "Account": "0x007d1b1ea335e8e4a74c0be781d828dc7db934b1",
                      "Amount": 88,
                      "Price": 10,
                      "Code": ""
                  }
              }
          ]
      }
    }

GetBlockByHash

This method is used to obtain the block content based on block hash.

Type

Template

RPC

{"jsonrpc":"2.0","method":"seele_getBlockByHash","params":[string,bool],"id":1}

Parameters

  • hash:string - block hash

  • fulltx, f:bool - whether to include detailed transaction information

Returns

  • debts:array - debts in block

    • Hash:string - debts hash

    • Data:json - debts data

    • TxHash:string - txhash in debt

    • Shard:int - shard number of seele node where debts on

    • Account:array - debt account

    • Amount:int64 - debt amount

    • Fee:int64 - debt fee

    • Code:string - debt code

  • hash:string - block hash

  • header:json - block header

    • PreviousBlockHash:string - previous block hash

    • Creator:string - creator address

    • TxHash:string - tx hash

    • ReceiptHash:string - Receipts hash

    • stateHash:string - state tree hash

    • TxDebtHash:string - debts hash

    • DebtHash:string - debts hash

    • Difficulty:big.Int - block difficulty

    • Height:unit64 - block height

    • CreateTimestamp:uint64 - create timestamp

    • Witness:string - block nonce

    • Consensus:int - consensus algorithm

    • ExtraData:string - extra data

  • totalDifficulty:big.Int - total difficulty

  • transactions:array - transaction array

    • accountNonce:unit64 - account nonce

    • amount:Int - transaction amount

    • from:string - transaction provider

    • gasLimit:Int - transaction gas limit

    • gasPrice:Int - transaction gas price

    • hash:string - transaction hash

    • payload:array - transaction payload

    • to:string - transaction receiver

  • txDebts:array - transaction debts

    • Hash:string - txDebts hash

    • Data:json - txDebts data

      • TxHash:string - transaction hash

      • From:string - transaction sender

      • Nonce:unit64 - sender nonce

      • Account:string - transaction account

      • Amount:int - transaction amount

      • Price:int - transaction gas price

      • Code:string - transaction code

Example

  • Request

    curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"seele_getBlockByHash","params":["0x000002f75910694bf33a9a2f3e0cab454ac4b14ff9d32aee7b59efc20260f00c",true],"id":1}' localhost:8037
  • Result

    {
      "jsonrpc": "2.0",
      "id": 1,
      "result": {
          "debts": [],
          "hash": "0x000002f75910694bf33a9a2f3e0cab454ac4b14ff9d32aee7b59efc20260f00c",
          "header": {
              "PreviousBlockHash": "0x000005f39610211ad1e888940a0e6affb538ea2397f73e08f1f894537997118c",
              "Creator": "0x4c10f2cd2159bb432094e3be7e17904c2b4aeb21",
              "StateHash": "0xde119fb11c8c74b34a71ce376589a1711af5acef99aaf36827fbaafaeb9fe617",
              "TxHash": "0xa5dea280e6e880af7547ffea5c54526b0a3fae9dcd977a0a5a00e14852eb08ce",
              "ReceiptHash": "0xd6efdf2db85d6a5ab3fdc14925f67b9c97fb7ebdb733e5b2bb5776c694bc9073",
              "TxDebtHash": "0x8fde2b990967a9e51cb5218acc3318faea7a50429760cef37867b12c62f30b78",
              "DebtHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
              "Difficulty": 2258387,
              "Height": 19018,
              "CreateTimestamp": 1548821456,
              "Witness": "MTI4ODU5Njk2MTcyODI5NzQ3MzM=",
              "Consensus": 0,
              "ExtraData": ""
          },
          "totalDifficulty": 52970343102,
          "transactions": [
              {
                  "accountNonce": 0,
                  "amount": 1200000000,
                  "from": "0x0000000000000000000000000000000000000000",
                  "gasLimit": 0,
                  "gasPrice": 0,
                  "hash": "0x0071c67a94f3619d9c7acb6fd40750956df24beb5dfaa5372e87a83bc06e219c",
                  "payload": "",
                  "to": "0x4c10f2cd2159bb432094e3be7e17904c2b4aeb21"
              },
              {
                  "accountNonce": 100,
                  "amount": 88,
                  "from": "0x3b691130ec4166bfc9ec7240217fc8d08903cf21",
                  "gasLimit": 63000,
                  "gasPrice": 10,
                  "hash": "0xf7288fbc1ab3bea992dd5f311644f220b1accf8011f59df4778ca526843d1f68",
                  "payload": "",
                  "to": "0x007d1b1ea335e8e4a74c0be781d828dc7db934b1"
              }
          ],
          "txDebts": [
              {
                  "Hash": "0xa0089462915e0a1b99ce3d75f6b51cdd5caf9a52691f327c9a27d222e0e38d57",
                  "Data": {
                      "TxHash": "0xf7288fbc1ab3bea992dd5f311644f220b1accf8011f59df4778ca526843d1f68",
                      "From": "0x3b691130ec4166bfc9ec7240217fc8d08903cf21",
                      "Nonce": 100,
                      "Account": "0x007d1b1ea335e8e4a74c0be781d828dc7db934b1",
                      "Amount": 88,
                      "Price": 10,
                      "Code": ""
                  }
              }
          ]
      }
    }

GetBlockByHeight

This method is used to obtain the block content based on block height.

Type

Template

RPC

{"jsonrpc":"2.0","method":"seele_getBlockByHeight","params":[string,bool],"id":1}

Parameters

  • height:string - block height

  • fulltx, f:bool - whether to include detailed transaction information

Returns

  • debts:array - debts in block

    • Hash:string - debts hash

    • Data:json - debts data

    • TxHash:string - txhash in debt

    • Shard:int - shard number of seele node where debts on

    • Account:array - debt account

    • Amount:int64 - debt amount

    • Fee:int64 - debt fee

    • Code:string - debt code

  • hash:string - block hash

  • header:json - block header

    • PreviousBlockHash:string - previous block hash

    • Creator:string - creator address

    • TxHash:string - tx hash

    • ReceiptHash:string - Receipts hash

    • stateHash:string - state tree hash

    • TxDebtHash:string - debts hash

    • DebtHash:string - debts hash

    • Difficulty:big.Int - block difficulty

    • Height:unit64 - block height

    • CreateTimestamp:uint64 - create timestamp

    • Witness:string - block nonce

    • Consensus:int - consensus algorithm

    • ExtraData:string - extra data

  • totalDifficulty:big.Int - total difficulty

  • transactions:array - transaction array

    • accountNonce:unit64 - account nonce

    • amount:Int - transaction amount

    • from:string - transaction provider

    • gasLimit:Int - transaction gas limit

    • gasPrice:Int - transaction gas price

    • hash:string - transaction hash

    • payload:array - transaction payload

    • to:string - transaction receiver

  • txDebts:array - transaction debts

    • Hash:string - txDebts hash

    • Data:json - txDebts data

      • TxHash:string - transaction hash

      • From:string - transaction sender

      • Nonce:unit64 - sender nonce

      • Account:string - transaction account

      • Amount:int - transaction amount

      • Price:int - transaction gas price

      • Code:string - transaction code

Example

  • Request

    curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"seele_getBlockByHeight","params":[19018,true],"id":1}' localhost:8037
  • Result

    {
      "jsonrpc": "2.0",
      "id": 1,
      "result": {
          "debts": [],
          "hash": "0x000002f75910694bf33a9a2f3e0cab454ac4b14ff9d32aee7b59efc20260f00c",
          "header": {
              "PreviousBlockHash": "0x000005f39610211ad1e888940a0e6affb538ea2397f73e08f1f894537997118c",
              "Creator": "0x4c10f2cd2159bb432094e3be7e17904c2b4aeb21",
              "StateHash": "0xde119fb11c8c74b34a71ce376589a1711af5acef99aaf36827fbaafaeb9fe617",
              "TxHash": "0xa5dea280e6e880af7547ffea5c54526b0a3fae9dcd977a0a5a00e14852eb08ce",
              "ReceiptHash": "0xd6efdf2db85d6a5ab3fdc14925f67b9c97fb7ebdb733e5b2bb5776c694bc9073",
              "TxDebtHash": "0x8fde2b990967a9e51cb5218acc3318faea7a50429760cef37867b12c62f30b78",
              "DebtHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
              "Difficulty": 2258387,
              "Height": 19018,
              "CreateTimestamp": 1548821456,
              "Witness": "MTI4ODU5Njk2MTcyODI5NzQ3MzM=",
              "Consensus": 0,
              "ExtraData": ""
          },
          "totalDifficulty": 52970343102,
          "transactions": [
              {
                  "accountNonce": 0,
                  "amount": 1200000000,
                  "from": "0x0000000000000000000000000000000000000000",
                  "gasLimit": 0,
                  "gasPrice": 0,
                  "hash": "0x0071c67a94f3619d9c7acb6fd40750956df24beb5dfaa5372e87a83bc06e219c",
                  "payload": "",
                  "to": "0x4c10f2cd2159bb432094e3be7e17904c2b4aeb21"
              },
              {
                  "accountNonce": 100,
                  "amount": 88,
                  "from": "0x3b691130ec4166bfc9ec7240217fc8d08903cf21",
                  "gasLimit": 63000,
                  "gasPrice": 10,
                  "hash": "0xf7288fbc1ab3bea992dd5f311644f220b1accf8011f59df4778ca526843d1f68",
                  "payload": "",
                  "to": "0x007d1b1ea335e8e4a74c0be781d828dc7db934b1"
              }
          ],
          "txDebts": [
              {
                  "Hash": "0xa0089462915e0a1b99ce3d75f6b51cdd5caf9a52691f327c9a27d222e0e38d57",
                  "Data": {
                      "TxHash": "0xf7288fbc1ab3bea992dd5f311644f220b1accf8011f59df4778ca526843d1f68",
                      "From": "0x3b691130ec4166bfc9ec7240217fc8d08903cf21",
                      "Nonce": 100,
                      "Account": "0x007d1b1ea335e8e4a74c0be781d828dc7db934b1",
                      "Amount": 88,
                      "Price": 10,
                      "Code": ""
                  }
              }
          ]
      }
    }

Call

This method is used to execute a given transaction on a statedb of a given block height. It does not affect the statedb or blockchain and is useful for executing and retrieving values. However, the height currently does not support optional and will remove the from parameter in the next version or more.

Type

Template

RPC

{"jsonrpc":"2.0","method":"seele_call ","params":[CallRequest],"id":1}

Parameters

  • to:string - to address

  • payload:string - transaction payload info

  • Height:int64 - block height (default: -1)

Returns

  • contract:string - contract address

  • failed:bool - contract executes successfully or not

  • poststate:string - state trie root hash after transaction execution

  • result:string - transaction result

  • totalFee:int64 - transaction fee

  • txhash:string - transaction hash

  • usedGas:int64 - transaction gas

Example

When using the example below, the contract must be deployed first. The solidity code file:

pragma solidity ^0.4.0;

contract SimpleStorage {
    uint storedData=23;

    function set(uint x) {
        storedData=x;
    }

    function get() constant returns(uint) {
        return storedData;
    }
}

As you can see, the example is testing the get function.

  • Request

    curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"seele_call","params":["0x9df8ed11ea024183bd584480e80952c9b04e0122","0x6d4ce63c",-1],"id":1}' localhost:8037
  • Result

    {
      "jsonrpc": "2.0",
      "id": 1,
      "result": {
          "contract": "0x",
          "failed": false,
          "poststate": "0xb724c37fd2047d26c7e22da0f43d8c520aa15d9fc9358872583eb4a11b9c6787",
          "result": "0x0000000000000000000000000000000000000000000000000000000000000005",
          "totalFee": 101,
          "txhash": "0xefaa679d7b6bbbf2b56b198f45156a82a737a352cb1d42f2f5357ed3a4f91a16",
          "usedGas": 424
      }
    }

GetLogs

This method gets the event logs by block height, the contract address, and the event name.

Type

Template

RPC

{"jsonrpc":"2.0","method":"seele_getLogs ","params":[GetLogsRequest],"id":1}

Parameters

  • height:int64 - block height (default: -1)

  • contract:string - contract address

  • abi:string - contract abi

  • event:string - event name

Returns

  • address:string - contract address

  • topics:array - topic array

  • data:string - data

  • blocknumber:uint64 - block height

  • transactionNumber:uint - the index of the transaction in the block

Example

When using the example below, the contract must be deployed first. The solidity code file:

pragma solidity ^0.4.0;

contract simple_storage_1 {
    uint storedData=23;

    event getLog(address addr, string message);
    event getLog1(string message);
    event getLog2(string message);

    function set(uint x) public{
        getLog1("set getLog1");
        getLog2("set getLog2");
        storedData=x;
    }

    function get() constant public returns(uint) {
        getLog(msg.sender, "get getLog");
        getLog1("get getLog1");
        set(16);
        return storedData;
    }
}

As you can see, this example is testing the get function. In this situation, the height is the block height of the block containing the get transaction.

  • Request

curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"seele_getLogs","params":[1760936,"0x4df9ac0d329c07da15f202090649258c109a0022","[{\"constant\":false,\"inputs\":[{\"name\":\"x\",\"type\":\"uint256\"}],\"name\":\"set\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"addr\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"message\",\"type\":\"string\"}],\"name\":\"getLog\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"message\",\"type\":\"string\"}],\"name\":\"getLog1\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"message\",\"type\":\"string\"}],\"name\":\"getLog2\",\"type\":\"event\"},{\"constant\":true,\"inputs\":[],\"name\":\"get\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"}]","getLog2"],"id":1}' localhost:8037
  • Result

{"jsonrpc":"2.0","id":1,"result":[{"address":"0x4df9ac0d329c07da15f202090649258c109a0022","topics":["0xe84bb31d4e9adbff26e80edeecb6cf8f3a95d1ba519cf60a08a6e6f8d62d8100"],"data":"0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000b736574206765744c6f6732000000000000000000000000000000000000000000","blockNumber":1760936,"transactionIndex":1}]}

GeneratePayload

This method generate the contract method payload.

Type

Template

RPC

{"jsonrpc":"2.0","method":"seele_generatePayload","params":[string, string, []string],"id":1}

Parameters

  • abiJSON:string - contract json string

  • methodName:string - contract method name

  • args:string - args of contract method

Returns

  • result:string payload of contract method with args

Example

  • Request

    curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"seele_generatePayload","params":["[{\"constant\":false,\"inputs\":[{\"name\":\"x\",\"type\":\"uint256\"}],\"name\":\"set\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"get\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"}]", "set", ["1"]],"id":1}' localhost:8037
  • Result

    {
      "jsonrpc": "2.0",
      "id": 1,
      "result": "0x60fe47b10000000000000000000000000000000000000000000000000000000000000001"
    }

EstimateGas

This method Estimate the gas of a transaction.

Type

Template

RPC

{"jsonrpc":"2.0","method":"seele_estimateGas","params":[types.Transaction],"id":1}

Parameters

  • Hash:string - transaction hash

  • Data:json - transaction data

    • From:string - transaction sender

    • To:string - transaction receiver

    • Amount:uint64 - amount value, unit is fan

    • GasPrice:uint64 - transaction gas price in Fan

    • GasLimit:uint64 - maximum gas for transaction

    • Payload:string - transaction payload

    • AccountNonce:uint64 - transaction nonce

Returns

  • result:uint64 - gas amount

Example

  • Request

    curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"seele_estimateGas","params":[{"Hash": "0xd02530a4126ecea2787d59bf5e9611907c6043dd900f894554624bd1d25bcb32","Data": {"From": "0x4c10f2cd2159bb432094e3be7e17904c2b4aeb21","To": "0x0ea2a45ab5a909c309439b0e004c61b7b2a3e831","Amount": 20000,"AccountNonce": 1,"GasPrice": 10,"GasLimit": 200000,"Payload": ""}}],"id":1}' localhost:8037
  • Result

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

txpool

RPC collection provided for internal use for transaction pool inquiry manipulation.

GetBlockTransactionCount

This method is used to obtain the number of transactions in the transaction pool based on block height or hash.

Type

Template

RPC

{"jsonrpc":"2.0","method":"txpool_getBlockTransactionCount","params":[string,int64],"id":1}

Parameters

  • hash:string - hash value in hex

  • height:int64 - block height (default: -1)

Returns

  • result:int - transactions count

Example

  • Request

    curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"txpool_getBlockTransactionCount","params":["0x0000015592fab87d6efa10e63d7722f6f359d90a1aff9e70930b291931c34922",-1],"id":1}' localhost:8037
  • Result

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

GetBlockTransactionCountByHeight

This method is used to obtain the number of transactions in the transaction pool based on block height.

Type

Template

RPC

{"jsonrpc":"2.0","method":"txpool_getBlockTransactionCountByHeight","params":[int64],"id":1}

Parameters

  • height:int64 - block height (default: -1)

Returns

  • result:int - transactions count

Example

  • Request

    curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"txpool_getBlockTransactionCountByHeight","params":[-1],"id":1}' localhost:8037
  • Result

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

GetBlockTransactionCountByHash

This method is used to obtain the number of transactions in the transaction pool based on block hash.

Type

Template

RPC

{"jsonrpc":"2.0","method":"txpool_getBlockTransactionCountByHash","params":[string],"id":1}

Parameters

  • hash:string - hash value in hex

Returns

  • result:int - transactions count

Example

  • Request

    curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"txpool_getBlockTransactionCountByHash","params":["0x0000004c0336e63f76e7bd2b7888514eff47b3528df67ca6ee95edb9dff79c00"],"id":1}' localhost:8037
  • Result

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

GetTransactionByBlockIndex

This method is used to obtain the transaction content based on block height or hash and transaction index.

Type

Template

RPC

{"jsonrpc":"2.0","method":"txpool_getTransactionByBlockIndex","params":[string,int,int],"id":1}

Parameters

  • hash:string - block hash

  • height:int - block height (default: -1)

  • index:int - transaction index, start with 0 (default: 0)

Returns

  • accountNonce:unit64 - account nonce

  • amount:Int - transaction amount

  • gasLimit:Int - transaction gas limit

  • gasPrice:Int - transaction gas price

  • from:string - transaction provider

  • to:string - transaction receiver

  • hash:string - transaction hash

  • payload:array - transaction payload

Example

  • Request

    curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"txpool_getTransactionByBlockIndex","params":["0x0000015592fab87d6efa10e63d7722f6f359d90a1aff9e70930b291931c34922", -1, 1],"id":1}' localhost:8037
  • Result

    {
      "jsonrpc": "2.0",
      "id": 1,
      "result": {
          "accountNonce": 0,
          "amount": 150000000,
          "from": "0x0000000000000000000000000000000000000000",
          "gasLimit": 0,
          "gasPrice": 0,
          "hash": "0x473ea3667d073491d5896a93fcf84d7dd822988d07482f21e7a875787539e62e",
          "payload": "",
          "to": "0x4c10f2cd2159bb432094e3be7e17904c2b4aeb21"
      }
    }

GetTransactionByBlockHeightAndIndex

This method is used to obtain the transaction content based on block height and transaction index.

Type

Template

RPC

{"jsonrpc":"2.0","method":"txpool_getTransactionByBlockHeightAndIndex","params":[int,int],"id":1}

Parameters

  • height:int - block height (default: -1)

  • index:int - transaction index, start with 0 (default: 0)

Returns

  • accountNonce:unit64 - account nonce

  • amount:Int - transaction amount

  • gasLimit:Int - transaction gas limit

  • gasPrice:Int - transaction gas price

  • from:string - transaction provider

  • to:string - transaction receiver

  • hash:string - transaction hash

  • payload:array - transaction payload

Example

  • Request

    curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"txpool_getTransactionByBlockHeightAndIndex","params":[4202, 1],"id":1}' localhost:8037
  • Result

    {
      "jsonrpc": "2.0",
      "id": 1,
      "result": {
          "accountNonce": 0,
          "amount": 150000000,
          "from": "0x0000000000000000000000000000000000000000",
          "gasLimit": 0,
          "gasPrice": 0,
          "hash": "0x473ea3667d073491d5896a93fcf84d7dd822988d07482f21e7a875787539e62e",
          "payload": "",
          "to": "0x4c10f2cd2159bb432094e3be7e17904c2b4aeb21"
      }
    }

GetTransactionByBlockHashAndIndex

This method is used to obtain the transaction content based on block hash and transaction index.

Type

Template

RPC

{"jsonrpc":"2.0","method":"txpool_getTransactionByBlockHashAndIndex","params":[string,int],"id":1}

Parameters

  • hash:string - block hash

  • index:int - transaction index, start with 0 (default: 0)

Returns

  • accountNonce:unit64 - account nonce

  • amount:Int - transaction amount

  • gasLimit:Int - transaction gas limit

  • gasPrice:Int - transaction gas price

  • from:string - transaction provider

  • to:string - transaction receiver

  • hash:string - transaction hash

  • payload:array - transaction payload

Example

  • Request

    curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"txpool_getTransactionByBlockHashAndIndex","params":["0x0000015592fab87d6efa10e63d7722f6f359d90a1aff9e70930b291931c34922", 1],"id":1}' localhost:8037
  • Result

    {
      "jsonrpc": "2.0",
      "id": 1,
      "result": {
          "accountNonce": 0,
          "amount": 150000000,
          "from": "0x0000000000000000000000000000000000000000",
          "gasLimit": 0,
          "gasPrice": 0,
          "hash": "0x473ea3667d073491d5896a93fcf84d7dd822988d07482f21e7a875787539e62e",
          "payload": "",
          "to": "0x4c10f2cd2159bb432094e3be7e17904c2b4aeb21"
      }
    }

GetTransactionByHash

This method returns transaction information by hash.

Type

Template

RPC

{"jsonrpc":"2.0","method":"txpool_getTransactionByHash","params":[string],"id":1}

Parameters

  • hash:string - hash value in hex

Returns

  • blockHash:string - block hash

  • blockHeight:int - block height

  • status:string - transaction status

  • accountNonce:unit64 - account nonce

  • amount:Int - transaction amount

  • gasLimit:Int - transaction gas limit

  • gasPrice:Int - transaction gas price

  • from:string - transaction provider

  • to:string - transaction receiver

  • hash:string - transaction hash

  • payload:array - transaction payload

  • txIndex:int - transaction index in block

Example

  • Request

    curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"txpool_getTransactionByHash","params":["0xbd2ca4f9869c714e589ad6a3b16731c8cb066de40d0e27e220cc1e014577baff"],"id":1}' localhost:8037
  • Result

    {
      "jsonrpc": "2.0",
      "id": 1,
      "result": {
          "blockHash": "0x0000009c753570436b0bdd4ea1b9cfb1611f181f7aae82d4ba265761c50c8479",
          "blockHeight": 3608,
          "status": "block",
          "transaction": {
                  "accountNonce": 0,
                  "amount": 150000000,
                  "from": "0x0000000000000000000000000000000000000000",
                  "gasLimit": 0,
                  "gasPrice": 0,
                  "hash": "0x473ea3667d073491d5896a93fcf84d7dd822988d07482f21e7a875787539e62e",
                  "payload": "",
                  "to": "0x4c10f2cd2159bb432094e3be7e17904c2b4aeb21"
          },
          "txIndex": 0
      }
    }

GetReceiptByTxHash

This method is used to obtain the receipt contents based on transaction hash.

Type

Template

RPC

{"jsonrpc":"2.0","method":"txpool_getReceiptByTxHash","params":[string,string],"id":1}

Parameters

  • hash:string - hash value in hex

  • abi:string - the abi file of contract

Returns

  • contract:string - contract address

  • failed:bool - transaction executes successfully or not

  • poststate:string - state trie root hash after transaction execution

  • result:string - transaction result

  • totalFee:int - transaction fee

  • txhash:string - transaction hash

  • usedGas:int - transaction gas

Example

  • Request

    curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"txpool_getReceiptByTxHash","params":["0xbd2ca4f9869c714e589ad6a3b16731c8cb066de40d0e27e220cc1e014577baff","""],"id":1}' localhost:8037
  • Result

    {
      "jsonrpc": "2.0",
      "id": 1,
      "result": {
          "contract": "0x",
          "failed": false,
          "poststate": "0xdd0b0fc6605bbb2e76b8c22ccd466ea5eaa1a80e4860fbdf971be58ded3d782b",
          "result": "0x",
          "totalFee": 1,
          "txhash": "0xbd2ca4f9869c714e589ad6a3b16731c8cb066de40d0e27e220cc1e014577baff",
          "usedGas": 0
      }
    }

GetDebtByHash

This method is used to obtain the debt contents based on debt hash.

Type

Template

RPC

{"jsonrpc":"2.0","method":"txpool_getDebtByHash","params":[string],"id":1}

Parameters

  • hash:string - debt hash value in hex

Returns

  • blockHash:string - block hash of the debt on

  • blockHeight:int64 - block height of the debt on

  • debt:json - debt json

    • Hash:string - debt hash

    • Data:json - debt data

      • TxHash:string - txhash in debt

      • From:string - address of the sender

      • Nonce: uint64 - nonce of From address

      • Account:string - debt account

      • Amount:int64 - debt amount

      • Price:int64 - debt price

      • Code:string - debt contract code

  • debtIndex:int - debt index of the block debts

  • status:string - debt status

Example

  • Request

    curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"txpool_getDebtByHash","params":["0x0da1ed893e7f0ca2558c193b3b82ed20575a6978bea5b14f282309c69fee368e"],"id":1}' localhost:8037
  • Result

    {
      "jsonrpc": "2.0",
      "id": 1,
      "result": {
          "blockHash": "0x000001fb7817c8d9eeaa9bbed6670f8db62b605ad174f561e74afc60ac18c97b",
          "blockHeight": 170,
          "debt": {
              "Hash": "0xa0089462915e0a1b99ce3d75f6b51cdd5caf9a52691f327c9a27d222e0e38d57",
              "Data": {
                  "TxHash": "0xf7288fbc1ab3bea992dd5f311644f220b1accf8011f59df4778ca526843d1f68",
                  "From": "0x3b691130ec4166bfc9ec7240217fc8d08903cf21",
                  "Nonce": 100,
                  "Account": "0x007d1b1ea335e8e4a74c0be781d828dc7db934b1",
                  "Amount": 88,
                  "Price": 10,
                  "Code": ""
              }
          },
          "debtIndex": 0,
          "status": "block"
      }
    }

download

RPC collection provided for internal inquiry of blockchain node synchronization state.

GetStatus

This method returns synchronization information.

Type

Template

RPC

{"jsonrpc":"2.0","method":"download_getStatus","params":[],"id":2}

Parameters

none

Returns

  • Status:string - synchronization state

  • Duration:string - synchronization duration (seconds)

  • StartNum:uint64 - synchronization initial block height

  • Amount:uint64 - synchronization value

  • Downloaded:uint64 - Synchronization number of times

Example