Skip to main content

index/classes/NftCollectionService.md

NFT Collection Service

Manages all NFT-related operations including collection claims, token class creation, and NFT minting on GalaChain.

Fee Structure:

  • Collection Claim: 10,000 GALA
  • Token Class Create: 1,000 GALA
  • Mint NFT: Dynamic fee (estimated via DryRun)

Example​

const service = new NftCollectionService(httpClient, galaChainClient);

// Get collection claim fee
const fee = service.getCollectionClaimFee(); // "10000"

// Claim a collection
const result = await service.claimCollection({
collectionName: 'my-collection'
});

Extends​

  • BaseService

Constructors​

Constructor​

new NftCollectionService(httpClient): NftCollectionService

Parameters​

ParameterType
httpClientHttpClient

Returns​

NftCollectionService

Overrides​

BaseService.constructor

Methods​

claimCollection()​

claimCollection(params): Promise<ClaimCollectionResult>

Claim an NFT collection name

Parameters​

ParameterTypeDescription
paramsClaimCollectionParamsCollection claim parameters

Returns​

Promise<ClaimCollectionResult>

Claim result with transaction ID

Throws​

Error if collection name is invalid or already claimed


createTokenClass()​

createTokenClass(params): Promise<CreateTokenClassResult>

Create a token class within an NFT collection

Parameters​

ParameterTypeDescription
paramsCreateTokenClassParamsToken class creation parameters

Returns​

Promise<CreateTokenClassResult>

Creation result with transaction ID

Throws​

Error if parameters are invalid or user lacks authorization


estimateMintFee()​

estimateMintFee(params): Promise<string>

Estimate minting fee for NFTs via DryRun

Parameters​

ParameterTypeDescription
paramsEstimateMintFeeParamsMint parameters (collection, type, category, quantity, owner)

Returns​

Promise<string>

Estimated fee in GALA

Throws​

Error if DryRun fails


estimateNftOperationFees()​

estimateNftOperationFees(params): NftFeeEstimate

Calculate total fees for multiple NFT operations

Parameters​

ParameterTypeDescription
paramsEstimateNftFeesParamsOperations to estimate (claimCollection, createTokenClasses count)

Returns​

NftFeeEstimate

Fee breakdown with total


fetchNftBalances()​

fetchNftBalances(ownerAddress, collectionFilter?): Promise<NftBalance[]>

Fetch NFT balances for an owner: the owner's GalaChain balance records (FetchBalances) that hold at least one token instance, optionally of one collection.

Parameters​

ParameterTypeDescription
ownerAddressstringOwner wallet address (eth|<40 hex>)
collectionFilter?stringOptional collection name to filter by

Returns​

Promise<NftBalance[]>

List of NFT balances


fetchTokenClasses()​

fetchTokenClasses(params): Promise<NftTokenClassWithSupply[]>

Fetch the token classes of a collection (FetchTokenClassesWithPagination, page by page, bounded), optionally narrowed by type and category.

Parameters​

ParameterTypeDescription
paramsFetchTokenClassesParamsQuery parameters (collection, type, category)

Returns​

Promise<NftTokenClassWithSupply[]>

List of token classes with supply info


fetchUserCollections()​

fetchUserCollections(walletAddress): Promise<NftCollectionAuthorization[]>

Fetch all NFT collections authorized to a user: every collection authorization on GalaChain (FetchNftCollectionAuthorizationsWithPagination, page by page, bounded) whose authorized users include walletAddress.

Parameters​

ParameterTypeDescription
walletAddressstringWallet address to fetch collections for (eth|<40 hex>)

Returns​

Promise<NftCollectionAuthorization[]>

List of authorized collections

Throws​

Error for an address that is not eth|<40 hex>; the read's errors otherwise


getCollectionClaimFee()​

getCollectionClaimFee(): string

Get the fee to claim an NFT collection

Returns​

string

Fee amount in GALA as string ("10000")


getTokenClassCreateFee()​

getTokenClassCreateFee(): string

Get the fee to create a token class

Returns​

string

Fee amount in GALA as string ("1000")


isCollectionAvailable()​

isCollectionAvailable(collectionName): Promise<boolean>

Check if an NFT collection name is available: no collection authorization on GalaChain names it. A read that fails (or a set of authorizations larger than the read's page bound) throws: it is never reported as "available".

Parameters​

ParameterTypeDescription
collectionNamestringCollection name to check

Returns​

Promise<boolean>

True if available, false if already claimed


mintNft()​

mintNft(params): Promise<MintNftResult>

Mint NFTs from a token class

Parameters​

ParameterTypeDescription
paramsMintNftParamsMinting parameters

Returns​

Promise<MintNftResult>

Minting result with transaction ID

Throws​

Error if parameters invalid or user lacks balance


setJwtAuth()​

setJwtAuth(jwtAuth): void

Set the JWT authentication manager. Allows dynamic configuration of JWT auth after service creation.

Parameters​

ParameterTypeDescription
jwtAuthJwtAuthJWT auth manager instance

Returns​

void

Inherited from​

BaseService.setJwtAuth