Skip to main content

LedgerState

@midnight-ntwrk/ledger v3.0.2 β€’ Readme | API


@midnight-ntwrk/ledger v3.0.2 / LedgerState

Class: LedgerState

The state of the Midnight ledger

Constructors​

new LedgerState(zswap)​

new LedgerState(zswap): LedgerState

Initializes from a Zswap state, with an empty contract set

Parameters​

β€’ zswap: ZswapChainState

Returns​

LedgerState

Properties​

unmintedNativeTokenSupply​

readonly unmintedNativeTokenSupply: bigint;

The remaining unminted supply of native tokens.


zswap​

readonly zswap: ZswapChainState;

The Zswap part of the ledger state

Methods​

apply()​

apply(transaction, context): [LedgerState, TransactionResult]

Applies a ProofErasedTransaction

Parameters​

β€’ transaction: ProofErasedTransaction

β€’ context: TransactionContext

Returns​

[LedgerState, TransactionResult]


applySystemTx()​

applySystemTx(transaction): LedgerState

Applies a system transaction to this ledger state.

Parameters​

β€’ transaction: SystemTransaction

Returns​

LedgerState


index()​

index(address): undefined | ContractState

Indexes into the contract state map with a given contract address

Parameters​

β€’ address: string

Returns​

undefined | ContractState


serialize()​

serialize(netid): Uint8Array

Parameters​

β€’ netid: NetworkId

Returns​

Uint8Array


toString()​

toString(compact?): string

Parameters​

β€’ compact?: boolean

Returns​

string


treasuryBalance()​

treasuryBalance(token_type): bigint

Retrieves the balance of the treasury for a specific token type.

Parameters​

β€’ token_type: string

Returns​

bigint


unclaimedMints()​

unclaimedMints(recipient, token_type): bigint

How much in minting rewards a recipient, for a specific token type, is owed and can claim.

Parameters​

β€’ recipient: string

β€’ token_type: string

Returns​

bigint


updateIndex()​

updateIndex(address, context): LedgerState

Sets the state of a given contract address from a QueryContext

Parameters​

β€’ address: string

β€’ context: QueryContext

Returns​

LedgerState


blank()​

static blank(): LedgerState

A fully blank state

Returns​

LedgerState


deserialize()​

static deserialize(raw, netid): LedgerState

Parameters​

β€’ raw: Uint8Array

β€’ netid: NetworkId

Returns​

LedgerState