Class: GatewayReads
GalaChain core SDK 1.0.0-rc.8 / index / GatewayReads
Class: GatewayReads
Defined in: packages/gala-core-sdk/dist/index.d.ts:2874
Unsigned GalaChain token-contract reads through the gateway: balances (with their holds summed),
token classes (with or without supply, by key or page by page), token metadata and NFT
collection authorizations; and a user's registered public key (public-key-contract). React
Native safe (no Node builtins, no ethers, no @gala-chain/api).
Every input is checked before anything is sent (owners as GatewayWrites spells them, class
keys in the forms a write accepts, page sizes), and every answer is checked before it is
trusted: GalaChain's Status, then each row's shape. Amounts stay the chain's whole-token
decimal strings (never scaled, never numbers). A read applies nothing, so a retry is always
safe: every failure after the request left says so (error.write === false), and an input
refused before it is pre_send (nothing was sent).
Example
const reads = new GatewayReads({ gatewayBaseUrl: 'https://gateway-mainnet.galachain.com' });
const gala = await reads.fetchTokenBalance({ owner: 'client|abc', tokenClassKey: 'GALA|Unit|none|none' });
console.log(gala?.availableQuantity);
Constructors
Constructor
new GatewayReads(
options):GatewayReads
Defined in: packages/gala-core-sdk/dist/index.d.ts:2880
Parameters
options
Returns
GatewayReads
Throws
GalaSDKError INVALID_READS_OPTION (a missing base URL, a requestor that is not a
function), INVALID_TIMEOUT.
Methods
fetchAllNftCollectionAuthorizations()
fetchAllNftCollectionAuthorizations(
options?):Promise<GalaChainNftCollectionAuthorization[]>
Defined in: packages/gala-core-sdk/dist/index.d.ts:2957
Every NFT collection authorization, page by page, up to maxPages pages.
Parameters
options?
Returns
Promise<GalaChainNftCollectionAuthorization[]>
Throws
GalaSDKError as fetchNftCollectionAuthorizationsPage, plus
PAGINATION_LIMIT_EXCEEDED.
fetchAllTokenClasses()
fetchAllTokenClasses(
filter?,options?):Promise<GalaChainTokenClass[]>
Defined in: packages/gala-core-sdk/dist/index.d.ts:2943
Every token class matching filter, page by page, up to maxPages pages.
Parameters
filter?
options?
Returns
Promise<GalaChainTokenClass[]>
Throws
GalaSDKError as fetchTokenClassesPage, plus PAGINATION_LIMIT_EXCEEDED.
fetchBalances()
fetchBalances(
filter):Promise<GalaChainTokenBalance[]>
Defined in: packages/gala-core-sdk/dist/index.d.ts:2889
The owner's balance records (FetchBalances), narrowed by any class-key parts given. Sent to
the music channel for $MUSIC, else asset. An answer with a record of another owner is
GATEWAY_READ_RESPONSE_INVALID (it is never reported as the owner's).
Parameters
filter
Returns
Promise<GalaChainTokenBalance[]>
Throws
GalaSDKError pre-send: INVALID_WALLET_ADDRESS (field: 'owner'),
INVALID_TOKEN_REFERENCE; then the read failures (see the class note).
fetchNftBalances()
fetchNftBalances(
filter):Promise<GalaChainTokenBalance[]>
Defined in: packages/gala-core-sdk/dist/index.d.ts:2903
The owner's non-fungible holdings: the balance records that hold at least one instance.
Parameters
filter
Returns
Promise<GalaChainTokenBalance[]>
Throws
GalaSDKError as fetchBalances.
fetchNftCollectionAuthorizationsPage()
fetchNftCollectionAuthorizationsPage(
page?):Promise<GalaChainPage<GalaChainNftCollectionAuthorization>>
Defined in: packages/gala-core-sdk/dist/index.d.ts:2950
One page of the NFT collection authorizations (FetchNftCollectionAuthorizationsWithPagination):
which users may create token classes in which collection.
Parameters
page?
Returns
Promise<GalaChainPage<GalaChainNftCollectionAuthorization>>
Throws
GalaSDKError pre-send: INVALID_PAGE_REQUEST; then the read failures.
fetchPublicKey()
fetchPublicKey(
user):Promise<GalaChainPublicKey|undefined>
Defined in: packages/gala-core-sdk/dist/index.d.ts:2975
The public key GalaChain has registered for user (GetPublicKey of the
public-key-contract, asset channel), or undefined when the chain has none saved for that
user (its PK_NOT_FOUND). The public gateways do not route this contract: build the reads with
a connect-api .../galachain proxy base (https://<connect-api>/galachain), whose answer is
{ Data: { publicKey } } without a Status (a Status that is sent is still checked).
Parameters
user
string
Returns
Promise<GalaChainPublicKey | undefined>
Example
const reads = new GatewayReads({ gatewayBaseUrl: 'https://api-galaswap.gala.com/galachain' });
const registered = await reads.fetchPublicKey('client|64f8caf887fd8551315d8509');
console.log(registered?.publicKey);
Throws
GalaSDKError pre-send: INVALID_WALLET_ADDRESS (field: 'user'); then the read
failures (see the class note).
fetchTokenBalance()
fetchTokenBalance(
input):Promise<GalaChainTokenBalanceSummary|undefined>
Defined in: packages/gala-core-sdk/dist/index.d.ts:2897
The owner's balance of one token class with its holds totalled, or undefined when the chain
has no balance record of it for the owner. Holds that have expired are dropped (they no longer
hold anything) unless includeExpiredHolds.
Parameters
input
Returns
Promise<GalaChainTokenBalanceSummary | undefined>
Throws
GalaSDKError as fetchBalances.
fetchTokenClass()
fetchTokenClass(
tokenClassKey):Promise<GalaChainTokenClass>
Defined in: packages/gala-core-sdk/dist/index.d.ts:2922
The token class of one key.
Parameters
tokenClassKey
Returns
Promise<GalaChainTokenClass>
Throws
GalaSDKError as fetchTokenClasses.
fetchTokenClasses()
fetchTokenClasses(
tokenClassKeys):Promise<GalaChainTokenClass[]>
Defined in: packages/gala-core-sdk/dist/index.d.ts:2911
The token classes of tokenClassKeys (FetchTokenClasses), one per key, in the order asked.
Parameters
tokenClassKeys
readonly TokenClassKeyInput[]
Returns
Promise<GalaChainTokenClass[]>
Throws
GalaSDKError pre-send: INVALID_TOKEN_BATCH (1 to GATEWAY_READ_LIMITS.tokenClasses
keys), INVALID_TOKEN_REFERENCE; TOKEN_CLASS_NOT_FOUND for a key the chain has no class
of; then the read failures.
fetchTokenClassesPage()
fetchTokenClassesPage(
filter?):Promise<GalaChainPage<GalaChainTokenClass>>
Defined in: packages/gala-core-sdk/dist/index.d.ts:2937
One page of the token classes matching filter (FetchTokenClassesWithPagination).
Parameters
filter?
TokenClassesFilter & PageInput
Returns
Promise<GalaChainPage<GalaChainTokenClass>>
Throws
GalaSDKError pre-send: INVALID_TOKEN_REFERENCE, INVALID_PAGE_REQUEST; then the
read failures.
fetchTokenClassesWithSupply()
fetchTokenClassesWithSupply(
tokenClassKeys):Promise<GalaChainTokenClass[]>
Defined in: packages/gala-core-sdk/dist/index.d.ts:2916
As fetchTokenClasses, with the chain's supply figures (knownMintSupply,
knownMintAllowanceSupply) on each class (FetchTokenClassesWithSupply).
Parameters
tokenClassKeys
readonly TokenClassKeyInput[]
Returns
Promise<GalaChainTokenClass[]>
fetchTokenDetails()
fetchTokenDetails(
tokenClassKey):Promise<GalaChainTokenDetails>
Defined in: packages/gala-core-sdk/dist/index.d.ts:2930
The metadata an app shows for a token (its key, symbol, decimals, name, image, description, network and contract address), from its token class: the source of truth for a symbol, which a class key never carries.
Parameters
tokenClassKey
Returns
Promise<GalaChainTokenDetails>
Throws
GalaSDKError as fetchTokenClasses.