Skip to main content

ContractState

@midnight-ntwrk/compact-runtime v0.9.0


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

Constructor

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<ArrayBufferLike>

Returns

undefined | ContractOperation


operations()

operations(): (string | Uint8Array<ArrayBufferLike>)[];

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

Returns

(string | Uint8Array<ArrayBufferLike>)[]


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<ArrayBufferLike>

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