StateLib
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
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
artifact
static
artifact:Artifact
Defined in: packages/scrypt-ts-opcat/src/smart-contract/smartContractLib.ts:16
Inherited from
stateType?
static
optional
stateType:string
Defined in: packages/scrypt-ts-opcat/src/smart-contract/smartContractLib.ts:17
Inherited from
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 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
): typeofSmartContractLib
Defined in: packages/scrypt-ts-opcat/src/smart-contract/smartContractLib.ts:19
Parameters
artifact
Returns
typeof SmartContractLib
Inherited from
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
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
the hash byte string of the state object