get_transactions - Nervos

Returns the transactions collection by the lock or type script.

Parameters

  • search_key:
    • script - Script, supports prefix search when group_by_transaction is false.
    • scrip_type - enum, lock | type
    • filter - filter cells by following conditions, all conditions are optional
      • script: if search script type is lock, filter cells by type script, and vice versa
      • block_range: [u64; 2], filter cells by block number range, [inclusive, exclusive]
    • group_by_transaction - bool, optional default is false, if group_by_transaction is set to true, the returning objects will be grouped by the tx hash
  • order: enum, asc | desc
  • limit: result size limit
  • after_cursor: pagination parameter, optional

Returns

  • objects - enum, ungrouped TxWithCell | grouped TxWithCells
    • TxWithCell:
      • tx_hash: transaction hash
      • block_number: the number of the transaction committed in the block
      • tx_index: the position index of the transaction committed in the block
      • io_type: enum, input | output
      • io_index: the position index of the cell in the transaction inputs or outputs
    • TxWithCells:
      • tx_hash: transaction hash,
      • block_number: the number of the transaction committed in the block
      • tx_index: the position index of the transaction committed in the block
      • cells: Array [[io_type, io_index]]
  • last_cursor - pagination parameter

Example

  • get transactions by lock script

Request

{
    "id": 2,
    "jsonrpc": "2.0",
    "method": "get_transactions",
    "params": [
        {
            "script": {
                "code_hash": "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8",
                "hash_type": "type",
                "args": "0x5989ae415bb667931a99896e5fbbfad9ba53a223"
            },
            "script_type": "lock"
        },
        "asc",
        "0x64"
    ]
}

Result

