Skip to content

@gala-chain/chaincodeAPI


API > getObjectByKey

Function: getObjectByKey()

getObjectByKey\<T>(ctx, constructor, objectId): Promise\<T>

Type parameters

T extends ChainObject

Parameters

ctx: GalaChainContext

constructor: ClassConstructor\<Inferred\<T, ChainObject>>

objectId: string

Returns

Description

Fetch an object from on-chain World State by its key.

The result will be deserialized and returned as an instantiated class instance using the provided constructor.

Remarks

Reads from GalaChainStub if object has been read previously during transaction execution.

Source

chaincode/src/utils/state.ts:241