diff --git a/docs/references/json-rpc/admin/README.md b/docs/references/json-rpc/admin/README.md new file mode 100644 index 00000000000..6f4f0e97d76 --- /dev/null +++ b/docs/references/json-rpc/admin/README.md @@ -0,0 +1,9 @@ +This RPC API docs will be automatically generated in the Klaytn-docs official site. +Please follow the steps below if you also want to build the RPC API documentation +```shell +> git clone -b dev https://github.com/klaytn/web3klaytn.git + +> cd ./web3klaytn/documentation && RPC_SPEC_DIR=../../web3rpc/yaml ./generate-docs.sh split + +> cd ../../web3rpc && ./web3rpc.sh +``` \ No newline at end of file diff --git a/docs/references/json-rpc/admin/sidebar.ts b/docs/references/json-rpc/admin/sidebar.ts new file mode 100644 index 00000000000..7d8693b3472 --- /dev/null +++ b/docs/references/json-rpc/admin/sidebar.ts @@ -0,0 +1,16 @@ +import type { SidebarsConfig } from "@docusaurus/plugin-content-docs"; + +const sidebar: SidebarsConfig = { + apisidebar: [ + { + type: "doc", + id: "references/json-rpc/admin/web-3-rpc", + }, + { + type: "doc", + id: "references/json-rpc/admin/README", + }, + ], +}; + +export default sidebar.apisidebar; diff --git a/docs/references/json-rpc/debug/sidebar.ts b/docs/references/json-rpc/debug/sidebar.ts new file mode 100644 index 00000000000..50bf81b96af --- /dev/null +++ b/docs/references/json-rpc/debug/sidebar.ts @@ -0,0 +1,12 @@ +import type { SidebarsConfig } from "@docusaurus/plugin-content-docs"; + +const sidebar: SidebarsConfig = { + apisidebar: [ + { + type: "doc", + id: "references/json-rpc/debug/web-3-rpc", + }, + ], +}; + +export default sidebar.apisidebar; \ No newline at end of file diff --git a/docs/references/json-rpc/debug/tracing.md b/docs/references/json-rpc/debug/tracing.md deleted file mode 100644 index 2b8d1206806..00000000000 --- a/docs/references/json-rpc/debug/tracing.md +++ /dev/null @@ -1,633 +0,0 @@ -# VM Tracing - -**NOTE** The [JavaScript-based Tracing](#javascript-based-tracing) of VM Tracing APIs is considered unsafe to be opened to public. -If you want to provide VM Tracing APIs to the public, we strongly recommend you to set the -`rpc.unsafe-debug.disable` flag which will disable the [Javascript-based Tracing](#javascript-based-tracing) -and only allow [pre-defined tracers](#tracing-options). - -## debug_traceBadBlock - -The `traceBadBlock` method will return a full stack trace of all invoked -opcodes of all transactions that were included in this block. - -**NOTE**: the parent of this block must be present or it will fail. - -| Client | Method Invocation | -|:-------:|-----------------------------------------------------------| -| Console | `debug.traceBadBlock(hash, [options])` | -| RPC | `{"method": "debug_traceBadBlock", "params": [hash, {}]}` | - -**Parameters** - -| Name | Type | Description | -| --- | --- | --- | -| hash | 32-byte DATA | Hash of a block. | -| options | object | See [tracing options](#tracing-options). | - -**Return Value** - -| Type | Description | -| --- | --- | -| JSON string | The structured logs created during the execution of KLVM. | - -**Example** - -Console -```javascript -> debug.traceBadBlock("0x1d5ba00e313a81ae6d409d459c153327072665d9ea2f47608369722baf0cfbb6") -[{ - result: { - failed: false, - gas: 67100, - returnValue: "", - structLogs: [] - } -}, { - result: { - failed: false, - gas: 195179, - returnValue: "", - structLogs: [{...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}] - } -}] -``` - -HTTP RPC -```shell -$ curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"debug_traceBadBlock","params":["0x1d5ba00e313a81ae6d409d459c153327072665d9ea2f47608369722baf0cfbb6"],"id":1}' https://public-en-baobab.klaytn.net -{"jsonrpc":"2.0","id":1,"result":[{"result":{"gas":67100,"failed":false,"returnValue":"","structLogs":[]}},{"result":{"gas":195179,"failed":false,"returnValue":"","structLogs":[{"pc":0,"op":"PUSH1","gas":9975680,"gasCost":3,"depth":1,"stack":[],"memory":[],"storage":{}},{"pc":2,"op":"PUSH1","gas":9975677,"gasCost":3,"depth":1,"stack":["0000000000000000000000000000000000000000000000000000000000000080"],"memory":[],"storage":{}},{"pc":4,"op":"MSTORE","gas":9975674,"gasCost":12,"depth":1,"stack":["0000000000000000000000000000000000000000000000000000000000000080","0000000000000000000000000000000000000000000000000000000000000040"],"memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000"],"storage":{}},{"pc":5,"op":"PUSH1","gas":9975662,"gasCost":3,"depth":1,"stack":[],"memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000080"],"storage":{}},{"pc":7,"op":"CALLDATASIZE","gas":9975659,"gasCost":2,"depth":1,"stack":["0000000000000000000000000000000000000000000000000000000000000004"],"memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000080"],"storage":{}}, -... -,{"pc":853,"op":"STOP","gas":9804821,"gasCost":0,"depth":1,"stack":["000000000000000000000000000000000000000000000000000000007818097c"],"memory":["0000000000000000000000000000000000000000000000000000000000000002","0000000000000000000000000000000000000000000000000000000000000005","00000000000000000000000000000000000000000000000000000000000001c0","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000006","000000000000000000000000500a2e58ae232c5e91bcdcf82c5d6d2165572599","00000000000000000000000000000000000000000000021e19e0c9bab2400000","0000000000000000000000000000000000000000000000000000000000000000","00000000000000000000000081d390a4e469b45642341d6ad111062c24984b37","0000000000000000000000000000000000000000000000000000000000000160","0000000000000000000000000000000000000000000000000000000000000001","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000001","00000000000000000000000081d390a4e469b45642341d6ad111062c24984b37","0000000000000000000000000000000000000000000000000000000000000006","000000000000000000000000500a2e58ae232c5e91bcdcf82c5d6d2165572599","00000000000000000000000000000000000000000000021e19e0c9bab2400000","0000000000000000000000000000000000000000000000000000000000000000","00000000000000000000000000000000000000000000000000000000000000a0","0000000000000000000000000000000000000000000000000000000000000001","00000000000000000000000081d390a4e469b45642341d6ad111062c24984b37"],"storage":{"0000000000000000000000000000000000000000000000000000000000000004":"0000000000000000000000000000000000000000000000000000000000000003","5997abbe896cd022932fc8703dbed777f0bf0d6ed28b2444cb4b79da2805e9a5":"00000000000000000000000081d390a4e469b45642341d6ad111062c24984b37","89832631fb3c3307a103ba2c84ab569c64d6182a18893dcd163f0f1c2090733a":"0000000000000000000000000000000000000000000000000000000000000006","89832631fb3c3307a103ba2c84ab569c64d6182a18893dcd163f0f1c2090733b":"000000000000000000000000500a2e58ae232c5e91bcdcf82c5d6d2165572599","89832631fb3c3307a103ba2c84ab569c64d6182a18893dcd163f0f1c2090733c":"00000000000000000000000000000000000000000000021e19e0c9bab2400000","89832631fb3c3307a103ba2c84ab569c64d6182a18893dcd163f0f1c2090733d":"0000000000000000000000000000000000000000000000000000000000000000","89832631fb3c3307a103ba2c84ab569c64d6182a18893dcd163f0f1c2090733e":"00000000000000000000000081d390a4e469b45642341d6ad111062c24984b37","89832631fb3c3307a103ba2c84ab569c64d6182a18893dcd163f0f1c2090733f":"0000000000000000000000000000000000000000000000000000000000000001","89832631fb3c3307a103ba2c84ab569c64d6182a18893dcd163f0f1c20907340":"0000000000000000000000000000000000000000000000000000000000000001"}}]}}]} -``` - - -## debug_traceBlock - -The `traceBlock` method will return a full stack trace of all invoked opcodes -of all transactions that were included in this block. - -**NOTE**: the parent of this block must be present or it will fail. - -| Client | Method Invocation | -|:-------:|-------------------------------------------------------------| -| Console | `debug.traceBlock(blockRlp, [options])` | -| RPC | `{"method": "debug_traceBlock", "params": [blockRlp, {}]}` | - -References: [RLP](https://github.com/ethereum/wiki/wiki/RLP) - -**Parameters** - -| Name | Type | Description | -| --- | --- | --- | -| blockRlp | string | The RLP-encoded block. | -| options | object | See [tracing options](#tracing-options). | - -**Return Value** - -| Type | Description | -| --- | --- | -| JSON string | The structured logs created during the execution of KLVM. | - -**Example** - -Console -```javascript -> debug.traceBlock("0xblock_rlp") -[{ - result: { - failed: false, - gas: 247922, - returnValue: "60806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806341c0e1b514610051578063cfae321714610068575b600080fd5b34801561005d57600080fd5b506100666100f8565b005b34801561007457600080fd5b5061007d610168565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100bd5780820151818401526020810190506100a2565b50505050905090810190601f1680156100ea5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610166573373ffffffffffffffffffffffffffffffffffffffff16ff5b565b606060018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156102005780601f106101d557610100808354040283529160200191610200565b820191906000526020600020905b8154815290600101906020018083116101e357829003601f168201915b50505050509050905600a165627a7a72305820f4e74ca2266a24aabd6a8ee6c4e54ad49014e2faa152e49e7f9d927c932c72870029", - structLogs: [{...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}] - } -}] -``` -HTTP RPC -```shell -$ curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"debug_traceBlock","params":["0xblock_rlp"],"id":1}' https://public-en-baobab.klaytn.net -{"jsonrpc":"2.0","id":1,"result":[{"result":{"gas":247922,"failed":false,"returnValue":"60806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806341c0e1b514610051578063cfae321714610068575b600080fd5b34801561005d57600080fd5b506100666100f8565b005b34801561007457600080fd5b5061007d610168565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100bd5780820151818401526020810190506100a2565b50505050905090810190601f1680156100ea5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610166573373ffffffffffffffffffffffffffffffffffffffff16ff5b565b606060018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156102005780601f106101d557610100808354040283529160200191610200565b820191906000526020600020905b8154815290600101906020018083116101e357829003601f168201915b50505050509050905600a165627a7a72305820f4e74ca2266a24aabd6a8ee6c4e54ad49014e2faa152e49e7f9d927c932c72870029","structLogs":[{"pc":0,"op":"PUSH1","gas":891344,"gasCost":3,"depth":1,"stack":[],"memory":[],"storage":{}},{"pc":2,"op":"PUSH1","gas":891341,"gasCost":3,"depth":1,"stack":["0000000000000000000000000000000000000000000000000000000000000080"],"memory":[],"storage":{}},{"pc":4,"op":"MSTORE","gas":891338,"gasCost":12,"depth":1,"stack":["0000000000000000000000000000000000000000000000000000000000000080","0000000000000000000000000000000000000000000000000000000000000040"],"memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000"],"storage":{}},{"pc":5,"op":"CALLVALUE","gas":891326,"gasCost":2,"depth":1,"stack":[],"memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000080"],"storage":{}}, -... -,{"pc":322,"op":"RETURN","gas":865278,"gasCost":0,"depth":1,"stack":["0000000000000000000000000000000000000000000000000000000000000236","0000000000000000000000000000000000000000000000000000000000000000"],"memory":["60806040526004361061004c576000357c010000000000000000000000000000","0000000000000000000000000000900463ffffffff16806341c0e1b514610051","578063cfae321714610068575b600080fd5b34801561005d57600080fd5b5061","00666100f8565b005b34801561007457600080fd5b5061007d610168565b6040","5180806020018281038252838181518152602001915080519060200190808383","60005b838110156100bd5780820151818401526020810190506100a2565b5050","5050905090810190601f1680156100ea5780820380516001836020036101000a","031916815260200191505b509250505060405180910390f35b60008090549061","01000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffff","ffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffff","ffffffffffffff161415610166573373ffffffffffffffffffffffffffffffff","ffffffff16ff5b565b6060600180546001816001161561010002031660029004","80601f0160208091040260200160405190810160405280929190818152602001","828054600181600116156101000203166002900480156102005780601f106101","d557610100808354040283529160200191610200565b82019190600052602060","0020905b8154815290600101906020018083116101e357829003601f16820191","5b50505050509050905600a165627a7a72305820f4e74ca2266a24aabd6a8ee6","c4e54ad49014e2faa152e49e7f9d927c932c7287002900000000000000000000"],"storage":{"0000000000000000000000000000000000000000000000000000000000000000":"000000000000000000000000b0945862f63b832849a5f20b19e9f8188eb2230a","0000000000000000000000000000000000000000000000000000000000000001":"0000000000000000000000000000000000000000000000000000000000000000"}}]}}]} -``` - - -## debug_traceBlockByHash -Similar to [debug_traceBlock](#debug_traceblock), `traceBlockByHash` accepts a -block hash and will replay the block that is already present in the database. - -| Client | Method Invocation | -|:-------:|--------------------------------------------------------------| -| Console | `debug.traceBlockByHash(hash, [options])` | -| RPC | `{"method": "debug_traceBlockByHash", "params": [hash, {}]}` | - -**Parameters** - -| Name | Type | Description | -| --- | --- | --- | -| hash | 32-byte DATA | Hash of a block. | -| options | object | See [tracing options](#tracing-options). | - -**Return Value** - -| Type | Description | -| --- | --- | -| JSON string | The structured logs created during the execution of KLVM. | - -**Example** - -Console -```javascript -> debug.traceBlockByHash("0x244acf3f11f0999b93616cb156dc1b43ee87e27c9625a7170cf6de447189d890") -[{ - result: { - failed: false, - gas: 247922, - returnValue: "60806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806341c0e1b514610051578063cfae321714610068575b600080fd5b34801561005d57600080fd5b506100666100f8565b005b34801561007457600080fd5b5061007d610168565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100bd5780820151818401526020810190506100a2565b50505050905090810190601f1680156100ea5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610166573373ffffffffffffffffffffffffffffffffffffffff16ff5b565b606060018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156102005780601f106101d557610100808354040283529160200191610200565b820191906000526020600020905b8154815290600101906020018083116101e357829003601f168201915b50505050509050905600a165627a7a72305820f4e74ca2266a24aabd6a8ee6c4e54ad49014e2faa152e49e7f9d927c932c72870029", - structLogs: [{...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}] - } -}] -``` -HTTP RPC -```shell -$ curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"debug_traceBlockByHash","params":["0x244acf3f11f0999b93616cb156dc1b43ee87e27c9625a7170cf6de447189d890", {}],"id":1}' https://public-en-baobab.klaytn.net {"jsonrpc":"2.0","id":1,"result":[{"result":{"gas":247922,"failed":false,"returnValue":"60806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806341c0e1b514610051578063cfae321714610068575b600080fd5b34801561005d57600080fd5b506100666100f8565b005b34801561007457600080fd5b5061007d610168565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100bd5780820151818401526020810190506100a2565b50505050905090810190601f1680156100ea5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610166573373ffffffffffffffffffffffffffffffffffffffff16ff5b565b606060018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156102005780601f106101d557610100808354040283529160200191610200565b820191906000526020600020905b8154815290600101906020018083116101e357829003601f168201915b50505050509050905600a165627a7a72305820f4e74ca2266a24aabd6a8ee6c4e54ad49014e2faa152e49e7f9d927c932c72870029","structLogs":[{"pc":0,"op":"PUSH1","gas":891344,"gasCost":3,"depth":1,"stack":[],"memory":[],"storage":{}},{"pc":2,"op":"PUSH1","gas":891341,"gasCost":3,"depth":1,"stack":["0000000000000000000000000000000000000000000000000000000000000080"],"memory":[],"storage":{}},{"pc":4,"op":"MSTORE","gas":891338,"gasCost":12,"depth":1,"stack":["0000000000000000000000000000000000000000000000000000000000000080","0000000000000000000000000000000000000000000000000000000000000040"],"memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000"],"storage":{}},{"pc":5,"op":"CALLVALUE","gas":891326,"gasCost":2,"depth":1,"stack":[],"memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000080"],"storage":{}}, -... -,{"pc":322,"op":"RETURN","gas":865278,"gasCost":0,"depth":1,"stack":["0000000000000000000000000000000000000000000000000000000000000236","0000000000000000000000000000000000000000000000000000000000000000"],"memory":["60806040526004361061004c576000357c010000000000000000000000000000","0000000000000000000000000000900463ffffffff16806341c0e1b514610051","578063cfae321714610068575b600080fd5b34801561005d57600080fd5b5061","00666100f8565b005b34801561007457600080fd5b5061007d610168565b6040","5180806020018281038252838181518152602001915080519060200190808383","60005b838110156100bd5780820151818401526020810190506100a2565b5050","5050905090810190601f1680156100ea5780820380516001836020036101000a","031916815260200191505b509250505060405180910390f35b60008090549061","01000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffff","ffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffff","ffffffffffffff161415610166573373ffffffffffffffffffffffffffffffff","ffffffff16ff5b565b6060600180546001816001161561010002031660029004","80601f0160208091040260200160405190810160405280929190818152602001","828054600181600116156101000203166002900480156102005780601f106101","d557610100808354040283529160200191610200565b82019190600052602060","0020905b8154815290600101906020018083116101e357829003601f16820191","5b50505050509050905600a165627a7a72305820f4e74ca2266a24aabd6a8ee6","c4e54ad49014e2faa152e49e7f9d927c932c7287002900000000000000000000"],"storage":{"0000000000000000000000000000000000000000000000000000000000000000":"000000000000000000000000b0945862f63b832849a5f20b19e9f8188eb2230a","0000000000000000000000000000000000000000000000000000000000000001":"0000000000000000000000000000000000000000000000000000000000000000"}}]}}]} -``` - - -## debug_traceBlockByNumber -Similar to [debug_traceBlock](#debug_traceblock), `traceBlockByNumber` accepts -a block number and will replay the block that is already present in the -database. - -| Client | Method Invocation | -|:-------:|------------------------------------------------------------------| -| Console | `debug.traceBlockByNumber(number, [options])` | -| RPC | `{"method": "debug_traceBlockByNumber", "params": [number, {}]}` | - -**Parameters** - -| Name | Type | Description | -| --- | --- | --- | -| number | int | The block number. | -| options | object | See [tracing options](#tracing-options). | - -**Return Value** - -| Type | Description | -| --- | --- | -| JSON string | The structured logs created during the execution of KLVM. | - -**Example** - -Console -```javascript -> debug.traceBlockByNumber(1449) -[{ - result: { - failed: false, - gas: 247922, - returnValue: "60806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806341c0e1b514610051578063cfae321714610068575b600080fd5b34801561005d57600080fd5b506100666100f8565b005b34801561007457600080fd5b5061007d610168565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100bd5780820151818401526020810190506100a2565b50505050905090810190601f1680156100ea5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610166573373ffffffffffffffffffffffffffffffffffffffff16ff5b565b606060018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156102005780601f106101d557610100808354040283529160200191610200565b820191906000526020600020905b8154815290600101906020018083116101e357829003601f168201915b50505050509050905600a165627a7a72305820f4e74ca2266a24aabd6a8ee6c4e54ad49014e2faa152e49e7f9d927c932c72870029", - structLogs: [{...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}] - } -}] -``` -HTTP RPC -```shell -$ curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"debug_traceBlockByNumber","params":["0x5a9", {}],"id":1}' https://public-en-baobab.klaytn.net -{"jsonrpc":"2.0","id":1,"result":[{"result":{"gas":247922,"failed":false,"returnValue":"60806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806341c0e1b514610051578063cfae321714610068575b600080fd5b34801561005d57600080fd5b506100666100f8565b005b34801561007457600080fd5b5061007d610168565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100bd5780820151818401526020810190506100a2565b50505050905090810190601f1680156100ea5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610166573373ffffffffffffffffffffffffffffffffffffffff16ff5b565b606060018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156102005780601f106101d557610100808354040283529160200191610200565b820191906000526020600020905b8154815290600101906020018083116101e357829003601f168201915b50505050509050905600a165627a7a72305820f4e74ca2266a24aabd6a8ee6c4e54ad49014e2faa152e49e7f9d927c932c72870029","structLogs":[{"pc":0,"op":"PUSH1","gas":891344,"gasCost":3,"depth":1,"stack":[],"memory":[],"storage":{}},{"pc":2,"op":"PUSH1","gas":891341,"gasCost":3,"depth":1,"stack":["0000000000000000000000000000000000000000000000000000000000000080"],"memory":[],"storage":{}},{"pc":4,"op":"MSTORE","gas":891338,"gasCost":12,"depth":1,"stack":["0000000000000000000000000000000000000000000000000000000000000080","0000000000000000000000000000000000000000000000000000000000000040"],"memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000"],"storage":{}},{"pc":5,"op":"CALLVALUE","gas":891326,"gasCost":2,"depth":1,"stack":[],"memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000080"],"storage":{}}, -... -,{"pc":322,"op":"RETURN","gas":865278,"gasCost":0,"depth":1,"stack":["0000000000000000000000000000000000000000000000000000000000000236","0000000000000000000000000000000000000000000000000000000000000000"],"memory":["60806040526004361061004c576000357c010000000000000000000000000000","0000000000000000000000000000900463ffffffff16806341c0e1b514610051","578063cfae321714610068575b600080fd5b34801561005d57600080fd5b5061","00666100f8565b005b34801561007457600080fd5b5061007d610168565b6040","5180806020018281038252838181518152602001915080519060200190808383","60005b838110156100bd5780820151818401526020810190506100a2565b5050","5050905090810190601f1680156100ea5780820380516001836020036101000a","031916815260200191505b509250505060405180910390f35b60008090549061","01000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffff","ffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffff","ffffffffffffff161415610166573373ffffffffffffffffffffffffffffffff","ffffffff16ff5b565b6060600180546001816001161561010002031660029004","80601f0160208091040260200160405190810160405280929190818152602001","828054600181600116156101000203166002900480156102005780601f106101","d557610100808354040283529160200191610200565b82019190600052602060","0020905b8154815290600101906020018083116101e357829003601f16820191","5b50505050509050905600a165627a7a72305820f4e74ca2266a24aabd6a8ee6","c4e54ad49014e2faa152e49e7f9d927c932c7287002900000000000000000000"],"storage":{"0000000000000000000000000000000000000000000000000000000000000000":"000000000000000000000000b0945862f63b832849a5f20b19e9f8188eb2230a","0000000000000000000000000000000000000000000000000000000000000001":"0000000000000000000000000000000000000000000000000000000000000000"}}]}}]} -``` - -## debug_traceBlockByNumberRange - -Returns the structured logs created during the execution of EVM between two blocks (including start) as a JSON object. -That is, the result of tracing for a total of end-start+1 blocks is returned. - -| Client | Method Invocation | -|:-------:|------------------------------------------------------------------| -| Console | `debug.traceBlockByNumberRange(number, number, [options])` | -| RPC | `{"method": "debug_traceBlockByNumberRange", "params": [number, number, {}]}` | - -**NOTE**: Don't trace too many blocks at the same time as it can overuse machine resources. - -**Parameters** - -| Name | Type | Description | -| --- | --- | --- | -| number | int | Tracing start block number. | -| number | int | Tracing end block number. | -| options | object | See [tracing options](#tracing-options). | - -**Return Value** - -| Type | Description | -| --- | --- | -| map(key: block number. value: JSON string) | Value contains the structured logs created during the execution of KLVM. | - -**Example** - -Console -```javascript -> debug.traceBlockByNumberRange(21, 30, {}) -{ - 21: { - block: "0x15", - hash: "0x24b0a90822e63295623e6d8f5a8e5d47cead5c8d5854e44db00dc42d28e0850e", - traces: [{ - result: {...}, - txHash: "0x43ed7e441db8e90f377d74b5d61c6d7d8b85ffd277b965c9f275ce7e93fb1090" - }, { - result: {...}, - txHash: "0x1a448049b21d39cd4320ab95f18b8e91d687bfc7136268f50e041e439181fa0d" - }] - }, - 22: { - ... - }, - ... -} -``` -HTTP RPC -```shell -$ curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"debug_traceBlockByNumberRange","params":[21, 30, {}],"id":1}' http://localhost:8551 -{"jsonrpc":"2.0","id":1,"result":{"21":{"block":"0x15","hash":"0x24b0a90822e63295623e6d8f5a8e5d47cead5c8d5854e44db00dc42d28e0850e","traces":[{"txHash":"0x43ed7e441db8e90f377d74b5d61c6d7d8b85ffd277b965c9f275ce7e93fb1090","result":{"gas":21000,"failed":false,"returnValue":"","structLogs":[]}},{"txHash":"0x1a448049b21d39cd4320ab95f18b8e91d687bfc7136268f50e041e439181fa0d","result":{"gas":21000,"failed":false,"returnValue":"","structLogs":[]}}]}, -... -"result":{"gas":21000,"failed":false,"returnValue":"","structLogs":[]}}]}}} -``` - -## debug_traceBlockFromFile - -Similar to [debug_traceBlock](#debug_traceblock), `traceBlockFromFile` accepts -a file containing the RLP of the block. - -**NOTE**: the file must include the associated hexadecimal string without `0x`. - -| Client | Method Invocation | -|:-------:|--------------------------------------------------------------------| -| Console | `debug.traceBlockFromFile(fileName, [options])` | -| RPC | `{"method": "debug_traceBlockFromFile", "params": [fileName, {}]}` | - -References: [RLP](https://github.com/ethereum/wiki/wiki/RLP) - -**Parameters** - -| Name | Type | Description | -| --- | --- | --- | -| fileName | string | The file name which contains the RLP of the block. | -| options | object | See [tracing options](#tracing-options). | - -**Return Value** - -| Type | Description | -| --- | --- | -| JSON string | The structured logs created during the execution of KLVM. | - -**Example** - -The contents of the `block.rlp` file was printed on the running node as follows. -``` -$ cat block.rlp -f90399f90394a05a825207c8396b848fefc73e442db004adee6596309af27630871b6a3d424758a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000940000000000000000000000000000000000000000a0b2ff1e4173123faa241fb93d83860e09f9e1ca1cfaf24c40c9e963e65c0b0317a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000016485e8d4a50fff80845bb9e92eb90187d7820401846b6c617988676f312e31302e33856c696e75780000000000000000f90164f854943b215ed129645b949722d4efbd9c749838d85bf0947050164b7718c667c9661afd924f6c0c5e5d4a01947f303b360063efc575e99cf2f7602efa034e832e94f38624dba0e106aa6a79335f77d3fd6409f9e4d8b84126d1ae355905704d8ffcc50599a8a051ac7c50ed6fc6d7caf6510cf0329b56cf3e3babfe45cc95143074ca0385627ea3b6ac3f6ad7961b60f23e32965d3b0c2900f8c9b841c3423ecb41ee86b193dbb98bf74e0c1b8e0c475503a8f5ef37ef7566af34443c77b492a1f92e5a7411c36efeae08ebc698d02353c38f07a3d5c32168243ab7e901b841ec6558f4e5d123b9dc240e77db493f1e5e2f55f108d3c4f9b39e10dbca39ad7b3fc2dd5d27a7a3d92938ad4245bef5a914377fb2b92cbe342067a9963ab121b700b841f34ed94f29cd0aefd841cc8aba9dcc9d4c2fe14795f3a661e8ce92c2014c2099327e5f4285e1d1821e55f297cf5252bafed521ab49906b9b596a3187ce1e529c00a063746963616c2062797a616e74696e65206661756c7420746f6c6572616e6365880000000000000000c0c0 -``` - -Console -```javascript -> debug.traceBlockFromFile("block.rlp") -[{ - result: { - failed: false, - gas: 247922, - returnValue: "60806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806341c0e1b514610051578063cfae321714610068575b600080fd5b34801561005d57600080fd5b506100666100f8565b005b34801561007457600080fd5b5061007d610168565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100bd5780820151818401526020810190506100a2565b50505050905090810190601f1680156100ea5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610166573373ffffffffffffffffffffffffffffffffffffffff16ff5b565b606060018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156102005780601f106101d557610100808354040283529160200191610200565b820191906000526020600020905b8154815290600101906020018083116101e357829003601f168201915b50505050509050905600a165627a7a72305820f4e74ca2266a24aabd6a8ee6c4e54ad49014e2faa152e49e7f9d927c932c72870029", - structLogs: [{...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}] - } -}] -``` - -HTTP RPC -```shell -$ curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"debug_traceBlockFromFile","params":["block.rlp", {}],"id":1}' https://public-en-baobab.klaytn.net -{"jsonrpc":"2.0","id":1,"result":[{"result":{"gas":247922,"failed":false,"returnValue":"60806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806341c0e1b514610051578063cfae321714610068575b600080fd5b34801561005d57600080fd5b506100666100f8565b005b34801561007457600080fd5b5061007d610168565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100bd5780820151818401526020810190506100a2565b50505050905090810190601f1680156100ea5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610166573373ffffffffffffffffffffffffffffffffffffffff16ff5b565b606060018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156102005780601f106101d557610100808354040283529160200191610200565b820191906000526020600020905b8154815290600101906020018083116101e357829003601f168201915b50505050509050905600a165627a7a72305820f4e74ca2266a24aabd6a8ee6c4e54ad49014e2faa152e49e7f9d927c932c72870029","structLogs":[{"pc":0,"op":"PUSH1","gas":891344,"gasCost":3,"depth":1,"stack":[],"memory":[],"storage":{}},{"pc":2,"op":"PUSH1","gas":891341,"gasCost":3,"depth":1,"stack":["0000000000000000000000000000000000000000000000000000000000000080"],"memory":[],"storage":{}},{"pc":4,"op":"MSTORE","gas":891338,"gasCost":12,"depth":1,"stack":["0000000000000000000000000000000000000000000000000000000000000080","0000000000000000000000000000000000000000000000000000000000000040"],"memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000"],"storage":{}},{"pc":5,"op":"CALLVALUE","gas":891326,"gasCost":2,"depth":1,"stack":[],"memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000080"],"storage":{}}, -... -,{"pc":322,"op":"RETURN","gas":865278,"gasCost":0,"depth":1,"stack":["0000000000000000000000000000000000000000000000000000000000000236","0000000000000000000000000000000000000000000000000000000000000000"],"memory":["60806040526004361061004c576000357c010000000000000000000000000000","0000000000000000000000000000900463ffffffff16806341c0e1b514610051","578063cfae321714610068575b600080fd5b34801561005d57600080fd5b5061","00666100f8565b005b34801561007457600080fd5b5061007d610168565b6040","5180806020018281038252838181518152602001915080519060200190808383","60005b838110156100bd5780820151818401526020810190506100a2565b5050","5050905090810190601f1680156100ea5780820380516001836020036101000a","031916815260200191505b509250505060405180910390f35b60008090549061","01000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffff","ffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffff","ffffffffffffff161415610166573373ffffffffffffffffffffffffffffffff","ffffffff16ff5b565b6060600180546001816001161561010002031660029004","80601f0160208091040260200160405190810160405280929190818152602001","828054600181600116156101000203166002900480156102005780601f106101","d557610100808354040283529160200191610200565b82019190600052602060","0020905b8154815290600101906020018083116101e357829003601f16820191","5b50505050509050905600a165627a7a72305820f4e74ca2266a24aabd6a8ee6","c4e54ad49014e2faa152e49e7f9d927c932c7287002900000000000000000000"],"storage":{"0000000000000000000000000000000000000000000000000000000000000000":"000000000000000000000000b0945862f63b832849a5f20b19e9f8188eb2230a","0000000000000000000000000000000000000000000000000000000000000001":"0000000000000000000000000000000000000000000000000000000000000000"}}]}}]} -``` - - -## debug_traceTransaction - -The `traceTransaction` debugging method will attempt to run the transaction in -the exact same manner as it was executed on the network. It will replay any -transaction that may have been executed prior to this one before it will -finally attempt to execute the transaction that corresponds to the given hash. - -| Client | Method Invocation | -|:-------:|----------------------------------------------------------------| -| Console | `debug.traceTransaction(txHash, [options])` | -| RPC | `{"method": "debug_traceTransaction", "params": [txHash, {}]}` | - -**Parameters** - -| Name | Type | Description | -| --- | --- | --- | -| txHash | string | The hash of the transaction. | -| options | object | See [tracing options](#tracing-options). | - -**Return Value** - -| Type | Description | -| --- | --- | -| JSON string | The structured logs created during the execution of KLVM. | - -**Example** - -Console -```javascript -> debug.traceTransaction("0x07f6057bc93aca52e53cdbfac9b9830f6a9cae2b3f48f0b47e4cb54959143d09") -{ - failed: false, - gas: 247922, - returnValue: "60806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806341c0e1b514610051578063cfae321714610068575b600080fd5b34801561005d57600080fd5b506100666100f8565b005b34801561007457600080fd5b5061007d610168565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100bd5780820151818401526020810190506100a2565b50505050905090810190601f1680156100ea5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610166573373ffffffffffffffffffffffffffffffffffffffff16ff5b565b606060018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156102005780601f106101d557610100808354040283529160200191610200565b820191906000526020600020905b8154815290600101906020018083116101e357829003601f168201915b50505050509050905600a165627a7a72305820f4e74ca2266a24aabd6a8ee6c4e54ad49014e2faa152e49e7f9d927c932c72870029", - structLogs: [{ - depth: 1, - gas: 891344, - gasCost: 3, - memory: [], - op: "PUSH1", - pc: 0, - stack: [], - storage: {} - }, { - depth: 1, - gas: 891341, - gasCost: 3, - memory: [], - op: "PUSH1", - pc: 2, - stack: ["0000000000000000000000000000000000000000000000000000000000000080"], - storage: {} - }, { - depth: 1, - gas: 891338, - gasCost: 12, - memory: ["0000000000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000000000"], - op: "MSTORE", - pc: 4, - stack: ["0000000000000000000000000000000000000000000000000000000000000080", "0000000000000000000000000000000000000000000000000000000000000040"], - storage: {} - }, { - depth: 1, - gas: 891326, - gasCost: 2, - memory: ["0000000000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000000080"], - op: "CALLVALUE", - pc: 5, - stack: [], - storage: {} - }, { - ... - }, { - depth: 1, - gas: 865281, - gasCost: 3, - memory: ["60806040526004361061004c576000357c010000000000000000000000000000", "0000000000000000000000000000900463ffffffff16806341c0e1b514610051", "578063cfae321714610068575b600080fd5b34801561005d57600080fd5b5061", "00666100f8565b005b34801561007457600080fd5b5061007d610168565b6040", "5180806020018281038252838181518152602001915080519060200190808383", "60005b838110156100bd5780820151818401526020810190506100a2565b5050", "5050905090810190601f1680156100ea5780820380516001836020036101000a", "031916815260200191505b509250505060405180910390f35b60008090549061", "01000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffff", "ffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffff", "ffffffffffffff161415610166573373ffffffffffffffffffffffffffffffff", "ffffffff16ff5b565b6060600180546001816001161561010002031660029004", "80601f0160208091040260200160405190810160405280929190818152602001", "828054600181600116156101000203166002900480156102005780601f106101", "d557610100808354040283529160200191610200565b82019190600052602060", "0020905b8154815290600101906020018083116101e357829003601f16820191", "5b50505050509050905600a165627a7a72305820f4e74ca2266a24aabd6a8ee6", "c4e54ad49014e2faa152e49e7f9d927c932c7287002900000000000000000000"], - op: "PUSH1", - pc: 320, - stack: ["0000000000000000000000000000000000000000000000000000000000000236"], - storage: { - 0000000000000000000000000000000000000000000000000000000000000000: "000000000000000000000000b0945862f63b832849a5f20b19e9f8188eb2230a", - 0000000000000000000000000000000000000000000000000000000000000001: "0000000000000000000000000000000000000000000000000000000000000000" - } - }, { - depth: 1, - gas: 865278, - gasCost: 0, - memory: ["60806040526004361061004c576000357c010000000000000000000000000000", "0000000000000000000000000000900463ffffffff16806341c0e1b514610051", "578063cfae321714610068575b600080fd5b34801561005d57600080fd5b5061", "00666100f8565b005b34801561007457600080fd5b5061007d610168565b6040", "5180806020018281038252838181518152602001915080519060200190808383", "60005b838110156100bd5780820151818401526020810190506100a2565b5050", "5050905090810190601f1680156100ea5780820380516001836020036101000a", "031916815260200191505b509250505060405180910390f35b60008090549061", "01000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffff", "ffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffff", "ffffffffffffff161415610166573373ffffffffffffffffffffffffffffffff", "ffffffff16ff5b565b6060600180546001816001161561010002031660029004", "80601f0160208091040260200160405190810160405280929190818152602001", "828054600181600116156101000203166002900480156102005780601f106101", "d557610100808354040283529160200191610200565b82019190600052602060", "0020905b8154815290600101906020018083116101e357829003601f16820191", "5b50505050509050905600a165627a7a72305820f4e74ca2266a24aabd6a8ee6", "c4e54ad49014e2faa152e49e7f9d927c932c7287002900000000000000000000"], - op: "RETURN", - pc: 322, - stack: ["0000000000000000000000000000000000000000000000000000000000000236", "0000000000000000000000000000000000000000000000000000000000000000"], - storage: { - 0000000000000000000000000000000000000000000000000000000000000000: "000000000000000000000000b0945862f63b832849a5f20b19e9f8188eb2230a", - 0000000000000000000000000000000000000000000000000000000000000001: "0000000000000000000000000000000000000000000000000000000000000000" - } - }] -} -``` -HTTP RPC -```shell -$ curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"debug_traceTransaction","params":["0x07f6057bc93aca52e53cdbfac9b9830f6a9cae2b3f48f0b47e4cb54959143d09"],"id":1}' https://public-en-baobab.klaytn.net -{"jsonrpc":"2.0","id":1,"result":{"gas":247922,"failed":false,"returnValue":"60806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806341c0e1b514610051578063cfae321714610068575b600080fd5b34801561005d57600080fd5b506100666100f8565b005b34801561007457600080fd5b5061007d610168565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100bd5780820151818401526020810190506100a2565b50505050905090810190601f1680156100ea5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610166573373ffffffffffffffffffffffffffffffffffffffff16ff5b565b606060018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156102005780601f106101d557610100808354040283529160200191610200565b820191906000526020600020905b8154815290600101906020018083116101e357829003601f168201915b50505050509050905600a165627a7a72305820f4e74ca2266a24aabd6a8ee6c4e54ad49014e2faa152e49e7f9d927c932c72870029","structLogs":[{"pc":0,"op":"PUSH1","gas":891344,"gasCost":3,"depth":1,"stack":[],"memory":[],"storage":{}},{"pc":2,"op":"PUSH1","gas":891341,"gasCost":3,"depth":1,"stack":["0000000000000000000000000000000000000000000000000000000000000080"],"memory":[],"storage":{}},{"pc":4,"op":"MSTORE","gas":891338,"gasCost":12,"depth":1,"stack":["0000000000000000000000000000000000000000000000000000000000000080","0000000000000000000000000000000000000000000000000000000000000040"],"memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000"],"storage":{}}, -... -,{"pc":322,"op":"RETURN","gas":865278,"gasCost":0,"depth":1,"stack":["0000000000000000000000000000000000000000000000000000000000000236","0000000000000000000000000000000000000000000000000000000000000000"],"memory":["60806040526004361061004c576000357c010000000000000000000000000000","0000000000000000000000000000900463ffffffff16806341c0e1b514610051","578063cfae321714610068575b600080fd5b34801561005d57600080fd5b5061","00666100f8565b005b34801561007457600080fd5b5061007d610168565b6040","5180806020018281038252838181518152602001915080519060200190808383","60005b838110156100bd5780820151818401526020810190506100a2565b5050","5050905090810190601f1680156100ea5780820380516001836020036101000a","031916815260200191505b509250505060405180910390f35b60008090549061","01000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffff","ffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffff","ffffffffffffff161415610166573373ffffffffffffffffffffffffffffffff","ffffffff16ff5b565b6060600180546001816001161561010002031660029004","80601f0160208091040260200160405190810160405280929190818152602001","828054600181600116156101000203166002900480156102005780601f106101","d557610100808354040283529160200191610200565b82019190600052602060","0020905b8154815290600101906020018083116101e357829003601f16820191","5b50505050509050905600a165627a7a72305820f4e74ca2266a24aabd6a8ee6","c4e54ad49014e2faa152e49e7f9d927c932c7287002900000000000000000000"],"storage":{"0000000000000000000000000000000000000000000000000000000000000000":"000000000000000000000000b0945862f63b832849a5f20b19e9f8188eb2230a","0000000000000000000000000000000000000000000000000000000000000001":"0000000000000000000000000000000000000000000000000000000000000000"}}]}} -``` - -## debug_traceCall -The `traceCall` returns the tracing result by executing a klay call within the context of the given block execution. - -**Parameters** - -| Name | Type | Description | -| --- | --- | --- | -| callObject | Object | The transaction call object. See the next table for the object's properties. | -| blockNumberOrHash | QUANTITY \| TAG \| HASH| Integer or hexadecimal block number, or the string `"earliest"`, `"latest"` or `"pending"` as in the [default block parameter](../eth/block.md#the-default-block-parameter), or block hash.| -| options | object | See [tracing options](#tracing-options). | - -**Return Value** - -| Type | Description | -| --- | --- | -| JSON string | The structured logs created during the execution of KLVM. | - -**Example** -Console -```javascript -> debug.traceCall({from: "0xB2da01761B494F5F257fD3bA626fBAbFaE104313", to: "0xB2da01761B494F5F257fD3bA626fBAbFaE104313", input: "0x6057361d0000000000000000000000000000000000000000000000000000000000000003"}, "latest", {tracer:"revertTracer"}) -"this is the revert reason for this tracecall" -``` - -HTTP RPC -```shell -$ curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"debug_traceCall","params":[{"from": "0xB2da01761B494F5F257fD3bA626fBAbFaE104313", "to": "0xB2da01761B494F5F257fD3bA626fBAbFaE104313", "input": "0x6057361d0000000000000000000000000000000000000000000000000000000000000003"}, "latest", {"tracer":"revertTracer"}],"id":1}' http://localhost:8551 -"this is the revert reason for this tracecall" -``` - -## debug_traceChain - -Returns the structured logs created during the execution of EVM between two blocks (excluding start) as a JSON object. This endpoint must be invoked via debug_subscribe as follows: - -**NOTE**: Don't trace too many blocks at the same time as it can overuse machine resources. - -**Parameters** - -| Name | Type | Description | -| --- | --- | --- | -| number | int | Tracing start block number. | -| number | int | Tracing end block number. | -| options | object | See [tracing options](#tracing-options). | - -**Example** -``` -wscat -c ws://localhost:8552 -> {"id": 1, "method": "debug_subscribe", "params": ["traceChain", 21, 30, {}]} -< {"jsonrpc":"2.0","id":1,"result":"0xcef1ebe5819ce55a11e97c28cee5d36b"} -< {"jsonrpc":"2.0","method":"debug_subscription","params":{"subscription":"0xcef1ebe5819ce55a11e97c28cee5d36b","result":{"block":"0x16","hash":"0xb620aa234c0a9279d3eb467d5be96d93a31edc580385cae632c6f7c231c3ac72","traces":[{"txHash":"0xeb6b4ddb206952f8600dd64d04618d518b51bfe722226d6717ce5c96aa243070","result":{"gas":21000,"failed":false,"returnValue":"","structLogs":[]}},{"txHash":"0xf389f44a0e61b6497517c2b4569343adeab59e2b099d6a43ae1c6c10a71823b2","result":{"gas":21000,"failed":false,"returnValue":"","structLogs":[]}}]}}} -< {"jsonrpc":"2.0","method":"debug_subscription","params":{"subscription":"0xcef1ebe5819ce55a11e97c28cee5d36b","result":{"block":"0x17","hash":"0x634c41b5687fe733dacb9d4a4062fd29f744132771f8529838c1956d18efadd4","traces":[{"txHash":"0xa0bdd0e9c69f45295e7cb8fe2e6fb6c35f0d99b69d31d496fd57e40e4da6f85e","result":{"gas":21000,"failed":false,"returnValue":"","structLogs":[]}},{"txHash":"0x5762193b76c0c61cbe272e3bc54d0d7e123677efb12cc62e2e08a4743992f1ff","result":{"gas":21000,"failed":false,"returnValue":"","structLogs":[]}}]}}} -... -> -``` - -## Tracing Options - -You may give trace API function a secondary optional argument, which specifies -the options for this specific call. The possible options are: - -- `disableStorage`: `BOOL`. Setting this to true will disable storage capture (default = false). -- `disableMemory`: `BOOL`. Setting this to true will disable memory capture (default = false). -- `disableStack`: `BOOL`. Setting this to true will disable stack capture (default = false). -- `timeout`: `STRING`. Overrides the default timeout of 5 seconds for JavaScript-based tracing calls. Valid values are described [here](https://golang.org/pkg/time/#ParseDuration). -- `tracer`: `STRING`. Setting this will enable JavaScript-based transaction tracing, described in the [next section](#javascript-based-tracing). If set, the previous four arguments will be ignored. The predefined tracers can also be used as the following table. -- `reexec`: `INT`. Overrides the default reexec value (default = 128). Reexec value is the maximum number of blocks to reprocess trying to obtain the desired state. - -Tracer Name | Description --- | -- -4byteTracer | 4byteTracer searches for 4byte-identifiers, and collects them for post-processing. It collects the methods identifiers along with the size of the supplied data, so a reversed signature can be matched against the size of the data. -callTracer | callTracer is a full-blown transaction tracer that extracts and reports all the internal calls made by a transaction, along with any useful information. -fastCallTracer | fastCallTracer is a Go-native version of callTracer. Since it is not executed on JavaScript VM, it shows more than 10x speedup compared to callTracer. Please use fastCallTracer instead of callTracer if the performance is the matter of the first importance. -evmdisTracer | evmdisTracer returns sufficient information from a trace to perform evmdis-style disassembly. -noopTracer | noopTracer is just the barebone boilerplate code required from a JavaScript object to be usable as a transaction tracer. -opcountTracer | opcountTracer is a sample tracer that just counts the number of instructions executed by the KLVM before the transaction terminated. -prestateTracer | prestateTracer outputs sufficient information to create a local execution of the transaction from a custom assembled genesis block. -revertTracer | revertTracer outputs the error string of REVERT. If the execution is not reverted, it outputs an empty string. -unigramTracer | unigramTracer returns the number of occurrences of each opcode. -bigramTracer | bigramTracer returns the number of occurrences of two consecutive opcodes. -trigramTracer | trigramTracer returns the number of occurrences of three consecutive opcodes. - - -**Example** - -Console -```javascript -> debug.traceTransaction("0x07f6057bc93aca52e53cdbfac9b9830f6a9cae2b3f48f0b47e4cb54959143d09", {tracer: "callTracer"}) -{ - from: "0xb0945862f63b832849a5f20b19e9f8188eb2230a", - gas: "0xd99d0", - gasUsed: "0x22002", - input: "0x608060405234801561001057600080fd5b5060405161037a38038061037a83398101806040528101908080518201929190505050336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508060019080519060200190610089929190610090565b5050610135565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106100d157805160ff19168380011785556100ff565b828001600101855582156100ff579182015b828111156100fe5782518255916020019190600101906100e3565b5b50905061010c9190610110565b5090565b61013291905b8082111561012e576000816000905550600101610116565b5090565b90565b610236806101446000396000f30060806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806341c0e1b514610051578063cfae321714610068575b600080fd5b34801561005d57600080fd5b506100666100f8565b005b34801561007457600080fd5b5061007d610168565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100bd5780820151818401526020810190506100a2565b50505050905090810190601f1680156100ea5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610166573373ffffffffffffffffffffffffffffffffffffffff16ff5b565b606060018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156102005780601f106101d557610100808354040283529160200191610200565b820191906000526020600020905b8154815290600101906020018083116101e357829003601f168201915b50505050509050905600a165627a7a72305820f4e74ca2266a24aabd6a8ee6c4e54ad49014e2faa152e49e7f9d927c932c72870029", - output: "0x60806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806341c0e1b514610051578063cfae321714610068575b600080fd5b34801561005d57600080fd5b506100666100f8565b005b34801561007457600080fd5b5061007d610168565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100bd5780820151818401526020810190506100a2565b50505050905090810190601f1680156100ea5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610166573373ffffffffffffffffffffffffffffffffffffffff16ff5b565b606060018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156102005780601f106101d557610100808354040283529160200191610200565b820191906000526020600020905b8154815290600101906020018083116101e357829003601f168201915b50505050509050905600a165627a7a72305820f4e74ca2266a24aabd6a8ee6c4e54ad49014e2faa152e49e7f9d927c932c72870029", - time: "2.507969ms", - to: "0x98cf8b777dab0137b47a7fdaad1378ec93a7b80b", - type: "CREATE", - value: "0x0" -} -> debug.traceTransaction("0xbae8bd56daa6a3f1bba16854d14e37f265e76976c960ac57c4c7b56a78729e53", {tracer:'revertTracer'}) -"reverted due to XXX" -``` - -HTTP RPC -```shell -curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"debug_traceTransaction","params":["0x07f6057bc93aca52e53cdbfac9b9830f6a9cae2b3f48f0b47e4cb54959143d09", {"tracer": "callTracer"}],"id":1}' https://public-en-baobab.klaytn.net -{"jsonrpc":"2.0","id":1,"result":{"type":"CREATE","from":"0xb0945862f63b832849a5f20b19e9f8188eb2230a","to":"0x98cf8b777dab0137b47a7fdaad1378ec93a7b80b","value":"0x0","gas":"0xd99d0","gasUsed":"0x22002","input":"0x608060405234801561001057600080fd5b5060405161037a38038061037a83398101806040528101908080518201929190505050336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508060019080519060200190610089929190610090565b5050610135565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106100d157805160ff19168380011785556100ff565b828001600101855582156100ff579182015b828111156100fe5782518255916020019190600101906100e3565b5b50905061010c9190610110565b5090565b61013291905b8082111561012e576000816000905550600101610116565b5090565b90565b610236806101446000396000f30060806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806341c0e1b514610051578063cfae321714610068575b600080fd5b34801561005d57600080fd5b506100666100f8565b005b34801561007457600080fd5b5061007d610168565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100bd5780820151818401526020810190506100a2565b50505050905090810190601f1680156100ea5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610166573373ffffffffffffffffffffffffffffffffffffffff16ff5b565b606060018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156102005780601f106101d557610100808354040283529160200191610200565b820191906000526020600020905b8154815290600101906020018083116101e357829003601f168201915b50505050509050905600a165627a7a72305820f4e74ca2266a24aabd6a8ee6c4e54ad49014e2faa152e49e7f9d927c932c72870029","output":"0x60806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806341c0e1b514610051578063cfae321714610068575b600080fd5b34801561005d57600080fd5b506100666100f8565b005b34801561007457600080fd5b5061007d610168565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100bd5780820151818401526020810190506100a2565b50505050905090810190601f1680156100ea5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610166573373ffffffffffffffffffffffffffffffffffffffff16ff5b565b606060018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156102005780601f106101d557610100808354040283529160200191610200565b820191906000526020600020905b8154815290600101906020018083116101e357829003601f168201915b50505050509050905600a165627a7a72305820f4e74ca2266a24aabd6a8ee6c4e54ad49014e2faa152e49e7f9d927c932c72870029","time":"2.510754ms"}} - -curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"debug_traceTransaction","params":["0xbae8bd56daa6a3f1bba16854d14e37f265e76976c960ac57c4c7b56a78729e53", {"tracer": "revertTracer"}],"id":1}' https://public-en-baobab.klaytn.net -{"jsonrpc":"2.0","id":1,"result":"reverted due to XXX"} -``` - - -## JavaScript-based Tracing - -**NOTE** The JavaScript-based Tracing allows the user to run arbitrary JS code, -which is **unsafe**. If you want to provide debug namespace APIs to the public, -we strongly recommend to set the `rpc.unsafe-debug.disable` flag when running -the EN, so the JavaScript-based Tracing can be disabled. - -Specifying the `tracer` option in the second argument enables JavaScript-based tracing. In this mode, `tracer` is interpreted as a JavaScript expression that is expected to evaluate to an object with (at least) two methods, named `step` and `result`. - -`step` is a function that takes two arguments, `log` and `db`, and is called -for each step of the KLVM, or when an error occurs, as the specified -transaction is traced. - -`log` has the following fields: - -Field Name | Type | Description ---|--|--| -`pc`| Number | The current program counter. -`op`| Object | An OpCode object representing the current opcode. -`gas`| Number | The amount of gas remaining. -`gasPrice`| Number | The cost in peb of each unit of gas. -`memory`| Object | A structure representing the contract's memory space. -`stack`| array[big.Int] | The KLVM execution stack. -`depth`| Number | The execution depth. -`account`| String | The address of the account executing the current operation. -`err`| String | If an error occurred, information about the error. - -If `err` is non-null, all other fields should be ignored. - -For efficiency, the same `log` object is reused on each execution step, updated -with current values; make sure to copy values you want to preserve beyond the -current call. For instance, this step function will not work: - -```javascript -function(log) { - this.logs.append(log); -} -``` - -But this step function will: - -```javascript -function(log) { - this.logs.append({gas: log.gas, pc: log.pc, ...}); -} -``` - -`log.op` has the following methods: - -Method Name | Description ---|-- -`isPush()` | Returns true if the opcode is a `PUSHn`. -`toString()` | Returns the string representation of the opcode. -`toNumber()` | Returns the opcode's number. - -`log.memory` has the following methods: - -Method Name | Description ---|-- -`slice(start, stop)` | Returns the specified segment of memory as a byte slice. -`length()` | Returns the length of the memory. - -`log.stack` has the following methods: - -Method Name | Description ---|-- -`peek(idx)` | Returns the idx-th element from the top of the stack (0 is the topmost element) as a `big.Int`. -`length()` | Returns the number of elements in the stack. - -`db` has the following methods: - -Method Name | Description ---|-- -`getBalance(address)` | Returns a `big.Int` with the specified account's balance. -`getNonce(address)` | Returns a Number with the specified account's nonce. -`getCode(address)` | Returns a byte slice with the code for the specified account. -`getState(address, hash)` | Returns the state value for the specified account and the specified hash. -`exists(address)` | Returns true if the specified address exists. - -The second function, `result`, takes no arguments, and is expected to return a -JSON-serializable value to return to the RPC caller. - -If the `step` function throws an exception or executes an illegal operation at -any point, it will not be called on any further VM steps, and the error will be -returned to the caller. - -Note that several values are Golang `big.Int` objects, not JavaScript numbers -or JS bigints. As such, they have the same interface as described in the -godocs. Their default serialization to JSON is as a Javascript number; to -serialize large numbers accurately call `.String()` on them. For convenience, -`big.NewInt(x)` is provided, and will convert a uint to a Golang `big.Int`. - -As an usage example below, it returns the top element of the stack at each CALL -opcode only: - -```javascript -debug.traceTransaction(txhash, {tracer: '{data: [], step: function(log) { if(log.op.toString() == "CALL") this.data.push(log.stack.peek(0)); }, result: function() { return this.data; }}'}); -``` diff --git a/docs/references/json-rpc/eth/sidebar.ts b/docs/references/json-rpc/eth/sidebar.ts new file mode 100644 index 00000000000..9af1b92c573 --- /dev/null +++ b/docs/references/json-rpc/eth/sidebar.ts @@ -0,0 +1,12 @@ +import type { SidebarsConfig } from "@docusaurus/plugin-content-docs"; + +const sidebar: SidebarsConfig = { + apisidebar: [ + { + type: "doc", + id: "references/json-rpc/eth/web-3-rpc", + }, + ], +}; + +export default sidebar.apisidebar; \ No newline at end of file diff --git a/docs/references/json-rpc/governance/sidebar.ts b/docs/references/json-rpc/governance/sidebar.ts new file mode 100644 index 00000000000..5fb965e290a --- /dev/null +++ b/docs/references/json-rpc/governance/sidebar.ts @@ -0,0 +1,12 @@ +import type { SidebarsConfig } from "@docusaurus/plugin-content-docs"; + +const sidebar: SidebarsConfig = { + apisidebar: [ + { + type: "doc", + id: "references/json-rpc/governance/web-3-rpc", + }, + ], +}; + +export default sidebar.apisidebar; \ No newline at end of file diff --git a/docs/references/json-rpc/klay/sidebar.ts b/docs/references/json-rpc/klay/sidebar.ts new file mode 100644 index 00000000000..213883608e8 --- /dev/null +++ b/docs/references/json-rpc/klay/sidebar.ts @@ -0,0 +1,12 @@ +import type { SidebarsConfig } from "@docusaurus/plugin-content-docs"; + +const sidebar: SidebarsConfig = { + apisidebar: [ + { + type: "doc", + id: "references/json-rpc/klay/web-3-rpc", + }, + ], +}; + +export default sidebar.apisidebar; \ No newline at end of file diff --git a/docs/references/json-rpc/mainbridge/sidebar.ts b/docs/references/json-rpc/mainbridge/sidebar.ts new file mode 100644 index 00000000000..05eaa988f1b --- /dev/null +++ b/docs/references/json-rpc/mainbridge/sidebar.ts @@ -0,0 +1,12 @@ +import type { SidebarsConfig } from "@docusaurus/plugin-content-docs"; + +const sidebar: SidebarsConfig = { + apisidebar: [ + { + type: "doc", + id: "references/json-rpc/mainbridge/web-3-rpc", + }, + ], +}; + +export default sidebar.apisidebar; \ No newline at end of file diff --git a/docs/references/json-rpc/net/sidebar.ts b/docs/references/json-rpc/net/sidebar.ts new file mode 100644 index 00000000000..3a6040736aa --- /dev/null +++ b/docs/references/json-rpc/net/sidebar.ts @@ -0,0 +1,12 @@ +import type { SidebarsConfig } from "@docusaurus/plugin-content-docs"; + +const sidebar: SidebarsConfig = { + apisidebar: [ + { + type: "doc", + id: "references/json-rpc/net/web-3-rpc", + }, + ], +}; + +export default sidebar.apisidebar; \ No newline at end of file diff --git a/docs/references/json-rpc/personal/sidebar.ts b/docs/references/json-rpc/personal/sidebar.ts new file mode 100644 index 00000000000..09be4e4425a --- /dev/null +++ b/docs/references/json-rpc/personal/sidebar.ts @@ -0,0 +1,12 @@ +import type { SidebarsConfig } from "@docusaurus/plugin-content-docs"; + +const sidebar: SidebarsConfig = { + apisidebar: [ + { + type: "doc", + id: "references/json-rpc/personal/web-3-rpc", + }, + ], +}; + +export default sidebar.apisidebar; \ No newline at end of file diff --git a/docs/references/json-rpc/subbridge/sidebar.ts b/docs/references/json-rpc/subbridge/sidebar.ts new file mode 100644 index 00000000000..f00ec92bdab --- /dev/null +++ b/docs/references/json-rpc/subbridge/sidebar.ts @@ -0,0 +1,12 @@ +import type { SidebarsConfig } from "@docusaurus/plugin-content-docs"; + +const sidebar: SidebarsConfig = { + apisidebar: [ + { + type: "doc", + id: "references/json-rpc/subbridge/web-3-rpc", + }, + ], +}; + +export default sidebar.apisidebar; \ No newline at end of file diff --git a/docs/references/json-rpc/txpool/sidebar.ts b/docs/references/json-rpc/txpool/sidebar.ts new file mode 100644 index 00000000000..624e9cb4cea --- /dev/null +++ b/docs/references/json-rpc/txpool/sidebar.ts @@ -0,0 +1,12 @@ +import type { SidebarsConfig } from "@docusaurus/plugin-content-docs"; + +const sidebar: SidebarsConfig = { + apisidebar: [ + { + type: "doc", + id: "references/json-rpc/txpool/web-3-rpc", + }, + ], +}; + +export default sidebar.apisidebar; \ No newline at end of file diff --git a/docs/references/service-chain-api/mainbridge.md b/docs/references/service-chain-api/mainbridge.md deleted file mode 100644 index 870bc42b69c..00000000000 --- a/docs/references/service-chain-api/mainbridge.md +++ /dev/null @@ -1,180 +0,0 @@ ---- -description: >- - APIs related to main chain ENs connected with a service chain. ---- - -# mainbridge - -The namespace `mainbridge` provides functions related to Service Chain. -To use functions in this namespace, the option `mainbridge` should be enabled in the EN connected to the main chain (Mainnet or Baobab testnet). - -## mainbridge_nodeInfo - -Returns bridge node information including the KNI (Klaytn Network Identifier) of the node. -A mainbridge node can connect to a subbrige node via the KNI. - -**Parameters** - -None - -**Return Value** - -| Type | Description | -| ------ | ------------------------------------ | -| JSON string | the bridge node information. | - -**Example** - -```javascript -> mainbridge.nodeInfo -{ - kni: "kni://f8a1f0cd1e2bebeece571e4fda16e215218fd4b9bc2eddd924f7cd5b5f950fcec8f4b8cd3851390d1d0bacf1b15e1c4a38c882252e429a28d16eeb6edbacd726@[::]:50505?discport=0", - id: "f8a1f0cd1e2bebeece571e4fda16e215218fd4b9bc2eddd924f7cd5b5f950fcec8f4b8cd3851390d1d0bacf1b15e1c4a38c882252e429a28d16eeb6edbacd726", - ip: "::", - listenAddr: "[::]:50505", - name: "-2", - ports: { - discovery: 0, - listener: 50505 - }, - protocols: { - servicechain: { - config: { - chainId: 2018, - deriveShaImpl: 0, - isBFT: true, - istanbul: {...}, - unitPrice: 0 - }, - difficulty: 87860, - genesis: "0x711ce9865492659977abb2758d29f68c2b0c82862d9376f25953579f64f95b58", - head: "0x0d4b130731f1e7560e4531ac73d55ac8c6daccb178abd86af0d96b7aafded7c5", - network: 1 - } - } -} -``` - -## mainbridge_addPeer -Returns `true` if adding a subbridge peer is done successfully. - -It Adds a new remote node to the peer list. -The node will try to maintain connectivity to these nodes at all times, reconnecting every -once in a while if the remote connection goes down. -The method accepts a single argument, the `kni` URL of the remote peer to start tracking and returns a `BOOL` indicating whether the peer was accepted for tracking or some error occurred. - -**Parameters** - -| Name | Type | Description | -| --- | --- | --- | -| url | string | Peer's `kni` URL. | - -**Return Value** - -| Type | Description | -| --- | --- | -| bool | `true` if the peer was accepted, `false` otherwise. | - -**Example** - -Console - -```javascript -> mainbridge.addPeer("kni://a979fb...1163c@10.0.0.1:50505") // or 'subbridge.addPeer' -true -``` -HTTP RPC - -```shell -$ curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"mainbridge_addPeer","params":["kni://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@10.0.0.1:50505"],"id":1}' https://public-en-baobab.klaytn.net -{"jsonrpc":"2.0","id":1,"result":true} -``` - -## mainbridge_removePeer -Returns `true` if removing the peer is done successfully. - -The `removePeer` method disconnects and removes the remote node in the list of tracked static nodes. -The method accepts a single argument, the `kni` URL of the remote peer to start tracking and returns a `BOOL` indicating whether the peer was accepted -for tracking or some error occurred. - -**Parameters** - -| Name | Type | Description | -| --- | --- | --- | -| url | string | Peer's `kni` URL. | - -**Return Value** - -| Type | Description | -| --- | --- | -| bool | `true` if the peer was removed, `false` otherwise. | - -**Example** - -Console - -```javascript -> mainbridge.removePeer("kni://a979fb...1163c@10.0.0.1:50505") // or 'subbridge.removePeer' -true -``` - -HTTP RPC - -```shell -$ curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"mainbridge_removePeer","params":["kni://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@10.0.0.1:50505"],"id":1}' https://public-en-baobab.klaytn.net -{"jsonrpc":"2.0","id":1,"result":true} -``` - -## mainbridge_getChildChainIndexingEnabled - -`mainbridge_getChildChainIndexingEnabled` returns if indexing anchoring transaction is enabled or not. - -**Parameters** - -none - -**Return Value** - -| Type | Description | -| ------ | ------------------------------------ | -| bool | `true` if the indexing was enabled, `false` otherwise. | - -**Example** - -```javascript -> mainbridge.getChildChainIndexingEnabled() -true -``` - -## mainbridge_convertChildChainBlockHashToParentChainTxHash - -Returns the anchoring transaction hash of the given child chain block hash. - -**Parameters** - -| Type | Description | -| ------ | ------------------------------------ | -| 32-byte DATA | The child chain block hash. | - -**Return Value** - -| Type | Description | -| ------ | ------------------------------------ | -| 32-byte DATA | The anchoring transaction hash that includes the child chain block information.| - -**Example** - -Console - -```javascript -> mainbridge.convertChildChainBlockHashToParentChainTxHash("0xeadc6a3a29a20c13824b5df1ba05cca1ed248d046382a4f2792aac8a6e0d1880") -"0x9a68591c0faa138707a90a7506840c562328aeb7621ac0561467c371b0322d51" -``` - -HTTP RPC - -```shell -$ curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"mainbridge_convertChildChainBlockHashToParentChainTxHash","params":["0xeadc6a3a29a20c13824b5df1ba05cca1ed248d046382a4f2792aac8a6e0d1880"],"id":1}' https://public-en-baobab.klaytn.net -{"jsonrpc":"2.0","id":1,"result":"0x9a68591c0faa138707a90a7506840c562328aeb7621ac0561467c371b0322d51"} -``` - diff --git a/docs/references/service-chain-api/service-chain-api.md b/docs/references/service-chain-api/service-chain-api.md deleted file mode 100644 index 12c7505deb0..00000000000 --- a/docs/references/service-chain-api/service-chain-api.md +++ /dev/null @@ -1,9 +0,0 @@ -# Service Chain API Reference - -Namespaces related to "Service Chain". - -```mdx-code-block -import DocCardList from '@theme/DocCardList'; - - -``` \ No newline at end of file diff --git a/docs/references/service-chain-api/subbridge.md b/docs/references/service-chain-api/subbridge.md deleted file mode 100644 index d59610154fd..00000000000 --- a/docs/references/service-chain-api/subbridge.md +++ /dev/null @@ -1,705 +0,0 @@ ---- -description: >- - APIs related to service chain ENs. ---- - -# subbridge - -The namespace `subbridge` provides functions related to Service Chain. -To use the functions in this namespace, the option `subbridge` should be enabled in the SEN connected to the service chain. - -## subbridge_nodeInfo - -Returns bridge node information including the KNI (Klaytn Network Identifier) of the node. -A subbridge node can connect to a mainbridge node via the KNI. - -**Parameters** - -None - -**Return Value** - -| Type | Description | -| ------ | ------------------------------------ | -| JSON string | the bridge node information. | - -**Example** - -```javascript -> subbridge.nodeInfo -{ - kni: "kni://f8a1f0cd1e2bebeece571e4fda16e215218fd4b9bc2eddd924f7cd5b5f950fcec8f4b8cd3851390d1d0bacf1b15e1c4a38c882252e429a28d16eeb6edbacd726@[::]:50505?discport=0", - id: "f8a1f0cd1e2bebeece571e4fda16e215218fd4b9bc2eddd924f7cd5b5f950fcec8f4b8cd3851390d1d0bacf1b15e1c4a38c882252e429a28d16eeb6edbacd726", - ip: "::", - listenAddr: "[::]:50505", - name: "-2", - ports: { - discovery: 0, - listener: 50505 - }, - protocols: { - servicechain: { - config: { - chainId: 2018, - deriveShaImpl: 0, - isBFT: true, - istanbul: {...}, - unitPrice: 0 - }, - difficulty: 87860, - genesis: "0x711ce9865492659977abb2758d29f68c2b0c82862d9376f25953579f64f95b58", - head: "0x0d4b130731f1e7560e4531ac73d55ac8c6daccb178abd86af0d96b7aafded7c5", - network: 1 - } - } -} -``` - -## subbridge_addPeer -Returns `true` if adding a mainbridge peer is done successfully. - -The `addPeer` method adds a new remote node to the peer list. -The node will try to maintain connectivity to these nodes at all times, reconnecting every -once in a while if the remote connection goes down. - -The method accepts a single argument, the `kni` URL of the remote peer to start tracking and returns a `BOOL` indicating whether the peer was accepted -for tracking or some error occurred. - -**Parameters** - -| Name | Type | Description | -| --- | --- | --- | -| url | string | Peer's `kni` URL. | - -**Return Value** - -| Type | Description | -| --- | --- | -| bool | `true` if the peer was accepted, `false` otherwise. | - -**Example** - -Console - -```javascript -> mainbridge.addPeer("kni://a979fb...1163c@10.0.0.1:50505") // or 'subbridge.addPeer' -true -``` -HTTP RPC - -```shell -$ curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"mainbridge_addPeer","params":["kni://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@10.0.0.1:50505"],"id":1}' https://public-en-baobab.klaytn.net -{"jsonrpc":"2.0","id":1,"result":true} -``` - -## subbridge_removePeer -Returns `true` if removing the peer is done successfully. - -The `removePeer` method disconnects and removes the remote node in the list of tracked static nodes. -The method accepts a single argument, the `kni` URL of the remote peer to start tracking and returns a `BOOL` indicating whether the peer was accepted -for tracking or some error occurred. - -**Parameters** - -| Name | Type | Description | -| --- | --- | --- | -| url | string | Peer's `kni` URL. | - -**Return Value** - -| Type | Description | -| --- | --- | -| bool | `true` if the peer was removed, `false` otherwise. | - -**Example** - -Console - -```javascript -> mainbridge.removePeer("kni://a979fb...1163c@10.0.0.1:50505") // or 'subbridge.removePeer' -true -``` - -HTTP RPC - -```shell -$ curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"mainbridge_removePeer","params":["kni://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@10.0.0.1:50505"],"id":1}' https://public-en-baobab.klaytn.net -{"jsonrpc":"2.0","id":1,"result":true} -``` - -## subbridge_parentOperator -The `subbridge_parentOperator` returns the parent operator account address. - -**Parameters** - -none - -**Return Value** - -| Type | Description | -| --- | --- | -| Account | Parent chain operator account address. | - -**Example** - -```javascript -> subbridge.parentOperator -"0xA057995175B93Ee0D1bdfA54f078Ad0F0116130b" -``` - -## subbridge_childOperator -The `subbridge_childOperator` returns the child operator account address. - -**Parameters** - -none - -**Return Value** - -| Type | Description | -| --- | --- | -| Account | Child chain operator account address. | - -**Example** - -```javascript -> subbridge.childOperator -"0x5C1C757a6Cb6c6FcEFE398674D8209FDA2A74Df4" -``` - -## subbridge_parentOperatorNonce -The `subbridge_parentOperatorNonce` returns the nonce of the parent operator account address. - -**Parameters** - -none - -**Return Value** - -| Type | Description | -| --- | --- | -| QUANTITY | Integer of the number of transactions sent from the parent operator account. | - -**Example** - -```javascript -> subbridge.parentOperatorNonce -1348 -``` - -## subbridge_childOperatorNonce -The `subbridge_childOperator` returns the child operator account address. - -**Parameters** - -none - -**Return Value** - -| Type | Description | -| --- | --- | -| QUANTITY | Integer of the number of transactions sent from the child operator account. | - -**Example** - -```javascript -> subbridge.childOperatorNonce -1024 -``` - -## subbridge_parentOperatorBalance -The `subbridge_parentOperatorBalance` returns the balance of the parent operator account. - -**Parameters** - -none - -**Return Value** - -| Type | Description | -| --- | --- | -| QUANTITY | Integer of the current balance of the parent operator account. | - -**Example** - -```javascript -> subbridge.parentOperatorBalance -1e+50 -``` - -## subbridge_childOperatorBalance -The `subbridge_childOperatorBalance` returns the balance of the child operator account. - -**Parameters** - -none - -**Return Value** - -| Type | Description | -| --- | --- | -| QUANTITY | Integer of the current balance of the child operator account. | - -**Example** - -```javascript -> subbridge.childOperatorBalance -1e+50 -``` - - - -## subbridge_sendChainTxslimit - -The `sendChainTxslimit` gets the maximum number of pending transactions to pick up for sending at once. - -**Parameters** - -None - -**Return Value** - -| Type | Description | -| ------ | ------------------------------------ | -| Uint64 | the maximum number of pending transactions to pickup for sending at once. | - -**Example** - -```javascript -> subbridge.sendChainTxslimit -100 -``` - -## subbridge_anchoring -The `subbridge_anchoring` can enable/disable the anchoring feature of the service chain. - -**Parameters** - -| Name | Type | Description | -| --- | --- | --- | -| enable | Bool | `true` enables the anchoring feature, `false` disables it.| - -**Return Value** - -| Type | Description | -| --- | --- | -| bool | `true` if the anchoring was enabled, `false` otherwise. | - -**Example** - -Console - -```javascript -> subbridge.anchoring(true) -true -> subbridge.anchoring(false) -false -``` - -HTTP RPC - -```shell -$ curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"subbridge_anchoring","params":[true],"id":1}' https://public-en-baobab.klaytn.net -{"jsonrpc":"2.0","id":1,"result":true} -$ curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"subbridge_anchoring","params":[false],"id":1}' https://public-en-baobab.klaytn.net -{"jsonrpc":"2.0","id":1,"result":false} -``` - -## subbridge_latestAnchoredBlockNumber -The `subbridge_latestAnchoredBlockNumber` returns the latest anchored block number of the service chain. - -**Parameters** - -None - -**Return Value** - -| Type | Description | -| --- | --- | -| Uint64 | The latest anchored block number. | - -**Example** - -```javascript -> subbridge.latestAnchoredBlockNumber -71025 -``` - -## subbridge_getReceiptFromParentChain -The `subbridge_getReceiptFromParentChain` returns the receipt of the anchoring transaction. - -**Parameters** - -| Type | Description | -| ------ | ------------------------------------ | -| 32-byte DATA | The child chain block hash that was included the anchoring tx hash. | - - -**Return Value** - -`Object` - A transaction receipt object, or `null` when no receipt was found. - -| Name | Type | Description | -| --- | --- | --- | -| contractAddress | DATA | The contract address created, if the transaction was a contract creation, otherwise `null`. (will be deprecated) | -| gasUsed | QUANTITY | The amount of gas used by this specific transaction alone. | -| logs | Array | Array of log objects, which this transaction generated. | -| logsBloom | 256-byte DATA | Bloom filter for light clients to quickly retrieve related logs. | -| status | QUANTITY | Either `1` (success) or `0` (failure). | -| transactionHash | 32-byte DATA | Hash of the transaction. | - -**Example** - -```javascript -> subbridge.getReceiptFromParentChain("0x4f300d6574e71d7940c88fe08f27d9ac45cbc7b81d45c17e848d3772f64377b5") -{ - contractAddress: "0x0000000000000000000000000000000000000000", - gasUsed: "0x9470", - logs: [], - logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - status: "0x1", - transactionHash: "0x3641f52359f44ef2a9941ea840aed4befbace5cac28d5cc8cacd94eae211fd1e" -} -``` - -## subbridge_deployBridge -The `subbridge_deployBridge` deploys a bridge contract to the parent and child chains and returns the addresses of deployed bridge contracts. This method also registers the bridge contracts with the sub-bridge. - -**Parameters** - -none - -**Return Value** - -| Name | Type | Description | -| --- | --- | --- | -| account | 20-byte DATA | Address of bridge contract on child chain. | -| account | 20-byte DATA | Address of bridge contract on parent chain. | - -**Example** - -```javascript -> subbridge.deployBridge() -["0x87d6b9c567e5b84cd00e03bfbe6d20d88209c33a", "0x23dab942822021bbd6d551ef51003208924877e4"] -``` - -## subbridge_registerBridge -The `subbridge_registerBridge` registers already deployed bridge contracts in the parent and child chains. - -**Parameters** - -| Name | Type | Description | -| --- | --- | --- | -| account | 20-byte DATA | Address of bridge contract on child chain. | -| account | 20-byte DATA | Address of bridge contract on parent chain. | - -**Return Value** - -| Name | Type | Description | -| --- | --- | --- | -| error | Error | `null` if the registration succeeds, Error object otherwise. | - -**Example** - -```javascript -> subbridge.registerBridge("0x87d6b9c567e5b84cd00e03bfbe6d20d88209c33a", "0x23dab942822021bbd6d551ef51003208924877e4") -null - -> subbridge.registerBridge("0x87d6b9c567e5b84cd00e03bfbe6d20d88209c33a", "0x23dab942822021bbd6d551ef51003208924877e4") -Error: bridge already exists -``` - -## subbridge_deregisterBridge -The `subbridge.deregisterBridge` deregisters already registered bridge contracts in the parent/child chain. - -**Parameters** - -| Name | Type | Description | -| --- | --- | --- | -| account | 20-byte DATA | Address of bridge contract on child chain. | -| account | 20-byte DATA | Address of bridge contract on parent chain. | - -**Return Value** - -| Name | Type | Description | -| --- | --- | --- | -| error | Error | `null` if the deregistration succeeds, Error object otherwise. | - -**Example** - -```javascript -> subbridge.deregisterBridge("0x87d6b9c567e5b84cd00e03bfbe6d20d88209c33a", "0x23dab942822021bbd6d551ef51003208924877e4") -null - -> subbridge.deregisterBridge("0x87d6b9c567e5b84cd00e03bfbe6d20d88209c33a", "0x23dab942822021bbd6d551ef51003208924877e4") -Error: invalid bridge pair -``` - -## subbridge_subscribeBridge -The `subbridge_subscribeBridge` subscribes to the registered bridge contracts in the parent and child chains. -If the sub-bridge node is subscribed to the bridge contract pair, cross-chain value-transfer requests are handled automatically by the sub-bridge. - -**Parameters** - -| Name | Type | Description | -| --- | --- | --- | -| account | 20-byte DATA | Address of bridge contract on child chain. | -| account | 20-byte DATA | Address of bridge contract on parent chain. | - -**Return Value** - -| Name | Type | Description | -| --- | --- | --- | -| error | Error | `null` if the subscribing succeeds, Error object otherwise. | - -**Example** - -```javascript -> subbridge.subscribeBridge("0x87d6b9c567e5b84cd00e03bfbe6d20d88209c33a", "0x23dab942822021bbd6d551ef51003208924877e4") -null -> subbridge.subscribeBridge("0x87d6b9c567e5b84cd00e03bfbe6d20d88209c33a", "0x23dab942822021bbd6d551ef51003208924877e4") -Error: already subscribed -``` - -## subbridge_unsubscribeBridge -The `subbridge_unsubscribeBridge` unsubscribes the sub-bridge from the bridge contracts in the parent and child chains. -If the sub-bridge is unsubscribed from the bridge contracts, cross-chain value transfer requests can not be handled by the sub-bridge. - -**Parameters** - -| Name | Type | Description | -| --- | --- | --- | -| account | 20-byte DATA | Address of bridge contract on child chain. | -| account | 20-byte DATA | Address of bridge contract on parent chain. | - -**Return Value** - -| Name | Type | Description | -| --- | --- | --- | -| error | Error | `null` if the unsubscribing succeeds, Error object otherwise. | - -**Example** - -```javascript -> subbridge.unsubscribeBridge("0x87d6b9c567e5b84cd00e03bfbe6d20d88209c33a", "0x23dab942822021bbd6d551ef51003208924877e4") -null -``` - -## subbridge_registerToken -The `subbridge_registerToken` registers a pair of ERC-20 or 721 tokens with the bridge contracts. - -**Parameters** - -| Name | Type | Description | -| --- | --- | --- | -| account | 20-byte DATA | Address of bridge contract on child chain. | -| account | 20-byte DATA | Address of bridge contract on parent chain. | -| account | 20-byte DATA | Address of token contract on child chain. | -| account | 20-byte DATA | Address of token contract on parent chain. | - -**Return Value** - -| Name | Type | Description | -| --- | --- | --- | -| error | Error | `null` if the registration succeeds, Error object otherwise. | - -**Example** - -```javascript -> subbridge.registerToken("0x87d6b9c567e5b84cd00e03bfbe6d20d88209c33a", "0x23dab942822021bbd6d551ef51003208924877e4","0xA4b0c6e12346426a09FaD70dAE0651E6Dbdd5198","0x865Cca53828C91663BFf0Ca9808827Bac552BAec") -null -> subbridge.registerToken("0x87d6b9c567e5b84cd00e03bfbe6d20d88209c33a", "0x23dab942822021bbd6d551ef51003208924877e4","0xA4b0c6e12346426a09FaD70dAE0651E6Dbdd5198","0x865Cca53828C91663BFf0Ca9808827Bac552BAec") -Error: token already exists -``` - -## subbridge_deregisterToken -The `subbridge_deregisterBridge` deregisters already registered token pair from the bridge contracts. - -**Parameters** - -| Name | Type | Description | -| --- | --- | --- | -| account | 20-byte DATA | Address of bridge contract on child chain. | -| account | 20-byte DATA | Address of bridge contract on parent chain. | -| account | 20-byte DATA | Address of token contract on child chain. | -| account | 20-byte DATA | Address of token contract on parent chain. | - -**Return Value** - -| Name | Type | Description | -| --- | --- | --- | -| error | Error | `null` if the deregistration succeeds, Error object otherwise. | - -**Example** - -```javascript -> subbridge.deregisterToken("0x87d6b9c567e5b84cd00e03bfbe6d20d88209c33a", "0x23dab942822021bbd6d551ef51003208924877e4","0xA4b0c6e12346426a09FaD70dAE0651E6Dbdd5198","0x865Cca53828C91663BFf0Ca9808827Bac552BAec") -null -> subbridge.deregisterToken("0x87d6b9c567e5b84cd00e03bfbe6d20d88209c33a", "0x23dab942822021bbd6d551ef51003208924877e4","0xA4b0c6e12346426a09FaD70dAE0651E6Dbdd5198","0x865Cca53828C91663BFf0Ca9808827Bac552BAec") -Error: invalid token pair -``` - -## subbridge_convertRequestTxHashToHandleTxHash -The `subbridge_convertRequestTxHashToHandleTxHash` returns the corresponding "handle value transfer transaction" hash in the opposite chain for the given "request value transfer transaction" hash. -"Request value transfer transaction" is a transaction initiated by a user, requesting a cross-chain value transfer. -"Handle value transfer transaction" is the transaction created by the sub-bridge to handle the value transfer request from the user. - -**Parameters** - -| Name | Type | Description | -| --- | --- | --- | -| Hash | 32-byte DATA | Hash of a "request value transfer" transaction. | - - -**Return Value** - -| Name | Type | Description | -| --- | --- | --- | -| Hash | 32-byte DATA | Hash of a "handle value transfer" transaction. zero hash means there is no corresponding "handle value transfer" transaction. | - - -**Example** - -```javascript -> subbridge.convertRequestTxHashToHandleTxHash("0xae5604f8673098436ee4eaf1b453f1a395afccd6e8eb674c60edd63ebb047622") -"0x97493d1a91d65c149763209be6535efdacf8f1b50c99daa22abf06502010b2ee" -> subbridge.convertRequestTxHashToHandleTxHash("0xc585cfd1e7047b4faae69e62e77db192d8a339701b40d6ab4adb58453b934bec") -"0x0000000000000000000000000000000000000000000000000000000000000000" -``` - -## subbridge_listBridge -The `subbridge_listBridge` returns the list of all bridge contract pairs that are registered (stored) in the sub-bridge. - -**Parameters** - -nonce - -**Return Value** - -| Name | Type | Description | -| --- | --- | --- | -| localAddress | account | 20-byte DATA | Address of the bridge contract on child (service) chain. | -| localAddress | account | 20-byte DATA | Address of the bridge contract on parent (main) chain. | -| subscribed | bool | `true` if the pair of bridge contracts is subscribed, `false` otherwise. | - -**Example** - -```javascript -> subbridge.listBridge -[{ - localAddress: "0x27caeba831d98b5fbb1d81ce0ed20801702f443a", - remoteAddress: "0x22c41ae528627b790233d2e59ea520be12350eb5", - subscribed: true -}, { - localAddress: "0x376b72abe1b29cace831bd3f5acdfa967814c9cd", - remoteAddress: "0x53160735f7cc6ff75e48619f368bb94daff66a1b", - subscribed: false -}, { - localAddress: "0x87d6b9c567e5b84cd00e03bfbe6d20d88209c33a", - remoteAddress: "0x23dab942822021bbd6d551ef51003208924877e4", - subscribed: false -}] -``` - -## subbridge_getBridgeInformation -The `subbridge_getBridgeInformation` returns the information of the given bridge contract. - -**Parameters** - -| Name | Type | Description | -| --- | --- | --- | -| account | 20-byte DATA | Address of a bridge contract | - - -**Return Value** - -| Name | Type | Description | -| --- | --- | --- | -| counterPart | 20-byte DATA | Address of the counterpart bridge contract. (Not supported yet) | -| isRunning | bool | `true` if the bridge contract is running, `false` otherwise. | -| isSubscribed | bool | `true` if the bridge contract is subscribed, `false` otherwise. | -| onServiceChain | bool | `true` if the bridge contact is on child (service) chain, `false` otherwise. | -| pendingEventSize | QUANTITY | Number of pending "request value transfer" events generated by the bridge contracts, not handled yet by the sub-bridge. | -| requestNonce | QUANTITY | Request nonce of the bridge contract. | -| handleNonce | QUANTITY | Upper handle nonce of the bridge contract. | -| lowerHandleNonce | QUANTITY | Lower handle nonce of the bridge contract. | - - -**Example** - -```javascript -> subbridge.getBridgeInformation("0x27caeba831d98b5fbb1d81ce0ed20801702f443a") -{ - counterPart: "0x0000000000000000000000000000000000000000", - handleNonce: 0, - lowerHandleNonce: 0, - isRunning: true, - isSubscribed: true, - onServiceChain: true, - pendingEventSize: 0, - requestNonce: 0 -} -``` - -## subbridge_txPendingCount -The `subbridge_txPendingCount` returns the number of pending transactions in the bridge transaction pool. - -**Parameters** - -None - -**Return Value** - -| Type | Description | -| --- | --- | -| Uint64 | The number of pending transactions in the bridge transaction pool. | - -**Example** - -```javascript -> subbridge.txPendingCount -2 -``` - -## subbridge_txPending -The `subbridge_txPending` returns the list of pending transactions in the bridge transaction pool. - -**Parameters** - -None - -**Return Value** - -| Type | Description | -| --- | --- | -| JSON string | List of pending transactions in the bridge transaction pool. | - -**Example** - -```javascript -> subbridge.txPending -{ - 0xa057995175b93ee0d1bdfa54f078ad0f0116130b: [{ - from: "0xa057995175b93ee0d1bdfa54f078ad0f0116130b", - gas: "0x186a0", - gasPrice: "0x5d21dba00", - hash: "0x284c8f5bc82ef987c3a14fc8dac7933beb528777745987ff790014441f26ca03", - input: "0xf8a9a063f41a6ec8e2f8074c30fccf11f2b8479e7ebd8a0e5aa0c171623bc1f3812e33a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a0f845557d8dc2175974f29c2e9d12b1a57f634acaafdf56ae7033201a0796bedea056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a09109530b191b47ca3d91012faba70fcf307f13b030f19d932cab38f2c1ece7b78304157c", - nonce: "0x41589", - signatures: [{...}], - type: "TxTypeChainDataAnchoring", - typeInt: 72 - }, { - from: "0xa057995175b93ee0d1bdfa54f078ad0f0116130b", - gas: "0x186a0", - gasPrice: "0x5d21dba00", - hash: "0x4dd093916a419608091da28b5d7ffc6e34d894ddaac96328f1904bfef93a4ad0", - input: "0xf8a9a05b0dd6cc938916e37b17b602690399987b4e8540a14a494626d85e947f721a10a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a063f41a6ec8e2f8074c30fccf11f2b8479e7ebd8a0e5aa0c171623bc1f3812e33a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a09109530b191b47ca3d91012faba70fcf307f13b030f19d932cab38f2c1ece7b78304157d", - nonce: "0x4158a", - signatures: [{...}], - type: "TxTypeChainDataAnchoring", - typeInt: 72 - }] -} -``` - diff --git a/sidebars.js b/sidebars.js index 3de5b740921..6ab2b429a82 100644 --- a/sidebars.js +++ b/sidebars.js @@ -434,15 +434,6 @@ const sidebars = { require("./web3rpc/web3rpc-sidebar").subbridgeSidebarFormatted, ], }, - { - type: 'category', - label: 'Service Chain API Reference', - link: {type: 'doc', id: 'references/service-chain-api/service-chain-api'}, - items: [ - 'references/service-chain-api/mainbridge', - 'references/service-chain-api/subbridge', - ], - }, 'references/transaction-error-codes', { type: 'category', diff --git a/web3rpc/web3rpc-sidebar.js b/web3rpc/web3rpc-sidebar.js index 758d5a3eb6d..d55bb028136 100644 --- a/web3rpc/web3rpc-sidebar.js +++ b/web3rpc/web3rpc-sidebar.js @@ -11,6 +11,7 @@ const subbridgeSidebar = require("../docs/references/json-rpc/subbridge/sidebar. // Function to find the common prefix of labels const findCommonLabelPrefix = (sidebar, categories) => { + if (categories === undefined) return categories categories.map(category => { let parentCategory = {} category.items.map(item => {