{
    "jsonrpc": "2.0",
    "result": {
      "last_cursor": "0x809bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8015989ae415bb667931a99896e5fbbfad9ba53a22300000000005b59df000000010000000101",
      "objects": [
        {
          "block_number": "0x5b033a",
          "io_index": "0x0",
          "io_type": "output",
          "tx_hash": "0x556060b62d16386da53f8a4b458314dfa2d1988a7bcc5c96c3bb2a350a3453a1",
          "tx_index": "0x4"
        },
        {
          "block_number": "0x5b0671",
          "io_index": "0x0",
          "io_type": "input",
          "tx_hash": "0x8205b2b4cd6380d7e332c7a5b49bf776a0322ba19f46dc6ca1f8c59f7daee08d",
          "tx_index": "0x1"
        },
        {
          "block_number": "0x5b0671",
          "io_index": "0x1",
          "io_type": "output",
          "tx_hash": "0x8205b2b4cd6380d7e332c7a5b49bf776a0322ba19f46dc6ca1f8c59f7daee08d",
          "tx_index": "0x1"
        },
        {
          "block_number": "0x5b0e6d",
          "io_index": "0x0",
          "io_type": "output",
          "tx_hash": "0xe8f2180dfba0cb15b45f771d520834515a5f8d7aa07f88894da88c22629b79e9",
          "tx_index": "0x1"
        },
        {
          "block_number": "0x5b0e90",
          "io_index": "0x0",
          "io_type": "output",
          "tx_hash": "0xece3a27409bde2914fb7a1555d6bfca453ee46af73e665149ef549fd46ec1fc6",
          "tx_index": "0x1"
        },
        {
          "block_number": "0x5b0ead",
          "io_index": "0x0",
          "io_type": "input",
          "tx_hash": "0x5c48768f91e3795b418c53211c76fd038c464a24c4aa7e35bbbb6ac5b219f581",
          "tx_index": "0x1"
        },
        {
          "block_number": "0x5b0ead",
          "io_index": "0x1",
          "io_type": "output",
          "tx_hash": "0x5c48768f91e3795b418c53211c76fd038c464a24c4aa7e35bbbb6ac5b219f581",
          "tx_index": "0x1"
        },
        {
          "block_number": "0x5b0eeb",
          "io_index": "0x0",
          "io_type": "output",
          "tx_hash": "0x90e6981d6a5692d92e54344dc0e12d213447710fa069cc19ddea874619b9ba48",
          "tx_index": "0x1"
        },
        {
          "block_number": "0x5b0f8c",
          "io_index": "0x0",
          "io_type": "output",
          "tx_hash": "0x9ea14510219ae97afa0275215fa77c3c015905281c953a3917a7fd036767429c",
          "tx_index": "0x1"
        },
        {
          "block_number": "0x5b5638",
          "io_index": "0x0",
          "io_type": "input",
          "tx_hash": "0x9346da4caa846cc035c182ecad0c17326a587983d25fb1e12a388f1a9c5c56b4",
          "tx_index": "0x1"
        },
        {
          "block_number": "0x5b5638",
          "io_index": "0x1",
          "io_type": "input",
          "tx_hash": "0x9346da4caa846cc035c182ecad0c17326a587983d25fb1e12a388f1a9c5c56b4",
          "tx_index": "0x1"
        },
        {
          "block_number": "0x5b5638",
          "io_index": "0x1",
          "io_type": "output",
          "tx_hash": "0x9346da4caa846cc035c182ecad0c17326a587983d25fb1e12a388f1a9c5c56b4",
          "tx_index": "0x1"
        },
        {
          "block_number": "0x5b5638",
          "io_index": "0x2",
          "io_type": "input",
          "tx_hash": "0x9346da4caa846cc035c182ecad0c17326a587983d25fb1e12a388f1a9c5c56b4",
          "tx_index": "0x1"
        },
        {
          "block_number": "0x5b59c2",
          "io_index": "0x0",
          "io_type": "input",
          "tx_hash": "0x5b58f90fb3309333bf0bec878f3a05038c7fe816747300ecdac37a9da76c4128",
          "tx_index": "0x1"
        },
        {
          "block_number": "0x5b59c2",
          "io_index": "0x1",
          "io_type": "output",
          "tx_hash": "0x5b58f90fb3309333bf0bec878f3a05038c7fe816747300ecdac37a9da76c4128",
          "tx_index": "0x1"
        },
        {
          "block_number": "0x5b59cc",
          "io_index": "0x0",
          "io_type": "input",
          "tx_hash": "0x57ca2822c28e02b199424a731b2efd2c9bf752f07b7309f555f2e71abe83ba26",
          "tx_index": "0x1"
        },
        {
          "block_number": "0x5b59cc",
          "io_index": "0x1",
          "io_type": "input",
          "tx_hash": "0x57ca2822c28e02b199424a731b2efd2c9bf752f07b7309f555f2e71abe83ba26",
          "tx_index": "0x1"
        },
        {
          "block_number": "0x5b59cc",
          "io_index": "0x1",
          "io_type": "output",
          "tx_hash": "0x57ca2822c28e02b199424a731b2efd2c9bf752f07b7309f555f2e71abe83ba26",
          "tx_index": "0x1"
        },
        {
          "block_number": "0x5b59df",
          "io_index": "0x0",
          "io_type": "input",
          "tx_hash": "0x21c4632a41140b828e9347ff80480b3e07be4e0a0b8d577565e7421fd5473194",
          "tx_index": "0x1"
        },
        {
          "block_number": "0x5b59df",
          "io_index": "0x1",
          "io_type": "output",
          "tx_hash": "0x21c4632a41140b828e9347ff80480b3e07be4e0a0b8d577565e7421fd5473194",
          "tx_index": "0x1"
        }
      ]
    },
    "id": 2
}
  • get transactions by lock script and group by tx hash

Request

{
    "id": 2,
    "jsonrpc": "2.0",
    "method": "get_transactions",
    "params": [
        {
            "script": {
                "code_hash": "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8",
                "hash_type": "type",
                "args": "0x5989ae415bb667931a99896e5fbbfad9ba53a223"
            },
            "script_type": "lock",
            "group_by_transaction": true
        },
        "asc",
        "0x64"
    ]
}

Result

