Skip to main content

StateLib

scrypt-ts-opcat v1.0.1


scrypt-ts-opcat / StateLib

Class: StateLib\<ST>

Defined in: packages/scrypt-ts-opcat/src/smart-contract/builtin-libs/stateLib.ts:14

Library for computing the hash of a state.

Onchain

Extends

Type Parameters

ST extends OpcatState

Constructors

new StateLib()

new StateLib\<ST>(...args): StateLib\<ST>

Defined in: packages/scrypt-ts-opcat/src/smart-contract/smartContractLib.ts:32

Parameters

args

...SupportedParamType[]

Returns

StateLib\<ST>

Inherited from

SmartContractLib.constructor

Other

__state_lib_dummy_private_field__

protected __state_lib_dummy_private_field__: ST

Defined in: packages/scrypt-ts-opcat/src/smart-contract/builtin-libs/stateLib.ts:95


args

args: any[] = []

Defined in: packages/scrypt-ts-opcat/src/smart-contract/smartContractLib.ts:31

Inherited from

SmartContractLib.args


artifact

static artifact: Artifact

Defined in: packages/scrypt-ts-opcat/src/smart-contract/smartContractLib.ts:16

Inherited from

SmartContractLib.artifact


stateType?

static optional stateType: string

Defined in: packages/scrypt-ts-opcat/src/smart-contract/smartContractLib.ts:17

Inherited from

SmartContractLib.stateType


deserializeState()

static deserializeState\<T>(this, serializedState): T

Defined in: packages/scrypt-ts-opcat/src/smart-contract/builtin-libs/stateLib.ts:56

Deserializes a state object from its ByteString representation.

Type Parameters

T extends StructObject

Type of the state object extending OpcatState

Parameters

this

(...args) => StateLib\<T>

Reference to the StateLib class constructor

serializedState

ByteString

ByteString containing the serialized state data

Returns

T

The deserialized state object of type T

Throws

Error if artifact is not loaded, library is not found, or state type is undefined


loadArtifact()

static loadArtifact(artifact): typeof SmartContractLib

Defined in: packages/scrypt-ts-opcat/src/smart-contract/smartContractLib.ts:19

Parameters

artifact

Artifact

Returns

typeof SmartContractLib

Inherited from

SmartContractLib.loadArtifact


stateHash()

static stateHash\<T>(this, state): ByteString

Defined in: packages/scrypt-ts-opcat/src/smart-contract/builtin-libs/stateLib.ts:87

Computes the SHA-256 hash of a serialized state object.

Type Parameters

T extends StructObject

Type extending OpcatState

Parameters

this

(...args) => StateLib\<T>

state

T

The state object to hash

Returns

ByteString

The hash as a ByteString

State

serializeState()

static serializeState\<T>(this, state): ByteString

Defined in: packages/scrypt-ts-opcat/src/smart-contract/builtin-libs/stateLib.ts:22

Calculate the hash of the state object

Type Parameters

T extends StructObject

Parameters

this

(...args) => StateLib\<T>

state

T

the state object

Returns

ByteString

the hash byte string of the state object

Onchain