Skip to content

Latest commit

 

History

History
1869 lines (1385 loc) · 50 KB

RPC.md

File metadata and controls

1869 lines (1385 loc) · 50 KB

RPC

Table of Contents

Methods

Method gw_ping

  • gw_ping()
  • result: pong

Get node info.

Examples

Request

{
    "id": 42,
    "jsonrpc": "2.0",
    "method": "gw_ping",
    "params": []
}

Response

{
    "id": 42,
    "jsonrpc": "2.0",
    "result": "pong"
}

Method gw_get_node_info

Get node info.

Examples

Request

{
    "id": 42,
    "jsonrpc": "2.0",
    "method": "gw_get_node_info",
    "params": []
}

Response

{
    "jsonrpc": "2.0",
    "id": 42,
    "result": {
        "mode": "fullnode",
        "version": "1.1.0 f3cdd47",
        "backends": [
            {
                "validator_code_hash": "0xb9d9375c0fd4d50ed95019d8307961238316cd18c1fb3faeb15ac0d3c6d76bda",
                "generator_code_hash": "0xf87824d6723b3c0be51b1213e8b35a6e8587a10f2f27734a344f201bf2ab05ef",
                "validator_script_type_hash": "0xb6176a6170ea33f8468d61f934c45c57d29cdc775bcd3ecaaec183f04b9f33d9",
                "backend_type": "sudt"
            },
            {
                "validator_code_hash": "0xb94f8adecaa8638318fc62f609431daa225bc22143ce23c03c59c78a78653448",
                "generator_code_hash": "0x9c64de23b69dc8496879d18156f6e79fa7cae4a9faf67e23e0ab3e7d1687ac35",
                "validator_script_type_hash": "0x1629b04b49ded9e5747481f985b11cba6cdd4ffc167971a585e96729455ca736",
                "backend_type": "polyjuice"
            },
            {
                "validator_code_hash": "0x9085bd6a550a9921b46d23ba7d9b0f9f5c5d0c9c00999988cd907ce16015e467",
                "generator_code_hash": "0xe2ba730569850cca7a56c9a96754bd0bfd784c8f001e997e4512edf572190c4a",
                "validator_script_type_hash": "0xa30dcbb83ebe571f49122d8d1ce4537679ebf511261c8ffaaa6679bf9fdea3a4",
                "backend_type": "eth_addr_reg"
            },
            {
                "validator_code_hash": "0x4cf8b2b8b04dab0de276093de71f98592a5d683d42e2aa70110e904b564fc1c3",
                "generator_code_hash": "0x8c6c44b97d9de23dc0047356fb0b3e258a60e14a1f2bfa8f95ddc7b41985a8e0",
                "validator_script_type_hash": "0x37b25df86ca495856af98dff506e49f2380d673b0874e13d29f7197712d735e8",
                "backend_type": "meta"
            }
        ],
        "eoa_scripts": [
            {
                "type_hash": "0x07521d0aa8e66ef441ebc31204d86bb23fc83e9edc58c19dbb1b0ebe64336ec0",
                "script": {
                    "code_hash": "0x00000000000000000000000000000000000000000000000000545950455f4944",
                    "hash_type": "type",
                    "args": "0x66056785e4e989729053508c30d620ead06b377f600eedc0419e6858e459ccfa"
                },
                "eoa_type": "eth"
            }
        ],
        "gw_scripts": [
            {
                "type_hash": "0x1e44736436b406f8e48a30dfbddcf044feb0c9eebfe63b0f81cb5bb727d84854",
                "script": {
                    "code_hash": "0x00000000000000000000000000000000000000000000000000545950455f4944",
                    "hash_type": "type",
                    "args": "0x063555cc66a1c270aafbe9324718232289a462f4d9edfc7a57f9c6e0f8257669"
                },
                "script_type": "state_validator"
            },
            {
                "type_hash": "0x50704b84ecb4c4b12b43c7acb260ddd69171c21b4c0ba15f3c469b7d143f6f18",
                "script": {
                    "code_hash": "0x00000000000000000000000000000000000000000000000000545950455f4944",
                    "hash_type": "type",
                    "args": "0x86d24e5cb132478005dcf2b59680a9f37011cb54a5947f42f19ba5076bc6594d"
                },
                "script_type": "deposit"
            },
            {
                "type_hash": "0x06ae0706bb2d7997d66224741d3ec7c173dbb2854a6d2cf97088796b677269c6",
                "script": {
                    "code_hash": "0x00000000000000000000000000000000000000000000000000545950455f4944",
                    "hash_type": "type",
                    "args": "0xbfef6580c1f93b98fa7d33bb3faa63255caba9bfbebfbada5eab4ce195052b9f"
                },
                "script_type": "withdraw"
            },
            {
                "type_hash": "0x7f5a09b8bd0e85bcf2ccad96411ccba2f289748a1c16900b0635c2ed9126f288",
                "script": {
                    "code_hash": "0x00000000000000000000000000000000000000000000000000545950455f4944",
                    "hash_type": "type",
                    "args": "0x0fc0f22f9a6e000692159c9d5dc633fba7ffcd1f1f2218d23aa2ede96f4b471d"
                },
                "script_type": "stake_lock"
            },
            {
                "type_hash": "0x85ae4db0dd83f428a31deb342e4000af37ce2c9645d9e619df00096e3c50a2bb",
                "script": {
                    "code_hash": "0x00000000000000000000000000000000000000000000000000545950455f4944",
                    "hash_type": "type",
                    "args": "0xc4695745c69c298c89bc701b6cc8614332c6fd8a2ed160e04748fc6fda636e71"
                },
                "script_type": "custodian_lock"
            },
            {
                "type_hash": "0x06ae0706bb2d7997d66224741d3ec7c173dbb2854a6d2cf97088796b677269c6",
                "script": {
                    "code_hash": "0x00000000000000000000000000000000000000000000000000545950455f4944",
                    "hash_type": "type",
                    "args": "0x7997689a9038a5487535cd8297d37b39840e140c849efd6f07ecc20ee9b9c244"
                },
                "script_type": "challenge_lock"
            },
            {
                "type_hash": "0xc5e5dcf215925f7ef4dfaf5f4b4f105bc321c02776d6e7d52a1db3fcd9d011a4",
                "script": {
                    "code_hash": "0x00000000000000000000000000000000000000000000000000545950455f4944",
                    "hash_type": "type",
                    "args": "0x4db75e03349f4f2ec792476035dd1b7376c683130f7e2e74024be2d9ee064511"
                },
                "script_type": "l1_sudt"
            },
            {
                "type_hash": "0xb6176a6170ea33f8468d61f934c45c57d29cdc775bcd3ecaaec183f04b9f33d9",
                "script": {
                    "code_hash": "0x00000000000000000000000000000000000000000000000000545950455f4944",
                    "hash_type": "type",
                    "args": "0xe9374fd920cd4144ce72ab7ef3405d89e5f8530d586ba986e993f1d285060a7a"
                },
                "script_type": "l2_sudt"
            },
            {
                "type_hash": "0x79f90bb5e892d80dd213439eeab551120eb417678824f282b4ffb5f21bad2e1e",
                "script": {
                    "code_hash": "0x00000000000000000000000000000000000000000000000000545950455f4944",
                    "hash_type": "type",
                    "args": "0x1b8572b16c07f46a0efed623aea6de05d45985b9a7c1b0b52276da5d9f9615b7"
                },
                "script_type": "omni_lock"
            }
        ],
        "rollup_cell": {
            "type_hash": "0x702359ea7f073558921eb50d8c1c77e92f760c8f8656bde4995f26b8963e2dd8",
            "type_script": {
                "code_hash": "0x1e44736436b406f8e48a30dfbddcf044feb0c9eebfe63b0f81cb5bb727d84854",
                "hash_type": "type",
                "args": "0x86c7429247beba7ddd6e4361bcdfc0510b0b644131e2afb7e486375249a01802"
            }
        },
        "rollup_config": {
            "required_staking_capacity": "0x3691d6afc000",
            "challenge_maturity_blocks": "0x1c2",
            "finality_blocks": "0x64",
            "reward_burn_rate": "0x32",
            "chain_id": "0x116e9"
        }
    }
}

