Mint new NFTs into existing collections on Solana. Support both self-minting and minting to specific recipients with custom metadata.
Usage
// Mint to your own wallet
const nft = await agent.mintNFT(
new PublicKey("collection-address"),
{
name: "My NFT",
uri: "https://arweave.net/nft.json"
}
);
// Mint to a recipient
const nft = await agent.mintNFT(
new PublicKey("collection-address"),
{
name: "Gift NFT",
uri: "https://arweave.net/gift.json"
},
new PublicKey("recipient-address")
);
Parameter
Type
Required
Description
collectionMint
PublicKey
Yes
Collection address to mint into
metadata.name
string
Yes
Name of the NFT
metadata.uri
string
Yes
Metadata URI for the NFT
recipient
PublicKey
No
Recipient address (defaults to minter)
"Mint a new NFT called 'Awesome Art #1' in my collection"
"Create NFT with metadata from arweave and send it to wallet address"
"Mint NFT as a gift to recipient 9aUn5swQzUTRanaaTwmszxiv89cvFwUCjEBv1vZCoT1u"
"Add new NFT to my collection with name 'Rare Item #42'"
// Basic NFT mint to own wallet
{
"collectionMint": "J1S9H3QjnRtBbbuD4HjPV6RpRhwuk4zKbxsnCHuTgh9w",
"name": "Awesome Art #1",
"uri": "https://arweave.net/nft.json"
}
// Mint NFT to specific recipient
{
"collectionMint": "J1S9H3QjnRtBbbuD4HjPV6RpRhwuk4zKbxsnCHuTgh9w",
"name": "Gift NFT #1",
"uri": "https://arweave.net/gift.json",
"recipient": "9aUn5swQzUTRanaaTwmszxiv89cvFwUCjEBv1vZCoT1u"
}
import { SolanaAgentKit } from "solana-agent-kit";
import { PublicKey } from "@solana/web3.js";
async function mintCollectionNFTs(agent: SolanaAgentKit) {
// Collection address
const collection = new PublicKey("collection-address");
// Mint to own wallet
const nft1 = await agent.mintNFT(
collection,
{
name: "My NFT #1",
uri: "https://arweave.net/nft1.json"
}
);
console.log("Minted NFT:", nft1.mint.toString());
// Mint to recipient
const recipient = new PublicKey("recipient-address");
const nft2 = await agent.mintNFT(
collection,
{
name: "Gift NFT #1",
uri: "https://arweave.net/nft2.json"
},
recipient
);
console.log("Minted gift NFT:", nft2.mint.toString());
}
Your NFT metadata URI should point to a JSON file with this structure: