Somnia 백서

Somnia

원문

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 54쪽 중 4쪽

0x1"} ``` *** #### `eth_getBlockTransactionCountByHash` Returns the number of transactions in a block by hash. * **Parameters:** `blockHash` * **Returns:** `quantity` (uint64) * **Compatibility:** [EIP-1474](https://eips.ethereum.org/EIPS/eip-1474), [ethereum.org](https://ethereum.org/developers/docs/apis/json-rpc/#eth_getblocktransactioncountbyhash) ```bash curl -s -X POST $RPC_URL \ -H "Content-Type: application/json" \ -d '{ "jsonrpc":"2.0", "method":"eth_getBlockTransactionCountByHash", "params":["0x761fdbb98eb904196b6be98870b222fc2f06d2fdac4bae1200f177092ce6ec98"], "id":1 }' ``` ```json {"jsonrpc":"2.0","id":1,"result":"0x1"} ``` *** <br> ### Logs & Filters #### `eth_getLogs` Returns logs matching a filter. The block range must not exceed 1000 blocks. * **Parameters:** filter object with optional fields `fromBlock`, `toBlock`, `address`, `topics`, `blockHash` * **Returns:** [`Log`](#log)`[]` * **Compatibility:** [EIP-1474](https://eips.ethereum.org/EIPS/eip-1474), [ethereum.org](https://ethereum.org/developers/docs/apis/json-rpc/#eth_getlogs) | Field | Type | Notes | | ----------- | ------------------------ | --------------------------------------------------------------------------------------------------------- | | `fromBlock` | `blockLabel` or `null` | Start of block range | | `toBlock` | `blockLabel` or `null` | End of block range | | `blockHash` | `hash` or `null` | Specific block hash | | `address` | `address` or `address[]` | Match logs from one or more contracts | | `topics` | `array` or `null` | Topic-position filters; each position may be a single hash, an OR-list of hashes, or `null` as a wildcard | ```bash curl -s -X POST $RPC_URL \ -H "Content-Type: application/json" \ -d '{ "jsonrpc":"2.0", "method":"eth_getLogs", "params":[{ "fromBlock": "0xfebbe5e", "toBlock": "0xfebbe5e" }], "id":1 }' ``` ```json { "jsonrpc": "2.0", "id": 1, "result": [ { "address": "0x2a48aa2986e4bdabfae1c7366c72168cf4772f56", "topics": [ "0xb33ea778dc37bc968fc39ed9c7bb9d2d265850bfb8dcaaaea7987640fe0fa956", "0x000000000000000000000000000000000000000000000000000000000000002e", "0x000000000000000000000000db1b9390cfae98af059d6c38c987dedc86081da1" ], "data": "0x0000000000000000000000000000000000000000000000000000000000008477", "blockNumber": "0x147df45d", "transactionHash": "0x659acd064a5f391d779dd8d778f4eae10cf6d9caa8948e17f8065c12ef6f7b5d", "transactionIndex": "0x0", "blockHash": "0xdbcabc2fc754288ec00dcd5b69c65033142f202c8cad21b563f778f88c9f7526", "logIndex": "0x0" } ] } ``` *** #### `eth_newFilter` Creates a log filter. Returns a filter ID. The block range must not exceed 1000 blocks. * **Parameters:** filter object with optional fields `fromBlock`, `toBlock`, `address`, `topics` * **Returns:** `quantity` (filter id) * **Compatibility:** [EIP-1474](https://eips.ethereum.org/EIPS/eip-1474), [ethereum.org](https://ethereum.org/developers/docs/apis/json-rpc/#eth_newfilter) | Field | Type | Notes | | ----------- | ------------------------ | --------------------------------------------------------------------------------------------------------- | | `fromBlock` | `blockLabel` or `null` | Start of block range | | `toBlock` | `blockLabel` or `null` | End of block range | | `address` | `address` or `address[]` | Match logs from one or more contracts | | `topics` | `array` or `null` | Topic-position filters; each position may be a single hash, an OR-list of hashes, or `null` as a wildcard | ```bash curl -s -X POST $RPC_URL \ -H "Content-Type: application/json" \ -d '{ "jsonrpc":"2.0", "method":"eth_newFilter", "params":[{"fromBlock":"latest","toBlock":"latest"}], "id":1 }' ``` ```json {"jsonrpc":"2.0","id":1,"result":"0x1517573b"} ``` *** #### `eth_newBlockFilter` Creates a filter that returns new block hashes. * **Parameters:** *(none)* * **Returns:** `quantity` (filter id) * **Compatibility:** [EIP-1474](https://eips.ethereum.org/EIPS/eip-1474), [ethereum.org](https://ethereum.org/developers/docs/apis/json-rpc/#eth_newblockfilter) ```bash curl -s -X POST $RPC_URL \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"eth_newBlockFilter","params":[],"id":1}' ``` ```json {"jsonrpc":"2.0","id":1,"result":"0x151730d4"} ``` *** #### `eth_newPendingTransactionFilter` Creates a filter that returns new pending transaction hashes. * **Parameters:** *(none)* * **Returns:** `quantity` (filter id) * **Compatibility:** [EIP-1474](https://eips.ethereum.org/EIPS/eip-1474), [ethereum.org](https://ethereum.org/developers/docs/apis/json-rpc/#eth_newpendingtransactionfilter) ```bash curl -s -X POST $RPC_URL \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"eth_newPendingTransactionFilter","params":[],"id":1}' ``` ```json {"jsonrpc":"2.0","id":1,"result":"0x151730f3"} ``` *** #### `eth_getFilterChanges` Polls a filter for new results since the last poll. Response format depends on filter type: block hashes for block filters, tx hashes for pending tx filters, log objects for log filters. * **Parameters:** `filterId` (hex) * **Returns:** `json` (varies by filter type) * **Compatibility:** [EIP-1474](https://eips.ethereum.org/EIPS/eip-1474), [ethereum.org](https://ethereum.org/developers/docs/apis/json-rpc/#eth_getfilterchanges) ```bash curl -s -X POST $RPC_URL \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"eth_getFilterChanges","params":["0x151730d4"],"id":1}' ``` ```json { "jsonrpc": "2.0", "id": 1, "result": [ "0x96fe2ad8067123d10ab4e618fd18316b95990e98c3cf914e835878d9d998167a", "0x27b347f204beeb9d06d9ae96483070f609cd863b37a34b3bc7b6e5589b4e93bc", "0xfafb5f1ecf15e169878fe83adb56bcf6041dc41fa186396e3f5a9f332c0956ea" ] } ``` *** #### `eth_getFilterLogs` Returns all logs matching the filter criteria (for log filters only). * **Parameters:** `filterId` (hex) * **Returns:** [`Log`](#log)`[]` * **Compatibility:** [EIP-1474](https://eips.ethereum.org/EIPS/eip-1474), [ethereum.org](https://ethereum.org/developers/docs/apis/json-rpc/#eth_getfilterlogs) ```bash curl -s -X POST $RPC_URL \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"eth_getFilterLogs","params":["0x1517573b"],"id":1}' ``` ```json {"jsonrpc":"2.0","id":1,"result":[]} ``` *** #### `eth_uninstallFilter` Removes a filter. Returns `true` if the filter was found and removed. * **Parameters:** `filterId` (hex) * **Returns:** `bool` * **Compatibility:** [EIP-1474](https://eips.ethereum.org/EIPS/eip-1474), [ethereum.org](https://ethereum.org/developers/docs/apis/json-rpc/#eth_uninstallfilter) ```bash curl -s -X POST $RPC_URL \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"eth_uninstallFilter","params":["0x1517573b"],"id":1}' ``` ```json {"jsonrpc":"2.0","id":1,"result":true} ``` > **Note:** Filter IDs are connection-scoped. On load-balanced public endpoints, the filter may be on a different backend than the uninstall request, causing `false` returns. For reliable filter usage, use a persistent WebSocket connection or a dedicated RPC endpoint. *** <br> ### Subscriptions #### `eth_subscribe` Creates a subscription. Supported subscription types: * `"newHeads"` -- new block headers * `"logs"` -- log events matching a filter * `"somnia_finishedTransactions"` -- completed transaction receipts (Somnia-specific) * `"somnia_finishedBlocks"` -- completed blocks (Somnia-specific) * `"somnia_watch"` -- log events with watch semantics (Somnia-specific) **Properties:** * **Parameters:** `subscriptionType`, optional params object (see [Subscription Schemas](#subscription-schemas)) * **Returns:** `quantity` (subscription id) * **Compatibility:** [Geth](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-eth#eth-subscribe-unsubscribe) * WebSocket only * This method emits events, so requires a **WebSocket** connection. Over HTTP it returns `events_not_supported`. [`eth_unsubscribe`](#eth_unsubscribe) works over both HTTP and WebSocket. ``` wscat -c wss://api.infra.testnet.somnia.network/ws > {"jsonrpc":"2.0","method":"eth_subscribe","params":["newHeads"],"id":1} < {"jsonrpc":"2.0","id":1,"result":"0x1"} < {"jsonrpc":"2.0","method":"eth_subscription","params":{"subscription":"0x1","result":{...block header...}}} ``` Over HTTP, this returns: ```json {"jsonrpc":"2.0","id":1,"error":{"code":-1,"message":"events_not_supported","data":null}} ``` *** #### `eth_unsubscribe` Cancels a subscription. Returns `true` if the subscription was found and removed, `false` otherwise. Subscription IDs are connection-scoped, so this must be called from the same connection that created the subscription. * **Parameters:** `subscriptionId` (hex) * **Returns:** `bool` * **Compatibility:** [Geth](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-eth#eth-subscribe-unsubscribe) ```bash curl -s -X POST $RPC_URL \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"eth_unsubscribe","params":["0x1"],"id":1}' ``` ```json {"jsonrpc":"2.0","id":1,"result":false} ``` *** <br> ### Gas & Fees #### `eth_gasPrice` Returns the current gas price in wei. * **Parameters:** *(none)* * **Returns:** `quantity` (uint256) * **Compatibility:** [EIP-1474](https://eips.ethereum.org/EIPS/eip-1474), [ethereum.org](https://ethereum.org/developers/docs/apis/json-rpc/#eth_gasprice), [execution-apis](https://ethereum.github.io/execution-apis/api/methods/eth_gasPrice) ```bash curl -s -X POST $RPC_URL \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"eth_gasPrice","params":[],"id":1}' ``` ```json {"jsonrpc":"2.0","id":1,"result":"0x165a0bc00"} ``` *** #### `eth_maxPriorityFeePerGas` Returns the current max priority fee per gas (tip) in wei. * **Parameters:** *(none)* * **Returns:** `quantity` (uint256) * **Compatibility:** [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559), [execution-apis](https://ethereum.github.io/execution-apis/api/methods/eth_maxPriorityFeePerGas) ```bash curl -s -X POST $RPC_URL \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"eth_maxPriorityFeePerGas","params":[],"id":1}' ``` ```json {"jsonrpc":"2.0","id":1,"result":"0x0"} ``` *** #### `eth_feeHistory` Returns historical gas fee data. * **Parameters:** `blockCount` (hex), `newestBlock` (hex or label), `rewardPercentiles` (array of floats) * **Returns:** json object * **Compatibility:** [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559), [execution-apis](https://ethereum.github.io/execution-apis/api/methods/eth_feeHistory) ```bash curl -s -X POST $RPC_URL \ -H "Content-Type: application/json" \ -d '{ "jsonrpc":"2.0", "method":"eth_feeHistory", "params":["0x4", "latest", [25, 75]], "id":1 }' ``` ```json { "jsonrpc": "2.0", "id": 1, "result": { "oldestBlock": "0xff78371", "baseFeePerGas": ["0x165a0bc00", "0x165a0bc00", "0x165a0bc00", "0x165a0bc00"], "baseFeePerBlobGas": ["0x0", "0x0", "0x0", "0x0"], "gasUsedRatio": [0, 0, 0, 0], "blobGasUsedRatio": [0, 0, 0, 0], "reward": [["0x0", "0x0"], ["0x0", "0x0"], ["0x0", "0x0"], ["0x0", "0x0"]] } } ``` *** #### `eth_call` Executes a call without creating a transaction (read-only simulation). * **Parameters:** [`TransactionRequest`](#transactionrequest), `blockLabelOrHash`, optional [`StateOverrideSet`](#stateoverrideset) (see [Request Schemas](#request-schemas)) * **Returns:** `bytes` (hex) * **Compatibility:** [EIP-1474](https://eips.ethereum.org/EIPS/eip-1474), [ethereum.org](https://ethereum.org/developers/docs/apis/json-rpc/#eth_call) * Requires node to be [ready](#requires-node-ready) ```bash curl -s -X POST $RPC_URL \ -H "Content-Type: application/json" \ -d '{ "jsonrpc":"2.0", "method":"eth_call", "params":[{ "to": "0x28bec7e30e6faee657a03e19bf1128aad7632a00", "data": "0x18160ddd" }, "0x107c14af"], "id":1 }' ``` ```json {"jsonrpc":"2.0","id":1,"result":"0x000000000000000000000000000000000000000000000000000000c11b9b1648"} ``` *** #### `eth_estimateGas` Estimates the gas required for a transaction. * **Parameters:** [`TransactionRequest`](#transactionrequest), optional `blockLabel`, optional [`StateOverrideSet`](#stateoverrideset) (see [Request Schemas](#request-schemas)) * **Returns:** `quantity` (uint64) * **Compatibility:** [EIP-1474](https://eips.ethereum.org/EIPS/eip-1474), [ethereum.org](https://ethereum.org/developers/docs/apis/json-rpc/#eth_estimategas) * Requires node to be [ready](#requires-node-ready) ```bash curl -s -X POST $RPC_URL \ -H "Content-Type: application/json" \ -d '{ "jsonrpc":"2.0", "method":"eth_estimateGas", "params":[{ "from": "0xc04ea345ac1aded81ea4b3bd7ada1f7638e63e66", "to": "0x1909cdb9524d065e5751d2fe79e2b9ad54d822e6", "value": "0x0" }], "id":1 }' ``` ```json {"jsonrpc":"2.0","id":1,"result":"0x5208"} ``` *** #### `eth_createAccessList` Returns an empty EIP-2930 access list plus the estimated gas for a transaction. (Somnia doesn't support access lists.) * **Parameters:** [`TransactionRequest`](#transactionrequest), optional `blockLabel` (see [Request Schemas](#request-schemas)) * **Returns:** `[accessList, gasUsed]` (JSON array) * **Compatibility:** [EIP-2930](https://eips.ethereum.org/EIPS/eip-2930), [execution-APIs](https://ethereum.github.io/execution-apis/api/methods/eth_createAccessList) * Requires node to be [ready](#requires-node-ready) ```bash curl -s -X POST $RPC_URL \ -H "Content-Type: application/json" \ -d '{ "jsonrpc":"2.0", "method":"eth_createAccessList", "params":[{ "from": "0xc04ea345ac1aded81ea4b3bd7ada1f7638e63e66", "to": "0x1909cdb9524d065e5751d2fe79e2b9ad54d822e6", "value": "0x0" }], "id":1 }' ``` ```json {"jsonrpc":"2.0","id":1,"result":[[],"0x7b0c"]} ``` *** <br> ### Debug / Tracing #### `debug_traceCall` Traces a call execution with a specified tracer. * **Parameters:** [`TransactionRequest`](#transactionrequest), `blockLabelOrHash`, trace config (`tracer`, `tracerConfig`, `stateOverrides`) (see [Request Schemas](#request-schemas)) * **Returns:** trace output * **Compatibility:** [Geth](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-debug#debugtracecall) * Requires node to be [ready](#requires-node-ready) ```bash curl -s -X POST $RPC_URL \ -H "Content-Type: application/json" \ -d '{ "jsonrpc":"2.0", "method":"debug_traceCall", "params":[{ "from": "0xc04ea345ac1aded81ea4b3bd7ada1f7638e63e66", "to": "0x1909cdb9524d065e5751d2fe79e2b9ad54d822e6", "value": "0x1" }, "latest", {"tracer": "callTracer"}], "id":1 }' ``` ```json { "jsonrpc": "2.0", "id": 1, "result": { "type": "CALL", "from": "0xc04ea345ac1aded81ea4b3bd7ada1f7638e63e66", "gas": "0x3b9a77f8", "gasUsed": "0x5208", "to": "0x1909cdb9524d065e5751d2fe79e2b9ad54d822e6", "input": "0x", "output": "0x", "error": "INSUFFICIENT_BALANCE", "revertReason": null, "value": "0x1", "logs": [], "calls": [] } } ``` *** #### `debug_traceTransaction` Traces an already-mined transaction. * **Parameters:** `txHash`, tracer config (`tracer`, `tracerConfig`) * **Returns:** trace output * **Compatibility:** [Geth](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-debug#debugtracetransaction) * Requires node to be [ready](#requires-node-ready) ```bash curl -s -X POST $RPC_URL \ -H "Content-Type: application/json" \ -d '{ "jsonrpc":"2.0", "method":"debug_traceTransaction", "params":[ "0xe37a5053ed983747d65a782a4924e2a894729a0cbcbbf012ea6267870a99df53", {"tracer": "callTracer"} ], "id":1 }' ``` ```json { "jsonrpc": "2.0", "id": 1, "result": { "type": "CALL", "from": "0xc04ea345ac1aded81ea4b3bd7ada1f7638e63e66", "gas": "0x0", "gasUsed": "0x5208", "to": "0x1909cdb9524d065e5751d2fe79e2b9ad54d822e6", "input": "0x", "output": "0x", "error": null, "revertReason": null, "value": "0x29a0cc50fa726000", "logs": [], "calls": [] } } ``` *** #### `debug_traceBlockByNumber` Traces all transactions in a block by block number. * **Parameters:** `blockLabel` (hex or label), tracer config * **Returns:** `{txHash, result | null, error | null}[]` * **Compatibility:** [Geth](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-debug#debugtraceblockbynumber) * Requires node to be [ready](#requires-node-ready) > **Supported tracers:** `"callTracer"` (with optional `{"onlyTopCall": true}`), `"prestateTracer"` (with optional `{"diffMode": true}`) ```bash curl -s -X POST $RPC_URL \ -H "Content-Type: application/json" \ -d '{ "jsonrpc":"2.0", "method":"debug_traceBlockByNumber", "params":["0xfebbe5e", {"tracer": "callTracer"}], "id":1 }' ``` ```json { "jsonrpc": "2.0", "id": 1, "result": [ { "txHash": "0xe37a5053ed983747d65a782a4924e2a894729a0cbcbbf012ea6267870a99df53", "result": { "type": "CALL", "from": "0xc04ea345ac1aded81ea4b3bd7ada1f7638e63e66", "gas": "0x0", "gasUsed": "0x5208", "to": "0x1909cdb9524d065e5751d2fe79e2b9ad54d822e6", "input": "0x", "output": "0x", "error": null, "revertReason": null, "value": "0x29a0cc50fa726000", "logs": [], "calls": [] }, "error": null } ] } ``` *** #### `debug_traceBlockByHash` Traces all transactions in a block by block hash. * **Parameters:** `blockHash`, tracer config * **Returns:** `{txHash, result | null, error | null}[]` * **Compatibility:** [Geth](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-debug#debugtraceblockbyhash) * Requires node to be [ready](#requires-node-ready) > **Supported tracers:** `"callTracer"` (with optional `{"onlyTopCall": true}`), `"prestateTracer"` (with optional `{"diffMode": true}`) ```bash curl -s -X POST $RPC_URL \ -H "Content-Type: application/json" \ -d '{ "jsonrpc":"2.0", "method":"debug_traceBlockByHash", "params":[ "0x761fdbb98eb904196b6be98870b222fc2f06d2fdac4bae1200f177092ce6ec98", {"tracer": "callTracer"} ], "id":1 }' ``` Response format is identical to [`debug_traceBlockByHash`](#debug_traceblockbyhash) above. *** <br> ### Somnia-Specific #### `somnia_isReady` Returns `true` if the node is synced and ready to process requests. * **Parameters:** *(none)* * **Returns:** `bool` * **Compatibility:** **Somnia-specific** ```bash curl -s -X POST $RPC_URL \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"somnia_isReady","params":[],"id":1}' ``` ```json {"jsonrpc":"2.0","id":1,"result":true} ``` *** #### `somnia_isReadyWithErrorCode` Like [`somnia_isReady`](#somnia_isready), but returns an RPC error (code -32603) instead of `false` when the node is not ready. * **Parameters:** *(none)* * **Returns:** `bool` (error code on failure) * **Compatibility:** **Somnia-specific** ```bash curl -s -X POST $RPC_URL \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"somnia_isReadyWithErrorCode","params":[],"id":1}' ``` ```json {"jsonrpc":"2.0","id":1,"result":true} ``` *** #### `somnia_nodePublicKeys` Returns the node's public keys for the current epoch. * **Parameters:** *(none)* * **Returns:** json object * **Compatibility:** **Somnia-specific** ```bash curl -s -X POST $RPC_URL \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"somnia_nodePublicKeys","params":[],"id":1}' ``` ```json { "jsonrpc": "2.0", "id": 1, "result": { "address": "0x53ee336e74e41250b1420d102fa35d3ac49c8928", "ecdsa_public_key": "0x024683678905b871ce02faf8af763033fea59dfc70f52df8ecb979b4e373abb638", "bls_public_key": "0x135dc21ad1326f464b458078408574a7adf3a570697715cbf68b28e817d69380...", "bls_proof_of_possession": "0xa14f7c8b...", "proof_of_address": "0x91c4c5be..." } } ``` *** #### `somnia_getBlockByNumber` Returns Somnia's native block representation (consensus + execution blocks), which contains more detail than the Ethereum-compatible [`eth_getBlockByNumber`](#eth_getblockbynumber). * **Parameters:** `blockLabel` (hex or label) * **Returns:** [`SomniaLedgerBlock`](#somnialedgerblock) `| null` * **Compatibility:** **Somnia-specific** -- native block format (cf. [`eth_getBlockByNumber`](#eth_getblockbynumber)) ```
프로젝트로 돌아가기