Method gw_get_tip_block_hash

  • params: None
  • result: H256

Get hash of the tip block.

Examples

Request

{
    "id": 42,
    "jsonrpc": "2.0",
    "method": "gw_get_tip_block_hash",
    "params": []
}

Response

{
    "id": 42,
    "jsonrpc": "2.0",
    "result": "0xcbe210ac82461388300cf62197062374ef88160a2755c95fab3e1a4a686aa372"
}

Method gw_get_block_hash

  • params:
  • result: H256 | null

Get block hash by number.

Examples

Request

{
    "id": 42,
    "jsonrpc": "2.0",
    "method": "gw_get_block_hash",
    "params": ["0x2a"]
}

Response

{
    "id": 42,
    "jsonrpc": "2.0",
    "result": "0xbf55ed82cf4b33a83df679b6cba8444a3527b64735d5b5c73f6163c24af525aa"
}

Method gw_get_block

Get block.

Examples

Request

{
    "id": 42,
    "jsonrpc": "2.0",
    "method": "gw_get_block",
    "params": ["0x4ac339b063e52dac1b845d935788f379ebcdb0e33ecce077519f39929dbc8829"]
}

Response

{
    "jsonrpc": "2.0",
    "id": 42,
    "result": {
        "block": {
            "raw": {
                "number": "0x1",
                "parent_block_hash": "0x61bcff6f20e8be09bbe8e36092a9cc05dd3fa67e3841e206e8c30ae0dd7032df",
                "block_producer": "0x0200000014000000715ab282b873b79a7be8b0e8c13c4e8966a52040",
                "stake_cell_owner_lock_hash": "0xf245705db4fe72be953e4f9ee3808a1700a578341aa80a8b2349c236c4af64e5",
                "timestamp": "0x180a1e9f622",
                "prev_account": {
                    "merkle_root": "0x52baafb94a6b1c43e7361460e3bb926ca6a7ab874cec19ba71a1a5dea501c34f",
                    "count": "0x3"
                },
                "post_account": {
                    "merkle_root": "0x52baafb94a6b1c43e7361460e3bb926ca6a7ab874cec19ba71a1a5dea501c34f",
                    "count": "0x3"
                },
                "submit_transactions": {
                    "tx_witness_root": "0x0000000000000000000000000000000000000000000000000000000000000000",
                    "tx_count": "0x0",
                    "prev_state_checkpoint": "0xe4c6f7d8dc63058ed833552954f8e1635bdaa9608866dc3eaa26b148de503ba9"
                },
                "submit_withdrawals": {
                    "withdrawal_witness_root": "0x0000000000000000000000000000000000000000000000000000000000000000",
                    "withdrawal_count": "0x0"
                },
                "state_checkpoint_list": []
            },
            "kv_state": [],
            "kv_state_proof": "0x",
            "transactions": [],
            "block_proof": "0x4c5061bcff6f20e8be09bbe8e36092a9cc05dd3fa67e3841e206e8c30ae0dd7032df4fff",
            "withdrawal_requests": [],
            "hash": "0x4ac339b063e52dac1b845d935788f379ebcdb0e33ecce077519f39929dbc8829"
        },
        "status": "finalized"
    }
}

