Skip to main content

OffchainState

function OffchainState<Config>(config: Config): OffchainState<Config>

Offchain state for a SmartContract.

// declare your offchain state

const offchainState = OffchainState({
accounts: OffchainState.Map(PublicKey, UInt64),
totalSupply: OffchainState.Field(UInt64),
});

// use it in a contract, by adding an onchain state field of type `OffchainStateCommitments`

class MyContract extends SmartContract {
\@state(OffchainStateCommitments) offchainState = State(
OffchainStateCommitments.empty()
);

// ...
}

// set the contract instance

let contract = new MyContract(address);
offchainState.setContractInstance(contract);

See the individual methods on offchainState for more information on usage.

Type parameters

Config extends {}

Parameters

config: Config

Returns

OffchainState\<Config>

Source

index.ts:146