{
    "jsonrpc": "2.0",
    "result": {
      "last_cursor": "0x809bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8015989ae415bb667931a99896e5fbbfad9ba53a22300000000005b59df000000010000000101",
      "objects": [
        {
          "block_number": "0x5b033a",
          "cells": [
            [
              "output",
              "0x0"
            ]
          ],
          "tx_hash": "0x556060b62d16386da53f8a4b458314dfa2d1988a7bcc5c96c3bb2a350a3453a1",
          "tx_index": "0x4"
        },
        {
          "block_number": "0x5b0671",
          "cells": [
            [
              "input",
              "0x0"
            ],
            [
              "output",
              "0x1"
            ]
          ],
          "tx_hash": "0x8205b2b4cd6380d7e332c7a5b49bf776a0322ba19f46dc6ca1f8c59f7daee08d",
          "tx_index": "0x1"
        },
        {
          "block_number": "0x5b0e6d",
          "cells": [
            [
              "output",
              "0x0"
            ]
          ],
          "tx_hash": "0xe8f2180dfba0cb15b45f771d520834515a5f8d7aa07f88894da88c22629b79e9",
          "tx_index": "0x1"
        },
        {
          "block_number": "0x5b0e90",
          "cells": [
            [
              "output",
              "0x0"
            ]
          ],
          "tx_hash": "0xece3a27409bde2914fb7a1555d6bfca453ee46af73e665149ef549fd46ec1fc6",
          "tx_index": "0x1"
        },
        {
          "block_number": "0x5b0ead",
          "cells": [
            [
              "input",
              "0x0"
            ],
            [
              "output",
              "0x1"
            ]
          ],
          "tx_hash": "0x5c48768f91e3795b418c53211c76fd038c464a24c4aa7e35bbbb6ac5b219f581",
          "tx_index": "0x1"
        },
        {
          "block_number": "0x5b0eeb",
          "cells": [
            [
              "output",
              "0x0"
            ]
          ],
          "tx_hash": "0x90e6981d6a5692d92e54344dc0e12d213447710fa069cc19ddea874619b9ba48",
          "tx_index": "0x1"
        },
        {
          "block_number": "0x5b0f8c",
          "cells": [
            [
              "output",
              "0x0"
            ]
          ],
          "tx_hash": "0x9ea14510219ae97afa0275215fa77c3c015905281c953a3917a7fd036767429c",
          "tx_index": "0x1"
        },
        {
          "block_number": "0x5b5638",
          "cells": [
            [
              "input",
              "0x0"
            ],
            [
              "input",
              "0x1"
            ],
            [
              "output",
              "0x1"
            ],
            [
              "input",
              "0x2"
            ]
          ],
          "tx_hash": "0x9346da4caa846cc035c182ecad0c17326a587983d25fb1e12a388f1a9c5c56b4",
          "tx_index": "0x1"
        },
        {
          "block_number": "0x5b59c2",
          "cells": [
            [
              "input",
              "0x0"
            ],
            [
              "output",
              "0x1"
            ]
          ],
          "tx_hash": "0x5b58f90fb3309333bf0bec878f3a05038c7fe816747300ecdac37a9da76c4128",
          "tx_index": "0x1"
        },
        {
          "block_number": "0x5b59cc",
          "cells": [
            [
              "input",
              "0x0"
            ],
            [
              "input",
              "0x1"
            ],
            [
              "output",
              "0x1"
            ]
          ],
          "tx_hash": "0x57ca2822c28e02b199424a731b2efd2c9bf752f07b7309f555f2e71abe83ba26",
          "tx_index": "0x1"
        },
        {
          "block_number": "0x5b59df",
          "cells": [
            [
              "input",
              "0x0"
            ],
            [
              "output",
              "0x1"
            ]
          ],
          "tx_hash": "0x21c4632a41140b828e9347ff80480b3e07be4e0a0b8d577565e7421fd5473194",
          "tx_index": "0x1"
        }
      ]
    },
    "id": 2
}

🚧

The below parameter inputs do not work, please reference the section above instead.

Language
Click Try It! to start a request and see the response here!