Method gw_get_block_by_number

Get block by number.

Examples

Request

{
    "id": 42,
    "jsonrpc": "2.0",
    "method": "gw_get_block_by_number",
    "params": ["0x1"]
}

Response

{
    "jsonrpc": "2.0",
    "id": 42,
    "result": {
        "raw": {
            "number": "0x1",
            "parent_block_hash": "0x61bcff6f20e8be09bbe8e36092a9cc05dd3fa67e3841e206e8c30ae0dd7032df",
            "block_producer": "0x0200000014000000715ab282b873b79a7be8b0e8c13c4e8966a52040",
            "stake_cell_owner_lock_hash": "0xf245705db4fe72be953e4f9ee3808a1700a578341aa80a8b2349c236c4af64e5",
            "timestamp": "0x180a1e9f622",
            "prev_account": {
                "merkle_root": "0x52baafb94a6b1c43e7361460e3bb926ca6a7ab874cec19ba71a1a5dea501c34f",
                "count": "0x3"
            },
            "post_account": {
                "merkle_root": "0x52baafb94a6b1c43e7361460e3bb926ca6a7ab874cec19ba71a1a5dea501c34f",
                "count": "0x3"
            },
            "submit_transactions": {
                "tx_witness_root": "0x0000000000000000000000000000000000000000000000000000000000000000",
                "tx_count": "0x0",
                "prev_state_checkpoint": "0xe4c6f7d8dc63058ed833552954f8e1635bdaa9608866dc3eaa26b148de503ba9"
            },
            "submit_withdrawals": {
                "withdrawal_witness_root": "0x0000000000000000000000000000000000000000000000000000000000000000",
                "withdrawal_count": "0x0"
            },
            "state_checkpoint_list": []
        },
        "kv_state": [],
        "kv_state_proof": "0x",
        "transactions": [],
        "block_proof": "0x4c5061bcff6f20e8be09bbe8e36092a9cc05dd3fa67e3841e206e8c30ae0dd7032df4fff",
        "withdrawal_requests": [],
        "hash": "0x4ac339b063e52dac1b845d935788f379ebcdb0e33ecce077519f39929dbc8829"
    }
}

Method gw_get_block_committed_info

Get block layer1 committed info.

Examples

Request

{
    "id": 42,
    "jsonrpc": "2.0",
    "method": "gw_get_block_committed_info",
    "params": ["0xbf55ed82cf4b33a83df679b6cba8444a3527b64735d5b5c73f6163c24af525aa"]
}

Response

{
    "id": 42,
    "jsonrpc": "2.0",
    "result": {
        "block_hash": "0x1f2a9c3aac8170d4ed82403298d4544955e3ce01dd8ee8e2ce591a1c67fe1b25",
        "number": "0xd2",
        "transaction_hash": "0x94ae05e36c0b6be0ee26a276dfc32f0cd3a0b1ab4da47812de369ef05562020d"
    }
}

Method gw_get_balance

Get balance.

Examples

Request

{
    "id": 42,
    "jsonrpc": "2.0",
    "method": "gw_get_balance",
    "params": ["0x0200000014000000bb1d13450cfa630728d0390c99957c6948bf7d19", "0x1"]
}

Response

{
    "id": 42,
    "jsonrpc": "2.0",
    "result": "0x9502f9000"
}

Method gw_get_storage_at

  • params:
    • account_id: Uint32 - Account ID
    • key: H256 - Storage key
    • block_number(optional): Uint64 - block number, default is tip
  • result: H256

Get storage at.

Examples

Request

{
    "id": 42,
    "jsonrpc": "2.0",
    "method": "gw_get_storage_at",
    "params": ["0x1", "0x0000000000000000000000000000000000000000000000000000000000000000"]
}

Response

{
    "id": 42,
    "jsonrpc": "2.0",
    "result": "0x0000000000000000000000000000000000000000000000000000000000000000"
}

