Skip to content

@gala-chain/chaincodeAPI


API > fetchOrCreateBalance

Function: fetchOrCreateBalance()

fetchOrCreateBalance(ctx, owner, tokenClassKey): Promise\<TokenBalance>

Parameters

ctx: GalaChainContext

owner: string

tokenClassKey: NonFunctionProperties\<TokenClassKey>

Returns

Promise

Description

Query a single TokenBalance from on-chain World State belonging to the provided owner for the specified tokenClassKey argument.

If the TokenBalance does not yet exist on-chain, a new TokenBalance class instance will be instantiated and returned.

Source

chaincode/src/balances/fetchOrCreateBalance.ts:36