Skip to main content

@midnight-ntwrk/compact-runtime v0.6.13Readme | API


@midnight-ntwrk/compact-runtime v0.6.13 / 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

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): GatherResult[]

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

Parameters

query: Op<null>[]

Returns

GatherResult[]


serialize()

serialize(): Uint8Array

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): ContractState

Parameters

raw: Uint8Array

Returns

ContractState