Method gw_get_account_id_by_script_hash

  • params:
    • script_hash: H256 - Script Hash
  • result: Uint32 | null

Get account ID by script hash.

Examples

Request

{
    "id": 42,
    "jsonrpc": "2.0",
    "method": "gw_get_account_id_by_script_hash",
    "params": ["0xdfb94d6794165b96668b4308607afc05790dc2110867d3370ceb8a412902e7b4"]
}

Response

{
    "id": 42,
    "jsonrpc": "2.0",
    "result": "0x2"
}

Method gw_get_nonce

  • params:
    • account_id: H256 - Account ID
    • block_number(optional): Uint64 - block number, default is tip
  • result: Uint32 | null

Get account nonce.

Examples

Request

{
    "id": 42,
    "jsonrpc": "2.0",
    "method": "gw_get_nonce",
    "params": ["0x2"]
}

Response

{
    "id": 42,
    "jsonrpc": "2.0",
    "result": "0x1"
}

Method gw_get_script

  • params:
    • script_hash: H256 - Script Hash
  • result: Script | null

Get script by script hash.

Examples

Request

{
    "id": 42,
    "jsonrpc": "2.0",
    "method": "gw_get_script",
    "params": ["0xdfb94d6794165b96668b4308607afc05790dc2110867d3370ceb8a412902e7b4"]
}

Response

{
    "id": 42,
    "jsonrpc": "2.0",
    "result": {
        "args": "0x828b8a63f97e539ddc79e42fa62dac858c7a9da222d61fc80f0d61b44b5af5d46daf63d8411d6e23552658e3cfb48416a6a2ca78",
        "code_hash": "0xf96d799a3c90ac8e153ddadd1747c6067d119a594f7f1c4b1fffe9db0f304335",
        "hash_type": "type"
    }
}

Method gw_get_script_hash

  • params:
    • account_id: Uint32 - Account ID
  • result: H256

Get script hash.

Examples

Request

{
    "id": 42,
    "jsonrpc": "2.0",
    "method": "gw_get_script_hash",
    "params": ["0x2"]
}

Response

{
    "id": 42,
    "jsonrpc": "2.0",
    "result": "0xdfb94d6794165b96668b4308607afc05790dc2110867d3370ceb8a412902e7b4"
}

Method gw_get_script_hash_by_registry_address

Get script hash by registry address.

Examples

Request

{
    "id": 42,
    "jsonrpc": "2.0",
    "method": "gw_get_script_hash_by_registry_address",
    "params": ["0x0200000014000000bb1d13450cfa630728d0390c99957c6948bf7d19"]
}

Response

{
    "id": 42,
    "jsonrpc": "2.0",
    "result": "0xdfb94d6794165b96668b4308607afc05790dc2110867d3370ceb8a412902e7b4"
}

Method gw_get_registry_address_by_script_hash

  • params:
    • script_hash: H256 - Script hash
    • registry_id: Uint32 - Registry ID (The builtin ID is 2 for Ethereum registry)
  • result: RegistryAddress | null

Get registry address by script hash.

Examples

Request

{
    "id": 42,
    "jsonrpc": "2.0",
    "method": "gw_get_registry_address_by_script_hash",
    "params": ["0x0003dfb94d6794165b96668b4308607afc05790dc211", "0x2"]
}

Response

{
    "id": 42,
    "jsonrpc": "2.0",
    "result": "0x0200000014000000bb1d13450cfa630728d0390c99957c6948bf7d19"
}

Method gw_get_data

  • params:
    • data_hash: H256 - Data Hash
    • block_number(optional): Uint64 - block number, default is tip
  • result: JsonBytes | null

Get Data.

Examples

Request

{
    "id": 42,
    "jsonrpc": "2.0",
    "method": "gw_get_data",
    "params": ["0x0000000000000000000000000000000000000000000000000000000000000000"]
}

Response

{
    "id": 42,
    "jsonrpc": "2.0",
    "result": null
}

Method gw_get_transaction

  • params:
    • tx_hash: H256 - Transaction Hash
    • verbose(optional): Uint8 - 0: Verbose; 1: Only Status. default is 0
  • result: L2TransactionWithStatus | null

Get transaction.

Examples

Request

{
    "id": 42,
    "jsonrpc": "2.0",
    "method": "gw_get_transaction",
    "params": ["0x57c521ce4282fcf075862089d1bef4096723395ace63b4c0b8b9af5fa"]
}

Response

{
    "id": 42,
    "jsonrpc": "2.0",
    "result": {
        "status": "pending",
        "transaction": {
            "hash": "0x57c521ce4282fcf075862089d1bef4096723395ace63b4c0b8b9af5faf924c55",
            "raw": {
                "args": "0xffffff504f4c590040420f0000000000000000000000000000000000000000000000000000000000000000000000000024000000fca3b5aa0000000000000000000000004ec86a4bd8b06d54d3e2ad96b20a374335e5b8f5",
                "from_id": "0x4",
                "nonce": "0x2f",
                "to_id": "0x18"
            },
            "signature": "0x30a37aabf68715f99ca88b21e49ca0f83ed329613e2e439c57cc2df2e65f836c3b1ed5b891cf39cae4ff6e0f0fc9660f96eec9b3ecf7a1df1f9cf0644c00efff01"
        }
    }
}

