For developers who prefer granular control over the minting process, you can use vanilla TypeScript with viem, a TypeScript interface for EVM-based projects. The Ethers.js library is also a robust approach.
Going vanilla requires you to perform a bit more work than when relying on frameworks such as thirdweb. For instance, unless you run your own IPFS node, you will need to rely on an NFT storage platforms, which are for-pay.
This example uses Pinata as an IPFS host.
You will also need to deploy an OpenZeppelin ERC-721 contract on Chiliz Chain yourself. Remix IDE gives you an in-browser to do it. Don't forget to verify the contract using a block explorer!
Now, let's install viem, the Pinata SDK, and the dotenv module:
npmiviempinatadotenv
Configure your .env file to work with your needs:
# Wallet / contract
PRIVATE_KEY=0xabc... # server-side only
CONTRACT_ADDRESS=0xYourErc721Address
RECIPIENT=0xRecipientOrLeaveEmpty # optional; defaults to minter
# Pinata
PINATA_JWT=eyJhbGciOi... # JWT from Pinata dashboard
PINATA_GATEWAY=your-subdomain.mypinata.cloud
# Single mint
IMAGE_PATH=./art/image.png
NAME=My Chiliz NFT
DESCRIPTION=Minted on Chiliz with viem
# Batch mint
IMAGES_DIR=./art
NAME_PREFIX=My Chiliz NFT
BATCH_DESCRIPTION=Batch minted on Chiliz with viem
Now, let's dive into the code.
Take inspiration from it, don't use as-is!