Skip to main content

ContractState

@midnight-ntwrk/onchain-runtime v0.2.2 β€’ Readme | API


@midnight-ntwrk/onchain-runtime v0.2.2 / ContractState

Class: ContractState

The state of a contract, consisting primarily of the data accessible directly to the contract, and the map of ContractOperations that can be called on it, the keys of which can be accessed with operations, and the individual operations can be read with operation and written to with setOperation.

Constructors​

new ContractState()​

new ContractState(): ContractState

Creates a blank contract state

Returns​

ContractState

Properties​

data​

data: StateValue;

The current value of the primary state of the contract


maintenanceAuthority​

maintenanceAuthority: ContractMaintenanceAuthority;

The maintenance authority associated with this contract

Methods​

operation()​

operation(operation): undefined | ContractOperation

Get the operation at a specific entry point name

Parameters​

β€’ operation: string | Uint8Array

Returns​

undefined | ContractOperation


operations()​

operations(): (string | Uint8Array)[]

Return a list of the entry points currently registered on this contract

Returns​

(string | Uint8Array)[]


query()​

query(query, cost_model): GatherResult[]

Runs a series of operations against the current state, and returns the results

Parameters​

β€’ query: Op<null>[]

β€’ cost_model: CostModel

Returns​

GatherResult[]


serialize()​

serialize(networkid): Uint8Array

Parameters​

β€’ networkid: NetworkId

Returns​

Uint8Array


setOperation()​

setOperation(operation, value): void

Set a specific entry point name to contain a given operation

Parameters​

β€’ operation: string | Uint8Array

β€’ value: ContractOperation

Returns​

void


toString()​

toString(compact?): string

Parameters​

β€’ compact?: boolean

Returns​

string


deserialize()​

static deserialize(raw, networkid): ContractState

Parameters​

β€’ raw: Uint8Array

β€’ networkid: NetworkId

Returns​

ContractState