Method gw_get_transaction_receipt

Get transaction receipt.

Examples

Request

{
    "id": 42,
    "jsonrpc": "2.0",
    "method": "gw_get_transaction_receipt",
    "params": ["0x57c521ce4282fcf075862089d1bef4096723395ace63b4c0b8b9af5fa"]
}

Response

{
    "id": 42,
    "jsonrpc": "2.0",
    "result": {
        "exit_code": "0x0",
        "logs": [
            {
                "account_id": "0x1",
                "data": "0x14afc22cc46a66350eb9375e968b66bc544189e15dff6b6da3ce1f35bce453ae384bfc8b5532e6429700000000000000000000000000000000",
                "service_flag": "0x0"
            },
            {
                "account_id": "0x18",
                "data": "0x64570000000000006457000000000000000000000000000000000000000000000000000000000000",
                "service_flag": "0x2"
            },
            {
                "account_id": "0x1",
                "data": "0x14afc22cc46a66350eb9375e968b66bc544189e15d0cc94282bd0c6baed74078c0c7ab7943cbf71f7e00000000000000000000000000000000",
                "service_flag": "0x1"
            }
        ],
        "post_state": {
            "count": "0x1b",
            "merkle_root": "0x693321c3d1047557dc8d7082c33ec717df55546e30b6d9c1c98aadef31f653fa"
        },
        "read_data_hashes": [
            "0x04a263649046d6127a5c823deb75e1a6d52fc45ce7beef6de7ebbe6ee5ee2c56"
        ],
        "tx_witness_hash": "0xce2c35e321081fbe0c266048a920008033d2ac849c0427dd0db0e057e0c4471c"
    }
}

Method gw_get_withdrawal

  • params:
    • withdrawal_hash: H256 - Withdrawal Hash
    • verbose(optional): Uint8 - 0: Verbose; 1: Only Status. default is 0
  • result: WithdrawalWithStatus | null

Get withdrawal info.

Examples

Request

{
    "id": 42,
    "jsonrpc": "2.0",
    "method": "gw_get_withdrawal",
    "params": ["0x73ebba534729fb5e3bae139903494cd05b3e3d75e437eab3e6ee4fc646fb6e6c"]
}

Response

{
   "id" : 2,
   "jsonrpc" : "2.0",
   "result" : {
      "l1_committed_info" : {
         "block_hash" : "0x35b938ef94ca3f347fffed86d1958a975919a1804277278ea622b298ac953fd2",
         "number" : "0x3921",
         "transaction_hash" : "0xc8db73e3bc609ee0019e65c2ea646f6a2a9cefcae6d8f4716c2c61cf0f81d0f3"
      },
      "l2_committed_info" : {
         "block_hash" : "0x4a7fc82fe76ec036500a20c07152d78caf429633b96ae553c84e05875373f21a",
         "block_number" : "0x101d",
         "withdrawal_index" : "0x0"
      },
      "status" : "committed",
      "withdrawal" : {
         "owner_lock" : {
            "args" : "0xa1db2eef3f29f3ef6f86c8d2a0772c705c449f4a",
            "code_hash" : "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8",
            "hash_type" : "type"
         },
         "request" : {
            "raw" : {
               "account_script_hash" : "0x04250fe2cb3cfe5d9a9f353b0a5b2f5a5bbd92b8c828563f7e45f7fa41ee6254",
               "amount" : "0x0",
               "capacity" : "0x746a528800",
               "chain_id" : "0x116e8",
               "fee" : "0x3e8",
               "nonce" : "0x0",
               "owner_lock_hash" : "0x90f95b4a388b6c1a4a220917def9438265f02460bdea1b17d2314163f14b9f39",
               "registry_id" : "0x2",
               "sudt_script_hash" : "0x0000000000000000000000000000000000000000000000000000000000000000"
            },
            "signature" : "0x3623f0dc43cc35064df1c3b37bc4c6c8af3f64d9f6d86f60f5a8dc028055c22a20f36cd3137dc1de16ba78779d39a0583e645161a0426dcc2aa92c8c176335161b"
         }
      }
   }
}

Method gw_is_request_in_queue

  • params:
    • hash: H256 - Transaction/Withdrawal Hash
  • result: [bool]

Returns whether the request (transaction or withdrawal) is in the fee queue.

Requests go through the fee queue before they are pushed to the mem pool.

Only supported on full nodes.

Examples

Request

{
  "id": 42,
  "jsonrpc": "2.0",
  "method": "gw_is_request_in_queue",
  "params": ["0x57c521ce4282fcf075862089d1bef4096723395ace63b4c0b8b9af5fa"]
}

Response

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

Method gw_execute_l2transaction

Execute layer2 transaction.

Examples

Request

