JSON-RPC API

Somnia exposes an RPC API compatible with the Ethereum JSON-RPC specification. The mainnet public RPC endpoint is https://api.infra.mainnet.somnia.network (chain ID 0x13a7 / 5031).

Methods by Name

Method

Compatibility

WebSocket Only

Somnia-specific

Yes

Somnia-specific

Somnia-specific

Somnia-specific

Somnia-specific

Somnia-specific, testnet only

Somnia-specific, testnet only

Methods by Category

Network / Web3

net_version

Returns the network ID.

Note: This is currently non-conformant with the Ethereum JSON-RPC spec, which specifies that the return value is a decimal string. In future Somnia will switch to this form:


net_listening

Returns true if the node is listening for connections.


web3_clientVersion

Returns the Somnia client version string.


web3_sha3

Returns the Keccak-256 hash of the given data.


Chain State

eth_chainId

Returns the chain ID.


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.


eth_blockNumber

Returns the latest block number.


eth_accounts

Returns the list of accounts owned by the node (empty for public RPC endpoints).


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, ethereum.org


eth_getTransactionCount

Returns the nonce (number of transactions sent) for an account.


eth_getCode

Returns the bytecode at an address ("0x" for addresses without code).


eth_getStorageAt

Returns the value in a contract's storage slot.

  • Parameters: address, slot (hex uint256), blockLabel

  • Returns: bytes (hex)

  • Compatibility: EIP-1474, ethereum.org

  • Requires node to be ready


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, ethereum.org

  • Requires node to be ready

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, but the response is a full transaction receipt instead of just the hash.

  • Parameters: signedTransactionData (hex-encoded signed tx bytes)

  • Compatibility: Somnia-specific -- no Ethereum equivalent

  • Requires node to be ready


Transaction Retrieval

eth_getTransactionByHash

Returns transaction details by hash, or null if not found.


eth_getTransactionByBlockHashAndIndex

Returns a transaction by block hash and index within the block.


eth_getTransactionByBlockNumberAndIndex

Returns a transaction by block number and index within the block.

Response format is identical to eth_getTransactionByBlockHashAndIndex above.


eth_getTransactionReceipt

Returns the receipt for a mined transaction.


eth_getBlockReceipts

Returns all transaction receipts for a block.


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 | null

  • Compatibility: EIP-1474, ethereum.org


eth_getBlockByHash

Returns block data by hash. Same response format as eth_getBlockByNumber.

Response format is identical to eth_getBlockByNumber above.


eth_getHeaderByNumber

Returns only the block header (no transactions). Same response shape as eth_getBlockByNumber but with the transactions field omitted entirely.

  • Parameters: blockLabel (hex or label)

  • Returns: Block | null (header only)

  • Compatibility: Geth

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 but looks up by block hash.

  • Parameters: blockHash

  • Returns: Block | null (header only)

  • Compatibility: Geth

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, ethereum.org


eth_getBlockTransactionCountByHash

Returns the number of transactions in a block by hash.


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[]

  • Compatibility: EIP-1474, ethereum.org

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


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, ethereum.org

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


eth_newBlockFilter

Creates a filter that returns new block hashes.


eth_newPendingTransactionFilter

Creates a filter that returns new pending transaction hashes.


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, ethereum.org


eth_getFilterLogs

Returns all logs matching the filter criteria (for log filters only).


eth_uninstallFilter

Removes a filter. Returns true if the filter was found and removed.

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.


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)

  • Returns: quantity (subscription id)

  • Compatibility: Geth

  • WebSocket only

    • This method emits events, so requires a WebSocket connection. Over HTTP it returns events_not_supported. eth_unsubscribe works over both HTTP and WebSocket.

Over HTTP, this returns:


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


Gas & Fees

eth_gasPrice

Returns the current gas price in wei.


eth_maxPriorityFeePerGas

Returns the current max priority fee per gas (tip) in wei.


eth_feeHistory

Returns historical gas fee data.

  • Parameters: blockCount (hex), newestBlock (hex or label), rewardPercentiles (array of floats)

  • Returns: json object

  • Compatibility: EIP-1559, execution-apis


eth_call

Executes a call without creating a transaction (read-only simulation).


eth_estimateGas

Estimates the gas required for a transaction.


eth_createAccessList

