@midnight/ledger v3.0.2 • Readme | API
@midnight/ledger v3.0.2 / LedgerState
Class: LedgerState
The state of the Midnight ledger
Constructors
new LedgerState(zswap)
new LedgerState(zswap): LedgerState
Intializes from a Zswap state, with an empty contract set
Parameters
• zswap: ZswapChainState
Returns
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
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
blank()
static blank(): LedgerState
A fully blank state
Returns
deserialize()
static deserialize(raw, netid): LedgerState
Parameters
• raw: Uint8Array
• netid: NetworkId