Skip to content

readState

readState<TLedger>(address, provider, ledgerParser): Promise<TLedger>

Defined in: src/Contract.ts:1096

Read a contract’s parsed ledger state without a wallet, deployment, or proof server.

Ideal for dashboards, explorers, and read-only views that only need to observe on-chain state.

Type Parameters

TLedger

TLedger

Parameters

address

string

The deployed contract address

provider

PublicDataProvider

Public data provider (from Config.publicDataProvider(networkConfig))

ledgerParser

LedgerParser<TLedger>

The contract module’s ledger function

Returns

Promise<TLedger>

Parsed ledger state

Example

import * as Contract from '@no-witness-labs/midday-sdk/Contract';
import * as Config from '@no-witness-labs/midday-sdk/Config';
import { ledger } from './contracts/counter/contract/index.js';
const pdp = Config.publicDataProvider(networkConfig);
const state = await Contract.readState(contractAddress, pdp, ledger);
console.log(state.counter); // 42n

Since

0.8.0