Returns an empty EIP-2930 access list plus the estimated gas for a transaction. (Somnia doesn't support access lists.)


Debug / Tracing

debug_traceCall

Traces a call execution with a specified tracer.


debug_traceTransaction

Traces an already-mined transaction.

  • Parameters: txHash, tracer config (tracer, tracerConfig)

  • Returns: trace output

  • Compatibility: Geth

  • Requires node to be ready


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

  • Requires node to be ready

Supported tracers: "callTracer" (with optional {"onlyTopCall": true}), "prestateTracer" (with optional {"diffMode": true})


debug_traceBlockByHash

Traces all transactions in a block by block hash.

  • Parameters: blockHash, tracer config

  • Returns: {txHash, result | null, error | null}[]

  • Compatibility: Geth

  • Requires node to be ready

Supported tracers: "callTracer" (with optional {"onlyTopCall": true}), "prestateTracer" (with optional {"diffMode": true})

Response format is identical to debug_traceBlockByHash above.


Somnia-Specific

somnia_isReady

Returns true if the node is synced and ready to process requests.

  • Parameters: (none)

  • Returns: bool

  • Compatibility: Somnia-specific


somnia_isReadyWithErrorCode

Like 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


somnia_nodePublicKeys

Returns the node's public keys for the current epoch.

  • Parameters: (none)

  • Returns: json object

  • Compatibility: Somnia-specific


somnia_getBlockByNumber

Returns Somnia's native block representation (consensus + execution blocks), which contains more detail than the Ethereum-compatible eth_getBlockByNumber.


somnia_getBlockByHash

Same as somnia_getBlockByNumber but looks up by block hash.

Response format is identical to somnia_getBlockByNumber above.


somnia_getStatistics

Returns chain statistics over a block range.

  • Parameters: fromBlock (hex or label), toBlock (hex or label)

  • Returns: json object

  • Compatibility: Somnia-specific


somnia_getPrivilegedTransactionReceiptsForBlockByNumber

Returns receipts for privileged (system) transactions in a block.

  • Parameters: blockNumber (hex or label)

  • Compatibility: Somnia-specific -- system/privileged tx receipts


somnia_getPrivilegedTransactionReceiptsForBlockByHash

Returns receipts for privileged (system) transactions in a block. Same as somnia_getPrivilegedTransactionReceiptsForBlockByNumber but looks up by block hash.

  • Parameters: blockHash

  • Compatibility: Somnia-specific -- system/privileged tx receipts

Response format is identical to somnia_getPrivilegedTransactionReceiptsForBlockByNumber above.


somnia_getSessionAddress

Derives a session key address from a seed.

  • Parameters: seed (32-byte hash)

  • Returns: address

  • Compatibility: Somnia-specific -- session key derivation


somnia_sendSessionTransaction

Sends a transaction using a session key (derived from a seed). The session account must have sufficient funds.

  • Parameters: object with seed (hash), gas (hex), to (address, optional), value (hex, optional), data (hex, optional)

  • Returns: TransactionReceipt | null

  • Compatibility: Somnia-specific -- session key transactions

Response format is identical to eth_getTransactionReceipt above.


somnia_reactivityGetSubscriptionInfo

Returns details of a Somnia Reactivity Protocol subscription by ID.


somnia_reactivityGetSubscriptions

Returns all Somnia Reactivity Protocol subscriptions owned by an address.

Response is a JSON array of ReactivitySubscription objects.


Notes

General Usage

Endpoints

Network
HTTP
WebSocket

Mainnet (chain ID 0x13a7 / 5031)

https://api.infra.mainnet.somnia.network

wss://api.infra.mainnet.somnia.network/ws

Testnet Shannon (chain ID 0xc488 / 50312)

https://api.infra.testnet.somnia.network

wss://api.infra.testnet.somnia.network/ws

Request Format

All requests use the JSON-RPC 2.0 protocol over HTTP POST or WebSocket. The request body is:

Batch requests are supported: send a JSON array of request objects and receive a JSON array of responses in the same order.

Hex Encoding

All numeric values in requests and responses are hex-encoded with a 0x prefix, following the Ethereum JSON-RPC convention:

  • Quantities (block numbers, gas, balances, nonces): hex without leading zeros — "0x1", "0x5208", "0x165a0bc00"

  • Data (hashes, addresses, bytecode, input data): hex with even-length zero-padding — "0x0000...0000", "0x"

Block Labels

Many methods accept a block label parameter. This can be:

  • A hex-encoded block number (e.g. "0xfebbe5e")

  • "latest" — the most recent confirmed block

  • "earliest" — the genesis block (block 0)

  • "finalized", "pending", "safe" — currently treated the same as "latest"

Transaction Types

Somnia supports the following Ethereum transaction types via eth_sendRawTransaction:

Type
Name
EIP
Notes

0x0

Legacy

pre-EIP-2718

gasPrice field

0x1

Access list

gasPrice + accessList

0x2

Dynamic fee

maxFeePerGas + maxPriorityFeePerGas

0x3

Blob

Not supported

0x4

Set code

authorizationList for EOA code delegation

Error Codes

Error responses follow the JSON-RPC 2.0 format:

Code
Meaning
Common causes

-32700

Parse error

Malformed JSON

-32600

Invalid request

Missing jsonrpc, method, or id fields

-32601

Method not found

Typo in method name, or method not available on this node

-32602

Invalid parameters

Wrong number or types of params

-32603

Internal error

Node not ready, or unexpected server error

-32604

Too many requests

Rate limit exceeded

-32004

Method not supported

Method exists but is disabled on this node

-32000

Invalid input

Transaction-specific errors (see below)

-1

Application error

Handler-specific errors (e.g. "block range exceeds 1000")

Common -32000 transaction errors from eth_sendRawTransaction:

Message
Meaning

"invalid transaction"

RLP decoding failed or transaction is malformed

"invalid signature"

ECDSA signature verification failed

"nonce too low"

Transaction nonce is behind the account's current nonce

"nonce too high"

Transaction nonce is too far ahead

"insufficient balance"

Account cannot cover value + gas

"gas price below base fee"

gasPrice or maxFeePerGas is below the current base fee

"mempool full"

Node's transaction pool is at capacity

Special Cases

Requires Node Ready

Some methods are marked Requires Node Ready in the index table. These methods will return an error if the node has not finished syncing and is not yet ready to serve requests.

You can check whether a node is ready before making calls by using somnia_isReady.

Log Query Limits

eth_getLogs, eth_newFilter, and eth_getFilterLogs enforce a maximum block range (currently 1000 blocks). Queries exceeding this range will return an error. To scan larger ranges, issue multiple queries with non-overlapping block ranges.

Filter and Subscription Statefulness

Filters created with eth_newFilter, eth_newBlockFilter, and eth_newPendingTransactionFilter are scoped to the connection that created them. On load-balanced public RPC endpoints, subsequent requests may be routed to a different backend, causing eth_getFilterChanges to return empty results or eth_uninstallFilter to return false. For reliable filter-based polling, use a dedicated RPC endpoint or switch to eth_subscribe over WebSocket.

Subscriptions created with eth_subscribe are also connection-scoped. eth_unsubscribe returns false if the subscription id is unknown or belongs to a different connection.

Missing Resource Semantics

Somnia does not use a single convention for "not found". The main cases are:

Somnia vs Ethereum Differences

While Somnia is EVM-compatible and supports the standard Ethereum JSON-RPC, there are a few behavioural differences to be aware of:

  • eth_syncing returns only a bool (true while syncing, false when ready). It does not return a sync-status object with startingBlock/currentBlock/highestBlock fields as Ethereum clients do.

  • eth_getHeaderByHash / eth_getHeaderByNumber omit the transactions field entirely rather than returning an empty array.

  • eth_subscribe supports the standard "newHeads" and "logs" types, plus three Somnia-specific types: "somnia_finishedTransactions", "somnia_finishedBlocks", and "somnia_watch". It does not support "newPendingTransactions".

  • realtime_sendRawTransaction is a Somnia extension that submits a transaction and blocks until the receipt is available, combining eth_sendRawTransaction + polling eth_getTransactionReceipt into a single call.

  • Block structure: Somnia blocks have a fixed difficulty of 0x0, miner of 0x0...0, and no uncle blocks. The gasLimit reflects per-block execution gas rather than a global gas target.

  • EIP-4844 blob transactions (type 0x3) are not supported.

For more detail on gas behaviour, see Somnia Gas Differences to Ethereum.

Appendix

Request Schemas

TransactionRequest (used by eth_call, eth_estimateGas, eth_createAccessList, debug_traceCall, and somnia_watch.eth_calls):

Field
Type
Notes

from

address or null

Sender address for simulation

to

address or null

Omit or set null for contract creation

gas

quantity or null

Gas limit for the simulated transaction

value

quantity or null

Wei transferred

input

bytes or null

Calldata alias accepted by Geth-style clients

data

bytes or null

Calldata alias

authorizationList

EIP-7702 authorization list

input and data are interchangeable aliases. If both are provided, Somnia uses input.

AuthorizationListEntry (entries within authorizationList):

Field
Type
Notes

chainId

quantity

Chain id covered by the authorization

address

address

Contract address to delegate code from

nonce

quantity

Authorization nonce

yParity

quantity

Signature recovery parity

r

quantity

Signature component

s

quantity

Signature component

StateOverrideSet (used by eth_call, eth_estimateGas, and debug_traceCall):

A JSON object keyed by account address, where each value is a StateOverride object.

StateOverride:

Field
Type
Notes

balance

quantity or null

Override account balance

nonce

quantity or null

Override account nonce

code

bytes or null

Override deployed bytecode

state

object or null

Replace the entire storage map with slot -> value entries

stateDiff

object or null

Patch individual storage slots with slot -> value entries

state and stateDiff are mutually exclusive. Providing both returns an error.

Several methods take similar log-filter-shaped inputs, but they are not one shared request type in source.

Response Schemas

Transaction (returned by eth_getTransactionByHash and similar):

Field
Type
Notes

blockHash

hash

blockNumber

quantity

from

address

to

address or null

null for contract creation

gas

quantity

Gas limit

gasPrice

quantity

Effective gas price

hash

hash

Transaction hash

input

bytes

Calldata ("0x" for simple transfers)

nonce

quantity

transactionIndex

quantity

Position within the block

value

quantity

Wei transferred

type

quantity

0x0 legacy, 0x1 access list, 0x2 EIP-1559, 0x4 EIP-7702

chainId

quantity

v, r, s

quantity

ECDSA signature components

maxPriorityFeePerGas

quantity or null

Present for type 0x2 and 0x4 only

maxFeePerGas

quantity or null

Present for type 0x2 and 0x4 only

authorizationList

array or null

Present for type 0x4 only

TransactionReceipt (returned by eth_getTransactionReceipt and similar):

Field
Type
Notes

transactionHash

hash

transactionIndex

quantity

blockHash

hash

blockNumber

quantity

from

address

to

address or null

null for contract creation

cumulativeGasUsed

quantity

gasUsed

quantity

Gas consumed by this transaction

contractAddress

address or null

Address of created contract, or null

type

quantity

Transaction type

status

quantity

0x1 success, 0x0 revert

logsBloom

bytes

256-byte bloom filter

logs

Log[]

Array of log entries (see below)

effectiveGasPrice

quantity

Actual gas price paid

Log (entries within logs arrays):

Field
Type
Notes

address

address

Contract that emitted the event

topics

hash[]

Up to 4 indexed event parameters; topics[0] is the event signature hash

data

bytes

ABI-encoded non-indexed parameters

blockNumber

quantity

transactionHash

hash

transactionIndex

quantity

blockHash

hash

logIndex

quantity

Position within the block's logs

Block (returned by eth_getBlockByNumber and similar):

Field
Type
Notes

hash

hash

parentHash

hash

sha3Uncles

hash

Always the empty uncles hash (no uncle blocks)

miner

address

Always 0x0000...0000

stateRoot

hash

transactionsRoot

hash

receiptsRoot

hash

logsBloom

bytes

256-byte bloom filter

difficulty

quantity

Always 0x0

number

quantity

Block number

gasLimit

quantity

Per-block execution gas

gasUsed

quantity

baseFeePerGas

quantity

EIP-1559 base fee

timestamp

quantity

Unix timestamp

size

quantity

RLP-encoded block size in bytes

extraData

bytes

mixHash

hash

Always zero

nonce

bytes

Always zero (8 bytes)

transactions

hash[] or Transaction[]

Tx hashes if fullTxObjects=false, full objects if true. Omitted entirely for eth_getHeaderBy*.

SomniaLedgerBlock (returned by somnia_getBlockByNumber / somnia_getBlockByHash):

Field
Type
Notes

consensus_block

Consensus-layer block data

execution_block

Execution-layer block data

parent_ledger_block_hash

hash

Parent ledger-block hash

ledger_block_hash

hash

Ledger-block hash

SomniaConsensusBlock:

Field
Type
Notes

block_number

quantity

Ledger block number

timestamp

quantity

Unix timestamp in milliseconds

data_chain_blocks

hash[]

Referenced data-chain blocks

delayed_ledger_block_number

quantity

Delayed ledger block number

delayed_ledger_block_hash

hash

Delayed ledger block hash

parent_consensus_block_hash

hash

Parent consensus-block hash

proposer_address

address

Block proposer

block_resources

Frontend resource accounting

consensus_block_hash

hash

Consensus-block hash

SomniaExecutionBlock:

Field
Type
Notes

transaction_ids_hash

hash

Hash of transaction ids

receipts_hash

hash

Hash of receipts

execution_gas_limit

quantity

Execution gas limit

execution_gas_used

quantity

Execution gas used

execution_state_snapshot

hash

State snapshot hash

state_snapshot_block_number

quantity

Block number of the state snapshot

operation_sequence_hash

quantity

Operation sequence hash encoded as a quantity

SomniaFrontendResources:

Field
Type
Notes

validation_gas

quantity

Validation gas used by the consensus block

compressed_bytes

quantity

Compressed frontend payload size

uncompressed_bytes

quantity

Uncompressed frontend payload size

ReactivitySubscription (returned by somnia_reactivityGetSubscriptionInfo / somnia_reactivityGetSubscriptions):

Field
Type
Notes

id

quantity

Subscription ID

topics

data[4]

Log topics to match (up to 4)

origin

address

Origin filter

caller

address

Caller filter (reserved, currently unused)

emitter

address

Contract address that emits the matched log

owner

address

Subscription owner address

handler_contract_address

address

Contract called when the subscription triggers

handler_function_selector

data

4-byte function selector on the handler contract

gas_limit

quantity

Gas limit for the reactive callback

priority_fee_per_gas

quantity

Priority fee per gas for the callback

max_fee_per_gas

quantity

Max fee per gas for the callback

Subscription Schemas

All eth_subscribe notifications use this envelope:

newHeads

logs

Params:

Field
Type
Notes

address

address or address[]

Match logs from one or more contracts

topics

array or null

Same topic-position semantics as eth_getLogs / eth_newFilter

  • Event result: Log

somnia_finishedTransactions

Params:

Field
Type
Notes

transaction_senders

address[] or null

Only emit events for transactions from these senders

subscribe_to_all_transactions

bool or null

Emit events for all finished transactions

Event result:

Field
Type
Notes

transaction_id

hash

Transaction hash

transaction_status

integer enum

Internal TransactionStatus value

sender_address

address

Transaction sender

transaction_nonce

integer

Sender nonce used by the transaction

somnia_finishedBlocks

  • Params: none

Event result:

Field
Type
Notes

blockNumber

quantity

Finished block number

totalTransactions

quantity

Number of transactions in the block

somnia_watch

Params:

Field
Type
Notes

address

address or address[]

Log emitter filter

topics

array or null

Same topic-position semantics as eth_getLogs / eth_newFilter

eth_calls

array

context

string or string[]

Extra values appended to each simulated call's calldata. Supported selectors: address, data, topic1, topic2, topic3, topic4

push_changes_only

bool or null

Only emit when simulationResults change from the previous event for that subscription

Event result:

Field
Type
Notes

address

address

Log emitter

topics

hash[]

Emitted topics

data

bytes

Raw log data

simulationResults

bytes[]

Return data from each configured simulated call

NewHead (event payload for eth_subscribe("newHeads")):

Field
Type
Notes

hash

hash

parentHash

hash

sha3Uncles

hash

Always the empty uncles hash

miner

address

Always 0x0000...0000

stateRoot

hash

transactionsRoot

hash

receiptsRoot

hash

logsBloom

bytes

256-byte bloom filter

difficulty

quantity

Always 0x0

number

quantity

Block number

gasLimit

quantity

gasUsed

quantity

baseFeePerGas

quantity

timestamp

quantity

Unix timestamp

extraData

bytes

Last updated