{
    "id": 42,
    "jsonrpc": "2.0",
    "method": "gw_execute_l2transaction",
    "params": ["0x84010000100000006c010000800100005c01000014000000180000001c0000002000000002000000a30000001a00000038010000ffffff504f4c590020bcbe0000000000000000000000000000000000000000000000000000000000000000000000000004010000252dba420000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000008be87ac9376c33c64583d0cd512227151fed5bfe000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000244d2301cc000000000000000000000000333c37400c7a519205554c2e9c3d4f2d750a42f800000000000000000000000000000000000000000000000000000000140000000c00000010000000000000000400000000000000"]
}

Response

{
    "id": 42,
    "jsonrpc": "2.0",
    "result": {
        "logs": [
            {
                "account_id": "0x1",
                "data": "0x1468f5cea51fa6fcfdcc10f6cddcafa13bf67174368be87ac9376c33c64583d0cd512227151fed5bfe00000000000000000000000000000000",
                "service_flag": "0x0"
            },
            {
                "account_id": "0x1",
                "data": "0x148be87ac9376c33c64583d0cd512227151fed5bfe8be87ac9376c33c64583d0cd512227151fed5bfe00000000000000000000000000000000",
                "service_flag": "0x0"
            },
            {
                "account_id": "0xa3",
                "data": "0xb312000000000000b312000000000000000000000000000000000000000000000000000000000000",
                "service_flag": "0x2"
            },
            {
                "account_id": "0x1",
                "data": "0x1468f5cea51fa6fcfdcc10f6cddcafa13bf671743668f5cea51fa6fcfdcc10f6cddcafa13bf671743600000000000000000000000000000000",
                "service_flag": "0x1"
            }
        ],
        "return_data": "0x00000000000000000000000000000000000000000000000000000000000320200000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000531edbb201"
    }
}

Method gw_execute_raw_l2transaction

Execute layer2 transaction without signature.

Examples

Request

{
    "id": 42,
    "jsonrpc": "2.0",
    "method": "gw_execute_raw_l2transaction",
    "params": ["0x84010000100000006c010000800100005c01000014000000180000001c0000002000000002000000a30000001a00000038010000ffffff504f4c590020bcbe0000000000000000000000000000000000000000000000000000000000000000000000000004010000252dba420000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000008be87ac9376c33c64583d0cd512227151fed5bfe000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000244d2301cc000000000000000000000000333c37400c7a519205554c2e9c3d4f2d750a42f800000000000000000000000000000000000000000000000000000000140000000c00000010000000000000000400000000000000"]
}

Response

{
    "id": 42,
    "jsonrpc": "2.0",
    "result": {
        "logs": [
            {
                "account_id": "0x1",
                "data": "0x1468f5cea51fa6fcfdcc10f6cddcafa13bf67174368be87ac9376c33c64583d0cd512227151fed5bfe00000000000000000000000000000000",
                "service_flag": "0x0"
            },
            {
                "account_id": "0x1",
                "data": "0x148be87ac9376c33c64583d0cd512227151fed5bfe8be87ac9376c33c64583d0cd512227151fed5bfe00000000000000000000000000000000",
                "service_flag": "0x0"
            },
            {
                "account_id": "0xa3",
                "data": "0xb312000000000000b312000000000000000000000000000000000000000000000000000000000000",
                "service_flag": "0x2"
            },
            {
                "account_id": "0x1",
                "data": "0x1468f5cea51fa6fcfdcc10f6cddcafa13bf671743668f5cea51fa6fcfdcc10f6cddcafa13bf671743600000000000000000000000000000000",
                "service_flag": "0x1"
            }
        ],
        "return_data": "0x00000000000000000000000000000000000000000000000000000000000320200000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000531edbb201"
    }
}

Method gw_compute_l2_sudt_script_hash

  • params:
    • l1_sudt_script_hash: H256 - Layer1 Simple UDT type hash
  • result: H256

Compute layer2 Simple UDT script hash

Examples

Request

{
    "id": 42,
    "jsonrpc": "2.0",
    "method": "gw_compute_l2_sudt_script_hash",
    "params": ["0x0000000000000000000000000000000000000000000000000000000000000000"]
}

Response

{
    "id": 42,
    "jsonrpc": "2.0",
    "result": "0x99d75f9b654762fb822fb36dcb89de0cd385f0d1deff8f8d3430b7b93aca0597"
}

Method gw_get_fee_config

Get fee config

Examples

Request

{
    "id": 42,
    "jsonrpc": "2.0",
    "method": "gw_get_fee_config",
    "params": []
}

Response

{
    "id": 42,
    "jsonrpc": "2.0",
    "result": {
        "meta_cycles_limit": "0x4e20",
        "sudt_cycles_limit": "0x4e20",
        "withdraw_cycles_limit": "0x4e20"
    }
}

Method gw_submit_l2transaction

Submit layer2 transaction. This RPC may has rate limit.

When the from_id of a Polyjuice transaction is 0, this RPC returns null because the transaction from_id will be updated before packing. To query the status of a pending transaction with from_id = 0, please use the hash of the transaction signature as parameter.

Examples

Request

