NftClient

Methods

  • createNFTCollection
  • getMintFeeToken
  • getMintFee

createNFTCollection

Creates a new SPG NFT Collection.

MethodType
createNFTCollection(request: CreateNFTCollectionRequest) => Promise<CreateNFTCollectionResponse>

Parameters:

  • request.name: The name of the collection.
  • request.symbol: The symbol of the collection.
  • request.isPublicMinting: If true, anyone can mint from the collection. If false, only the addresses with the minter role can mint.
  • request.mintOpen: Whether the collection is open for minting on creation.
  • request.mintFeeRecipient: The address to receive mint fees.
  • request.contractURI: The contract URI for the collection. Follows ERC-7572 standard. See here.
  • request.baseURI: [Optional] The base URI for the collection. If baseURI is not empty, tokenURI will be either baseURI + token ID (if nftMetadataURI is empty) or baseURI + nftMetadataURI.
  • request.maxSupply: [Optional] The maximum supply of the collection.
  • request.mintFee: [Optional] The cost to mint a token.
  • request.mintFeeToken: [Optional] The token to mint.
  • request.owner: [Optional] The owner of the collection.
  • request.txOptions: [Optional] The transaction options.
import { zeroAddress } from "viem";

// Create a new SPG NFT collection
//
// NOTE: Use this code to create a new SPG NFT collection. You can then use the
// `newCollection.spgNftContract` address as the `spgNftContract` argument in
// functions like `mintAndRegisterIpAssetWithPilTerms` in the
// `simpleMintAndRegisterSpg.ts` file.
//
// You will mostly only have to do this once. Once you get your nft contract address,
// you can use it in SPG functions.
//
const newCollection = await client.nftClient.createNFTCollection({
  name: "Test NFT",
  symbol: "TEST",
  isPublicMinting: true,
  mintOpen: true,
  mintFeeRecipient: zeroAddress,
  contractURI: "",
  txOptions: { waitForTransaction: true },
});

console.log(
  `New SPG NFT collection created at transaction hash ${newCollection.txHash}`
);
console.log(`NFT contract address: ${newCollection.spgNftContract}`);

getMintFeeToken

Returns the current mint token of the collection.

MethodType
getMintFeeToken(spgNftContract: Address) => Promise<Address>

Parameters:

  • spgNftContract: The address of the NFT contract.
const mintFeeToken = await client.nftClient.getMintFeeToken("0x01");

getMintFee

Returns the current mint fee of the collection.

MethodType
getMintFee(spgNftContract: Address) => Promise<bigint>

Parameters:

  • spgNftContract: The address of the NFT contract.
const mintFee = await client.nftClient.getMintFee("0x01");