Somnia 백서

Somnia

원문

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

getsubscriptioninfo) | Somnia-specific, testnet only | | | | [somnia\_reactivityGetSubscriptions](#somnia_reactivitygetsubscriptions) | Somnia-specific, testnet only | | | | [somnia\_sendSessionTransaction](#somnia_sendsessiontransaction) | Somnia-specific | | | | [web3\_clientVersion](#web3_clientversion) | [Ethereum standard](https://ethereum.org/developers/docs/apis/json-rpc/#web3_clientversion) | | | | [web3\_sha3](#web3_sha3) | [Ethereum standard](https://ethereum.org/developers/docs/apis/json-rpc/#web3_sha3) | | | ## Methods by Category ### Network / Web3 #### `net_version` Returns the network ID. * **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/#net_version) ```bash curl -s -X POST $RPC_URL \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"net_version","params":[],"id":1}' ``` ```json {"jsonrpc":"2.0","id":1,"result":"0x13a7"} ``` > **Note:** This is currently non-conformant with the [Ethereum JSON-RPC spec](https://ethereum.github.io/execution-apis/api/methods/net_version/), which specifies that the return value is a decimal string. In future Somnia will switch to this form:<br> > > ``` > {"jsonrpc":"2.0","id":1,"result":"5031"} > ``` *** #### `net_listening` Returns `true` if the node is listening for connections. * **Parameters:** *(none)* * **Returns:** `bool` * **Compatibility:** [EIP-1474](https://eips.ethereum.org/EIPS/eip-1474), [ethereum.org](https://ethereum.org/developers/docs/apis/json-rpc/#net_listening) ```bash curl -s -X POST $RPC_URL \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"net_listening","params":[],"id":1}' ``` ```json {"jsonrpc":"2.0","id":1,"result":true} ``` *** #### `web3_clientVersion` Returns the Somnia client version string. * **Parameters:** *(none)* * **Returns:** `string` * **Compatibility:** [EIP-1474](https://eips.ethereum.org/EIPS/eip-1474), [ethereum.org](https://ethereum.org/developers/docs/apis/json-rpc/#web3_clientversion) ```bash curl -s -X POST $RPC_URL \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":1}' ``` ```json {"jsonrpc":"2.0","id":1,"result":"somnia-92fe2faf8cbcd24-release"} ``` *** #### `web3_sha3` Returns the Keccak-256 hash of the given data. * **Parameters:** `data` (hex) * **Returns:** `hash` * **Compatibility:** [EIP-1474](https://eips.ethereum.org/EIPS/eip-1474), [ethereum.org](https://ethereum.org/developers/docs/apis/json-rpc/#web3_sha3) ```bash curl -s -X POST $RPC_URL \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"web3_sha3","params":["0x68656c6c6f"],"id":1}' ``` ```json {"jsonrpc":"2.0","id":1,"result":"0x1c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8"} ``` *** <br> ### Chain State #### `eth_chainId` Returns the chain ID. * **Parameters:** *(none)* * **Returns:** `quantity` (uint256) * **Compatibility:** [EIP-695](https://eips.ethereum.org/EIPS/eip-695), [ethereum.org](https://ethereum.org/developers/docs/apis/json-rpc/#eth_chainid) ```bash curl -s -X POST $RPC_URL \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":1}' ``` ```json {"jsonrpc":"2.0","id":1,"result":"0x13a7"} ``` *** #### `eth_syncing` Returns `true` while the node is still syncing, `false` once ready. Unlike standard Ethereum clients, Somnia returns bool only -- it does not return a sync-status object. * **Parameters:** *(none)* * **Returns:** `bool` * **Compatibility:** [EIP-1474](https://eips.ethereum.org/EIPS/eip-1474), [ethereum.org](https://ethereum.org/developers/docs/apis/json-rpc/#eth_syncing) ```bash curl -s -X POST $RPC_URL \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":1}' ``` ```json {"jsonrpc":"2.0","id":1,"result":false} ``` *** #### `eth_blockNumber` Returns the latest block number. * **Parameters:** *(none)* * **Returns:** `quantity` (block number) * **Compatibility:** [EIP-1474](https://eips.ethereum.org/EIPS/eip-1474), [ethereum.org](https://ethereum.org/developers/docs/apis/json-rpc/#eth_blocknumber) ```bash curl -s -X POST $RPC_URL \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' ``` ```json {"jsonrpc":"2.0","id":1,"result":"0xff7809e"} ``` *** #### `eth_accounts` Returns the list of accounts owned by the node (empty for public RPC endpoints). * **Parameters:** *(none)* * **Returns:** `address[]` * **Compatibility:** [EIP-1474](https://eips.ethereum.org/EIPS/eip-1474), [ethereum.org](https://ethereum.org/developers/docs/apis/json-rpc/#eth_accounts) ```bash curl -s -X POST $RPC_URL \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"eth_accounts","params":[],"id":1}' ``` ```json {"jsonrpc":"2.0","id":1,"result":[]} ``` *** <br> ### Account State #### `eth_getBalance` Returns the balance of an account in wei. * **Parameters:** `address`, `blockLabel` (`"latest"`, `"earliest"`, `"pending"`, or hex block number) * **Returns:** `quantity` (uint256) * **Compatibility:** [EIP-1474](https://eips.ethereum.org/EIPS/eip-1474), [ethereum.org](https://ethereum.org/developers/docs/apis/json-rpc/#eth_getbalance) ```bash curl -s -X POST $RPC_URL \ -H "Content-Type: application/json" \ -d '{ "jsonrpc":"2.0", "method":"eth_getBalance", "params":["0x1909cdb9524d065e5751d2fe79e2b9ad54d822e6", "0xfebbe5e"], "id":1 }' ``` ```json {"jsonrpc":"2.0","id":1,"result":"0x5a957142cf2e47706c"} ``` *** #### `eth_getTransactionCount` Returns the nonce (number of transactions sent) for an account. * **Parameters:** `address`, `blockLabel` * **Returns:** `quantity` (uint64) * **Compatibility:** [EIP-1474](https://eips.ethereum.org/EIPS/eip-1474), [ethereum.org](https://ethereum.org/developers/docs/apis/json-rpc/#eth_gettransactioncount) * 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_getTransactionCount", "params":["0xc04ea345ac1aded81ea4b3bd7ada1f7638e63e66", "latest"], "id":1 }' ``` ```json {"jsonrpc":"2.0","id":1,"result":"0x12"} ``` *** #### `eth_getCode` Returns the bytecode at an address (`"0x"` for addresses without code). * **Parameters:** `address`, `blockLabel` * **Returns:** `bytes` (hex) * **Compatibility:** [EIP-1474](https://eips.ethereum.org/EIPS/eip-1474), [ethereum.org](https://ethereum.org/developers/docs/apis/json-rpc/#eth_getcode) * 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_getCode", "params":["0x4e59b44847b379578588920cA78FbF26c0B4956C", "0xfebbe5e"], "id":1 }' ``` ```json {"jsonrpc":"2.0","id":1,"result":"0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3"} ``` *** #### `eth_getStorageAt` Returns the value in a contract's storage slot. * **Parameters:** `address`, `slot` (hex uint256), `blockLabel` * **Returns:** `bytes` (hex) * **Compatibility:** [EIP-1474](https://eips.ethereum.org/EIPS/eip-1474), [ethereum.org](https://ethereum.org/developers/docs/apis/json-rpc/#eth_getstorageat) * 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_getStorageAt", "params":["0x28bec7e30e6faee657a03e19bf1128aad7632a00", "0x0", "0x107c14af"], "id":1 }' ``` ```json {"jsonrpc":"2.0","id":1,"result":"0x000000000000000000000000d6b03d71e401479cc976fc94a41a37576404e7bd"} ``` *** <br> ### Transaction Submission #### `eth_sendRawTransaction` Submits a signed transaction. Returns the transaction hash. * **Parameters:** `signedTransactionData` (hex-encoded signed tx bytes) * **Returns:** `hash` (tx id) * **Compatibility:** [EIP-1474](https://eips.ethereum.org/EIPS/eip-1474), [ethereum.org](https://ethereum.org/developers/docs/apis/json-rpc/#eth_sendrawtransaction) * 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_sendRawTransaction", "params":["0x02f8...signed_tx_bytes..."], "id":1 }' ``` ```json {"jsonrpc":"2.0","id":1,"result":"0x...transaction_hash..."} ``` > **Note:** The example above is a template. You must provide a valid signed transaction. An invalid transaction returns: `{"jsonrpc":"2.0","id":1,"error":{"code":-32000,"message":"invalid transaction","data":null}}` *** #### `realtime_sendRawTransaction` Submits a signed transaction and **waits for the receipt** before returning. Same parameters as [`eth_sendRawTransaction`](#eth_sendrawtransaction), but the response is a full transaction receipt instead of just the hash. * **Parameters:** `signedTransactionData` (hex-encoded signed tx bytes) * **Returns:** [`TransactionReceipt`](#transactionreceipt) * **Compatibility:** **Somnia-specific** -- no Ethereum equivalent * 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":"realtime_sendRawTransaction", "params":["0x02f8...signed_tx_bytes..."], "id":1 }' ``` ```json {"jsonrpc":"2.0","id":1,"result":{"transactionHash":"0x...","blockNumber":"0x...","status":"0x1",...}} ``` *** <br> ### Transaction Retrieval #### `eth_getTransactionByHash` Returns transaction details by hash, or `null` if not found. * **Parameters:** `txHash` * **Returns:** [`Transaction`](#transaction) `| null` * **Compatibility:** [EIP-1474](https://eips.ethereum.org/EIPS/eip-1474), [ethereum.org](https://ethereum.org/developers/docs/apis/json-rpc/#eth_gettransactionbyhash) ```bash curl -s -X POST $RPC_URL \ -H "Content-Type: application/json" \ -d '{ "jsonrpc":"2.0", "method":"eth_getTransactionByHash", "params":["0xe37a5053ed983747d65a782a4924e2a894729a0cbcbbf012ea6267870a99df53"], "id":1 }' ``` ```json { "jsonrpc": "2.0", "id": 1, "result": { "blockHash": "0x761fdbb98eb904196b6be98870b222fc2f06d2fdac4bae1200f177092ce6ec98", "blockNumber": "0xfebbe5e", "from": "0xc04ea345ac1aded81ea4b3bd7ada1f7638e63e66", "to": "0x1909cdb9524d065e5751d2fe79e2b9ad54d822e6", "gas": "0x5208", "gasPrice": "0x165a0bc00", "hash": "0xe37a5053ed983747d65a782a4924e2a894729a0cbcbbf012ea6267870a99df53", "input": "0x", "nonce": "0x11", "transactionIndex": "0x0", "value": "0x29a0cc50fa726000", "type": "0x2", "chainId": "0x13a7", "v": "0x0", "r": "0xf2d4bdc57a1bab8df77f9fd311390f3ec9dacb5bd61fdb56b32bd0c3003136bf", "s": "0x10283bed1b67d23c87f8d64f309f401b802e5596788b3ce10dc47ee0e4c21fa4", "maxPriorityFeePerGas": "0x165a0bc00", "maxFeePerGas": "0x165a0bc00" } } ``` *** #### `eth_getTransactionByBlockHashAndIndex` Returns a transaction by block hash and index within the block. * **Parameters:** `blockHash`, `index` (hex) * **Returns:** [`Transaction`](#transaction) `| null` * **Compatibility:** [EIP-1474](https://eips.ethereum.org/EIPS/eip-1474), [ethereum.org](https://ethereum.org/developers/docs/apis/json-rpc/#eth_gettransactionbyblockhashandindex) ```bash curl -s -X POST $RPC_URL \ -H "Content-Type: application/json" \ -d '{ "jsonrpc":"2.0", "method":"eth_getTransactionByBlockHashAndIndex", "params":["0x761fdbb98eb904196b6be98870b222fc2f06d2fdac4bae1200f177092ce6ec98", "0x0"], "id":1 }' ``` ```json { "jsonrpc": "2.0", "id": 1, "result": { "blockHash": "0x761fdbb98eb904196b6be98870b222fc2f06d2fdac4bae1200f177092ce6ec98", "blockNumber": "0xfebbe5e", "from": "0xc04ea345ac1aded81ea4b3bd7ada1f7638e63e66", "to": "0x1909cdb9524d065e5751d2fe79e2b9ad54d822e6", "gas": "0x5208", "gasPrice": "0x165a0bc00", "hash": "0xe37a5053ed983747d65a782a4924e2a894729a0cbcbbf012ea6267870a99df53", "input": "0x", "nonce": "0x11", "transactionIndex": "0x0", "value": "0x29a0cc50fa726000", "type": "0x2", "chainId": "0x13a7", "v": "0x0", "r": "0xf2d4bdc57a1bab8df77f9fd311390f3ec9dacb5bd61fdb56b32bd0c3003136bf", "s": "0x10283bed1b67d23c87f8d64f309f401b802e5596788b3ce10dc47ee0e4c21fa4", "maxPriorityFeePerGas": "0x165a0bc00", "maxFeePerGas": "0x165a0bc00" } } ``` *** #### `eth_getTransactionByBlockNumberAndIndex` Returns a transaction by block number and index within the block. * **Parameters:** `blockNumber` (hex or label), `index` (hex) * **Returns:** [`Transaction`](#transaction) `| null` * **Compatibility:** [EIP-1474](https://eips.ethereum.org/EIPS/eip-1474), [ethereum.org](https://ethereum.org/developers/docs/apis/json-rpc/#eth_gettransactionbyblocknumberandindex) ```bash curl -s -X POST $RPC_URL \ -H "Content-Type: application/json" \ -d '{ "jsonrpc":"2.0", "method":"eth_getTransactionByBlockNumberAndIndex", "params":["0xfebbe5e", "0x0"], "id":1 }' ``` Response format is identical to [`eth_getTransactionByBlockHashAndIndex`](#eth_gettransactionbyblockhashandindex) above. *** #### `eth_getTransactionReceipt` Returns the receipt for a mined transaction. * **Parameters:** `txHash` * **Returns:** [`TransactionReceipt`](#transactionreceipt) `| null` * **Compatibility:** [EIP-1474](https://eips.ethereum.org/EIPS/eip-1474), [ethereum.org](https://ethereum.org/developers/docs/apis/json-rpc/#eth_gettransactionreceipt) ```bash curl -s -X POST $RPC_URL \ -H "Content-Type: application/json" \ -d '{ "jsonrpc":"2.0", "method":"eth_getTransactionReceipt", "params":["0xe37a5053ed983747d65a782a4924e2a894729a0cbcbbf012ea6267870a99df53"], "id":1 }' ``` ```json { "jsonrpc": "2.0", "id": 1, "result": { "transactionHash": "0xe37a5053ed983747d65a782a4924e2a894729a0cbcbbf012ea6267870a99df53", "transactionIndex": "0x0", "blockHash": "0x761fdbb98eb904196b6be98870b222fc2f06d2fdac4bae1200f177092ce6ec98", "blockNumber": "0xfebbe5e", "from": "0xc04ea345ac1aded81ea4b3bd7ada1f7638e63e66", "to": "0x1909cdb9524d065e5751d2fe79e2b9ad54d822e6", "cumulativeGasUsed": "0x0", "gasUsed": "0x5208", "contractAddress": null, "type": "0x2", "status": "0x1", "logsBloom": "0x00000000...00000000", "logs": [], "effectiveGasPrice": "0x165a0bc00" } } ``` *** #### `eth_getBlockReceipts` Returns all transaction receipts for a block. * **Parameters:** `blockNumberOrHash` (hex block number, block hash, or label like `"latest"`) * **Returns:** [`TransactionReceipt`](#transactionreceipt)`[]` * **Compatibility:** [execution-apis](https://ethereum.github.io/execution-apis/api/methods/eth_getBlockReceipts) ```bash curl -s -X POST $RPC_URL \ -H "Content-Type: application/json" \ -d '{ "jsonrpc":"2.0", "method":"eth_getBlockReceipts", "params":["0xfebbe5e"], "id":1 }' ``` ```json { "jsonrpc": "2.0", "id": 1, "result": [ { "transactionHash": "0xe37a5053ed983747d65a782a4924e2a894729a0cbcbbf012ea6267870a99df53", "transactionIndex": "0x0", "blockHash": "0x761fdbb98eb904196b6be98870b222fc2f06d2fdac4bae1200f177092ce6ec98", "blockNumber": "0xfebbe5e", "from": "0xc04ea345ac1aded81ea4b3bd7ada1f7638e63e66", "to": "0x1909cdb9524d065e5751d2fe79e2b9ad54d822e6", "cumulativeGasUsed": "0x0", "gasUsed": "0x5208", "contractAddress": null, "type": "0x2", "status": "0x1", "logsBloom": "0x00000000...00000000", "logs": [], "effectiveGasPrice": "0x165a0bc00" } ] } ``` *** <br> ### Block Retrieval #### `eth_getBlockByNumber` Returns block data by number. * **Parameters:** `blockNumber` (hex or `"latest"`, `"earliest"`, `"pending"`), `fullTransactions` (bool -- if true, returns full tx objects; if false, returns tx hashes only) * **Returns:** [`Block`](#block) `| null` * **Compatibility:** [EIP-1474](https://eips.ethereum.org/EIPS/eip-1474), [ethereum.org](https://ethereum.org/developers/docs/apis/json-rpc/#eth_getblockbynumber) ```bash curl -s -X POST $RPC_URL \ -H "Content-Type: application/json" \ -d '{ "jsonrpc":"2.0", "method":"eth_getBlockByNumber", "params":["0xfebbe5e", false], "id":1 }' ``` ```json { "jsonrpc": "2.0", "id": 1, "result": { "hash": "0x761fdbb98eb904196b6be98870b222fc2f06d2fdac4bae1200f177092ce6ec98", "parentHash": "0x73af1211b4b3ccc9c35db241d9aaf360375a10e2c85bd967c301411208404b45", "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", "miner": "0x0000000000000000000000000000000000000000", "stateRoot": "0xc076805ead803fdd1626309ade65a9da117e8dd0292c3b83a3f83b2c275e324c", "transactionsRoot": "0xb3704a7f49e846d089b574444a520315c852300c0e8a0b475d2614d71c14e031", "receiptsRoot": "0x38cb8db2babffab04de59d22a5ce68fb8cc5fcb00e71df0f9f03e3ce4d93a798", "logsBloom": "0x00000000...00000000", "difficulty": "0x0", "number": "0xfebbe5e", "gasLimit": "0x5208", "gasUsed": "0x5208", "baseFeePerGas": "0x165a0bc00", "timestamp": "0x69c925c6", "size": "0x222", "extraData": "0x0c73c07da3a7bbb6124544f41657d75a6a5ee033adce9d8eff74bfad616567a2", "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", "nonce": "0x0000000000000000", "transactions": [ "0xe37a5053ed983747d65a782a4924e2a894729a0cbcbbf012ea6267870a99df53" ] } } ``` *** #### `eth_getBlockByHash` Returns block data by hash. Same response format as [`eth_getBlockByNumber`](#eth_getblockbynumber). * **Parameters:** `blockHash`, `fullTransactions` (bool) * **Returns:** [`Block`](#block) `| null` * **Compatibility:** [EIP-1474](https://eips.ethereum.org/EIPS/eip-1474), [ethereum.org](https://ethereum.org/developers/docs/apis/json-rpc/#eth_getblockbyhash) ```bash curl -s -X POST $RPC_URL \ -H "Content-Type: application/json" \ -d '{ "jsonrpc":"2.0", "method":"eth_getBlockByHash", "params":["0x761fdbb98eb904196b6be98870b222fc2f06d2fdac4bae1200f177092ce6ec98", false], "id":1 }' ``` Response format is identical to [`eth_getBlockByNumber`](#eth_getblockbynumber) above. *** #### `eth_getHeaderByNumber` Returns only the block header (no transactions). Same response shape as [`eth_getBlockByNumber`](#eth_getblockbynumber) but with the `transactions` field omitted entirely. * **Parameters:** `blockLabel` (hex or label) * **Returns:** [`Block`](#block) `| null` (header only) * **Compatibility:** [Geth](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-eth#ethgetheaderbynumber) ```bash curl -s -X POST $RPC_URL \ -H "Content-Type: application/json" \ -d '{ "jsonrpc":"2.0", "method":"eth_getHeaderByNumber", "params":["0xfebbe5e"], "id":1 }' ``` > **Note:** The `transactions` field is omitted from the response (not present as an empty array). *** #### `eth_getHeaderByHash` Returns only the block header by hash. Same as [`eth_getHeaderByNumber`](#eth_getheaderbynumber) but looks up by block hash. * **Parameters:** `blockHash` * **Returns:** [`Block`](#block) `| null` (header only) * **Compatibility:** [Geth](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-eth#ethgetheaderbyhash) ```bash curl -s -X POST $RPC_URL \ -H "Content-Type: application/json" \ -d '{ "jsonrpc":"2.0", "method":"eth_getHeaderByHash", "params":["0x761fdbb98eb904196b6be98870b222fc2f06d2fdac4bae1200f177092ce6ec98"], "id":1 }' ``` > **Note:** The `transactions` field is omitted from the response (not present as an empty array). *** #### `eth_getBlockTransactionCountByNumber` Returns the number of transactions in a block. * **Parameters:** `blockLabel` (hex or label) * **Returns:** `quantity` (uint64) * **Compatibility:** [EIP-1474](https://eips.ethereum.org/EIPS/eip-1474), [ethereum.org](https://ethereum.org/developers/docs/apis/json-rpc/#eth_getblocktransactioncountbynumber) ```bash curl -s -X POST $RPC_URL \ -H "Content-Type: application/json" \ -d '{ "jsonrpc":"2.0", "method":"eth_getBlockTransactionCountByNumber", "params":["0xfebbe5e"], "id":1 }' ``` ```json {"jsonrpc":"2.0","id":1,"result":"
프로젝트로 돌아가기