{
    "id": 42,
    "jsonrpc": "2.0",
    "method": "gw_submit_l2transaction",
    "params": ["0xb5010000100000009d010000b10100008d0100000c000000480100003c01000014000000180000001c000000200000003100000084000000d602000018010000ffffff504f4c590020bcbe00000000000000000000000000000000000000000000e1f505000000000000000000000000e40000007ff36ab5000000000000000000000000000000000000000000000000115f08c6acba85c20000000000000000000000000000000000000000000000000000000000000080000000000000000000000000333c37400c7a519205554c2e9c3d4f2d750a42f80000000000000000000000000000000000000000000000000000000061b967dc00000000000000000000000000000000000000000000000000000000000000020000000000000000000000007417e92923952a3d65bffab3f34d2bd77497c890000000000000000000000000c5e133e6b01b2c335055576c51a53647b1b9b6244100000097616f7d50457b01bdf55e48d967f3a458274affedb4b071e4f5c6ea34a8d2283c71683bd51ce8d678dd36be2c13cc6b48753d923ddc10d6c4c53d3947395ddf00140000000c00000010000000000000000400000000000000"]
}

Response

{
    "id": 42,
    "jsonrpc": "2.0",
    "result": "0xf3ccf2bd7b22885dbdcd837d4a0aad30c70a84319016644f0d94e2f4135f1ade"
}

Method gw_submit_withdrawal_request

Submit layer2 withdrawal request

Examples

Request

{
    "id": 42,
    "jsonrpc": "2.0",
    "method": "gw_submit_withdrawal_request",
    "params": ["0x190100000c000000d4000000d5020000003bc09109000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000333c37400c7a519205554c2e9c3d4f2d750a42f81661dfc4da4ce3e20a6bd23c0000000000000000000000000000000000000000000000009cb93d3362f5d511eb5baa98c9d5da8ada50161798c8800dde4b15b6531595f900000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000410000000193740968815ce5a89a1c3a781ce44e0e16bf031d79c66056f56f3621dba5b0103d51bdf471f038feadf9e55fe00d09dd64aa02642b7327ab680d7d9f04f89e01"]
}

Response

{
    "id": 42,
    "jsonrpc": "2.0",
    "result": "0xb57c6da2f803413b5781f8c6508320a0ada61a2992bb59ab38f16da2d02099c1"
}

Method gw_get_last_submitted_info

Get node last submitted info.

Examples

Request

{
    "id": 42,
    "jsonrpc": "2.0",
    "method": "gw_get_last_submitted_info",
    "params": []
}

Response

 {
    "id": 42,
    "jsonrpc": "2.0",
    "result": {
        "transaction_hash": "0x1536b5af1e42707e0278cf16dd086ec630485883ce3d1c1388f9eb4d8169b119"
    }
}

Method gw_get_mem_pool_state_root

  • params: None
  • result: H256

Get mem-pool state root.

Examples

Request

{
    "id": 42,
    "jsonrpc": "2.0",
    "method": "gw_get_mem_pool_state_root",
    "params": []
}

Response

{
    "id": 42,
    "jsonrpc": "2.0",
    "result": "0xf3349effe912609ab277e227925995070ea8f3e452854852ed7386206371f07d"
}

Method gw_get_mem_pool_state_ready

  • params: None
  • result: true | false

Get mem-pool state root.

Examples

Request

{
    "id": 42,
    "jsonrpc": "2.0",
    "method": "gw_get_mem_pool_state_ready",
    "params": []
}

Response

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

Method gw_get_pending_tx_hashes

Get pending transaction hashes.

Examples

Request

{
    "id": 42,
    "jsonrpc": "2.0",
    "method": "gw_get_pending_tx_hashes",
    "params": []
}

Response:

{
    "id": 42,
    "jsonrpc": "2.0",
    "result": [
        "0x37c705fbbe2660b6cec619fbfc7847752e0111044742a78e1b394f8da285baa3",
        "0x4126f01bfaf17ffcbb1745c6e33830e66e2490e884c9f9c2d1e14bdbc99545de",
        "0x7dcd3ddd4fbe1b6ee0129b3a9a4874dd909490da9952f0e17d2ee8d88ec49a2a",
        "0xb0d96d3d73738f0dd4a66a03fb48fe11ea4d2195d8cb138885bb3a90fd29c7be"
    ],
}

RPC Types

Type Uint32

The 32-bit unsigned integer type encoded as the 0x-prefixed hex string in JSON.

Examples

JSON Decimal Value
“0x0” 0
“0x10” 16
“10” Invalid, 0x is required
“0x01” Invalid, redundant leading 0

Type Uint64

The 64-bit unsigned integer type encoded as the 0x-prefixed hex string in JSON.

Examples

JSON Decimal Value
“0x0” 0
“0x10” 16
“10” Invalid, 0x is required
“0x01” Invalid, redundant leading 0

Type Uint128

The 128-bit unsigned integer type encoded as the 0x-prefixed hex string in JSON.

Examples

JSON Decimal Value
“0x0” 0
“0x10” 16
“10” Invalid, 0x is required
“0x01” Invalid, redundant leading 0

Type Uint256

The 256-bit unsigned integer type encoded as the 0x-prefixed hex string in JSON.

Examples

