@somnia-chain/markets-sdk


@somnia-chain/markets-sdk / native / SomniaNative

Interface: SomniaNative

Defined in: packages/sdk/src/native/client.ts:103

The Somnia-native RPC surface — the twelve methods in the public JSON-RPC reference. Build one with createNative.

Reads throw on failure and return null only where the node genuinely means "no such thing" — a missing block, an unknown subscription.

Methods

isReady()

isReady(opts?): Promise<boolean>

Defined in: packages/sdk/src/native/client.ts:111

Is the node ready to serve? false while it is still syncing.

Details

  • opts: withErrorCode: true calls somnia_isReadyWithErrorCode instead, which throws on a not-ready node (Is not ready, JSON-RPC internal error) rather than returning false — that variant exists so a health check can key on the error. It never returns false.

Parameters

opts?
withErrorCode?

boolean

Returns

Promise<boolean>


getBlock()

getBlock(block?): Promise<SomniaBlock | null>

Defined in: packages/sdk/src/native/client.ts:121

A Somnia ledger block — richer than the Ethereum-compatible block, with the proposer, the committed data-chain blocks and the execution state snapshot.

Takes a tag ("latest", "earliest", "pending", "safe", "finalized"), a block number, or a 32-byte ledger block hash — dispatching to somnia_getBlockByHash for the last of those.

Parameters

block?

`0x${string}` | SomniaBlockParam

Returns

Promise<SomniaBlock | null>


getStatistics()

getStatistics(from, to): Promise<SomniaChainStatistics>

Defined in: packages/sdk/src/native/client.ts:124

Aggregate activity between two blocks, inclusive.

Parameters

from

SomniaBlockParam

to

SomniaBlockParam

Returns

Promise<SomniaChainStatistics>


listPrivilegedReceipts()

listPrivilegedReceipts(block?): Promise<TransactionReceipt[]>

Defined in: packages/sdk/src/native/client.ts:132

Receipts for the privileged (protocol-issued) transactions in a block — the ones no user submitted, e.g. reactivity callbacks. Usually empty.

Takes a tag, a number, or a 32-byte block hash, like getBlock.

Parameters

block?

`0x${string}` | SomniaBlockParam

Returns

Promise<TransactionReceipt[]>


listReactivitySubscriptionIds()

listReactivitySubscriptionIds(owner): Promise<bigint[]>

Defined in: packages/sdk/src/native/client.ts:135

Ids of every reactivity subscription owned by an address.

Parameters

owner

`0x${string}`

Returns

Promise<bigint[]>


getReactivitySubscription()

getReactivitySubscription(id): Promise<SomniaReactivitySubscription | null>

Defined in: packages/sdk/src/native/client.ts:138

One reactivity subscription, or null when no subscription has that id.

Parameters

id

number | bigint

Returns

Promise<SomniaReactivitySubscription | null>


listReactivitySubscriptions()

listReactivitySubscriptions(ids): Promise<SomniaReactivitySubscription[]>

Defined in: packages/sdk/src/native/client.ts:141

Several reactivity subscriptions in one round-trip. Unknown ids are omitted.

Parameters

ids

readonly (number | bigint)[]

Returns

Promise<SomniaReactivitySubscription[]>


getNodePublicKeys()

getNodePublicKeys(): Promise<SomniaNodePublicKeys>

Defined in: packages/sdk/src/native/client.ts:144

The serving node's identity keys for the current epoch.

Returns

Promise<SomniaNodePublicKeys>


getSessionAddress()

getSessionAddress(seed): Promise<`0x${string}`>

Defined in: packages/sdk/src/native/client.ts:154

The address a session seed controls, as the node computes it.

sessionAddress computes the same value locally with no round-trip; this is the way to confirm the node agrees.

Note the node creates its in-memory sender for the seed as a side effect.

Parameters

seed

`0x${string}`

Returns

Promise<`0x${string}`>


sendSessionTransaction()

sendSessionTransaction(tx): Promise<TransactionReceipt>

Defined in: packages/sdk/src/native/client.ts:179

Submit a transaction through a session and wait for its receipt.

The node derives the key from the seed, assigns the nonce, signs, submits and retries transient failures — so this one call replaces sign + send + poll. It does not return until the transaction has executed, which can take a while under retry; give the underlying transport a generous timeout.

Before using it, know four things:

  • The seed is a private key. Anyone with it controls the account.
  • Pre-fund the account (sessionAddress) or the transaction cannot pay gas.
  • The nonce space is shared with eth_sendRawTransaction from the same address. Sending both ways at once corrupts the sequence.
  • The session lives in the serving node's memory, so it is not shared between nodes and is rebuilt from the seed after a restart.

Sent with retries disabled: a retry would be a second transfer, not a second attempt at the same one.

Gotchas

  • Throws If the node returns no receipt, or rejects the transaction (mempool errors arrive as JSON-RPC -32000; a node-side timeout as timeout).

Parameters

tx

SessionTransactionRequest

Returns

Promise<TransactionReceipt>


request()

request<T>(method, params?): Promise<T>

Defined in: packages/sdk/src/native/client.ts:193

Call any somnia_* method directly — the escape hatch for an endpoint this module doesn't wrap: an operator-only one, one a newer node has added, or one the public reference omits.

Params go through untouched, so hex-encode quantities yourself.

⚠️ Off the documented surface you are on your own, and not every undocumented endpoint is merely unstable — somnia_getStorageDatabaseEntries will make a node dump unbounded data for a large enough key list, and has taken a public testnet down. Know what a method does before reaching for it here.

Type Parameters

T

T = unknown

Parameters

method

string

params?

unknown[]

Returns

Promise<T>