JSON Decimal Value
“0x0” 0
“0x10” 16
“10” Invalid, 0x is required
“0x01” Invalid, redundant leading 0

Type H256

The 32-byte fixed-length binary data.

The name comes from the number of bits in the data.

In JSONRPC, it is encoded as a 0x-prefixed hex string.

Fields

H256 is a JSON object with the following fields.

Type JsonBytes

Variable-length binary encoded as a 0x-prefixed hex string in JSON.

Example

JSON Binary
“0x” Empty binary
“0x00” Single byte 0
“0x636b62” 3 bytes, UTF-8 encoding of ckb
“00” Invalid, 0x is required
“0x0” Invalid, each byte requires 2 digits

Type Backend

Fields

Backend is a JSON object with the following fields.

  • validator_code_hash: H256 - Validator script's code hash

  • generator_code_hash: H256 - Generator script's code hash

  • validator_script_type_hash: H256 - Validate script's hash (script.hash_type = type)

Type NodeInfo

Fields

NodeInfo is a JSON object with the following fields.

Type EoaScript

Fields

EoaScript is a JSON object with the following fields.

  • type_hash: H256

  • script: Script

  • eoa_type: unknown | eth

Type GwScript

Fields

GwScript is a JSON object with the following fields.

  • type_hash: H256

  • script: Script

  • script_type: unknown | deposit | withdraw | state_validator | stake_lock | custodian_lock | challenge_lock | l1_sudt | l2_sudt | omni_lock

Type RollupCell

Fields

RollupCell is a JSON object with the following fields.

Type NodeRollupConfig

Fields

NodeRollupConfig is a JSON object with the following fields.

Type L2BlockWithStatus

Fields

L2BlockWithStatus is a JSON object with the following fields.

  • block: L2Block - L2 block

  • status: finalized | unfinalized | reverted - L2 block status

    • finalized: Block already finalized

    • unfinalized: Block not already finalized

    • reverted: Block has already reverted

Type L2Block

Fields

L2Block is a JSON object with the following fields.

Type KVPair

Fields

KVPair is a JSON object with the following fields.

Type RawL2Block

Fields

RawL2Block is a JSON object with the following fields.

Type AccountInfo

Fields

AccountInfo is a JSON object with the following fields.

Type AccountMerkleState

Fields

AccountMerkleState is a JSON object with the following fields.

Type SubmitWithdrawal

Fields

AccountInfo is a JSON object with the following fields.

  • withdrawal_count: Uint32

  • withdrawal_witness_root: H256

Type L2TransactionWithStatus

Fields

L2TransactionWithStatus is a JSON object with the following fields.

Type L2Transaction

Fields

L2Transaction is a JSON object with the following fields.

Type RawL2Transaction

Fields

RawL2Transaction is a JSON object with the following fields.

Type L2TransactionReceipt

Fields

L2TransactionReceipt is a JSON object with the following fields.

Type LogItem

Fields

LogItem is a JSON object with the following fields.

Type RunResult

Fields

RunResult is a JSON object with the following fields.

Type FeeConfig

Fields

FeeConfig is a JSON object with the following fields.

Type WithdrawalWithStatus

Fields

WithdrawalWithStatus is a JSON object with the following fields.

Type WithdrawalRequestExtra

Fields

WithdrawalRequestExtra is a JSON object with the following fields.

Type WithdrawalRequest

Fields

WithdrawalRequest is a JSON object with the following fields.

Type RawWithdrawalRequest

Fields

RawWithdrawalRequest is a JSON object with the following fields.

Type L2WithdrawalCommittedInfo

Fields

L2WithdrawalCommittedInfo is a JSON object with the following fields, represents the layer2 withdrawal committed information.

Type L2BlockCommittedInfo

Fields

L2BlockCommittedInfo is a JSON object with the following fields.

Type LastL2BlockCommittedInfo

Fields

LastL2BlockCommittedInfo is a JSON object with the following fields.

  • transaction_hash: H256

Type RegistryAddress

Fields

RegistryAddress is a JSON object with the following fields.

Type SerializedRegistryAddress

It's a 0x-prefix hex string in JSON.

Examples

registry_address = 0x0200000014000000bb1d13450cfa630728d0390c99957c6948bf7d19

Fields

registry_address = 0x | registry_account id | address_size | address
  • registry_account_id:

    • 4-byte, Uint32 in little endian format.
    • In example, it's 02000000, means id is 2.
    • The builtin ID is 2 for Ethereum registry.
  • address_size:

    • Byte length of address, 4-byte, Uint32 in little endian format.
    • In example, byte length is 14000000, means address length is 20-byte.
  • address: JsonBytes

    • Addess such as Eth Address.
    • In example, address is bb1d13450cfa630728d0390c99957c6948bf7d19

Type SerializedMoleculeSchema

It's a 0x-prefix hex string in JSON. Serialized by Molecule.

See schema files for more info.

  • SerializedL2Transaction: schema
  • SerializedRawL2Transaction: schema
  • SerializedWithdrawRequest: schema

Type Script

More info CKB RPC

Type ScriptHashType

More info CKB RPC