Skip to main content
Glama

Rootstock MCP Server

by cuongpo

mint_nft

Create and assign a new NFT for mintable ERC721 contracts on the Rootstock blockchain by specifying contract address, recipient, token ID, and optional metadata URI using the Mint NFT tool.

Instructions

Mint a new NFT for mintable ERC721 contracts

Input Schema

NameRequiredDescriptionDefault
gasLimitNoOptional gas limit
gasPriceNoOptional gas price
toYesAddress to mint NFT to
tokenAddressYesContract address of the mintable NFT
tokenIdYesToken ID for the new NFT
tokenURINoMetadata URI for the NFT (optional)

Input Schema (JSON Schema)

{ "properties": { "gasLimit": { "description": "Optional gas limit", "type": "string" }, "gasPrice": { "description": "Optional gas price", "type": "string" }, "to": { "description": "Address to mint NFT to", "type": "string" }, "tokenAddress": { "description": "Contract address of the mintable NFT", "type": "string" }, "tokenId": { "description": "Token ID for the new NFT", "type": "string" }, "tokenURI": { "description": "Metadata URI for the NFT (optional)", "type": "string" } }, "required": [ "tokenAddress", "to", "tokenId" ], "type": "object" }

Implementation Reference

  • Main handler function for the 'mint_nft' tool. Retrieves the current wallet and delegates to RootstockClient.mintNFT to perform the NFT minting transaction.
    private async handleMintNFT(params: MintNFTParams) { try { const wallet = this.walletManager.getCurrentWallet(); const result = await this.rootstockClient.mintNFT( wallet, params.tokenAddress, params.to, params.tokenId, params.tokenURI || '', params.gasLimit, params.gasPrice ); return { content: [ { type: 'text', text: `NFT Minted Successfully!\n\nTransaction Hash: ${result.transactionHash}\nTo: ${result.to}\nToken ID: ${result.tokenId}${result.tokenURI ? `\nToken URI: ${result.tokenURI}` : ''}\nGas Used: ${result.gasUsed || 'N/A'}\nBlock Number: ${result.blockNumber || 'N/A'}`, }, ], }; } catch (error) { throw new Error(`Failed to mint NFT: ${error}`); } }
  • Core implementation of NFT minting using ethers.js. Creates a contract instance with mintable ERC721 ABI and calls the mint function on the blockchain.
    async mintNFT( wallet: ethers.Wallet | ethers.HDNodeWallet, tokenAddress: string, to: string, tokenId: string, tokenURI: string = '', gasLimit?: string, gasPrice?: string ): Promise<{ transactionHash: string; to: string; tokenId: string; tokenURI?: string; gasUsed?: string; blockNumber?: number; }> { try { const connectedWallet = wallet.connect(this.getProvider()); const nftContract = new ethers.Contract( tokenAddress, this.getMintableERC721ABI(), connectedWallet ); // Convert tokenId to BigInt const parsedTokenId = BigInt(tokenId); const tx = await nftContract.mint(to, parsedTokenId, tokenURI, { gasLimit: gasLimit ? BigInt(gasLimit) : undefined, gasPrice: gasPrice ? BigInt(gasPrice) : undefined, }); const receipt = await tx.wait(); return { transactionHash: tx.hash, to, tokenId, tokenURI: tokenURI || undefined, gasUsed: receipt?.gasUsed.toString(), blockNumber: receipt?.blockNumber, }; } catch (error) { throw new Error(`Failed to mint NFT: ${error}`); } }
  • src/index.ts:536-569 (registration)
    Tool registration in the list of available tools, including name, description, and input schema definition.
    { name: 'mint_nft', description: 'Mint a new NFT for mintable ERC721 contracts', inputSchema: { type: 'object', properties: { tokenAddress: { type: 'string', description: 'Contract address of the mintable NFT', }, to: { type: 'string', description: 'Address to mint NFT to', }, tokenId: { type: 'string', description: 'Token ID for the new NFT', }, tokenURI: { type: 'string', description: 'Metadata URI for the NFT (optional)', }, gasLimit: { type: 'string', description: 'Optional gas limit', }, gasPrice: { type: 'string', description: 'Optional gas price', }, }, required: ['tokenAddress', 'to', 'tokenId'], }, },
  • TypeScript interface defining the input parameters for the mint_nft tool.
    export interface MintNFTParams { tokenAddress: string; to: string; tokenId: string; tokenURI: string; gasLimit?: string; gasPrice?: string; }
  • ABI definition for the mintable ERC721 contract used in the mintNFT function.
    private getMintableERC721ABI(): string[] { return [ // Mintable ERC721 Interface (extends standard ERC721) "constructor(string name, string symbol)", "function name() view returns (string)", "function symbol() view returns (string)", "function tokenURI(uint256 tokenId) view returns (string)", "function totalSupply() view returns (uint256)", "function balanceOf(address owner) view returns (uint256)", "function ownerOf(uint256 tokenId) view returns (address)", "function getApproved(uint256 tokenId) view returns (address)", "function isApprovedForAll(address owner, address operator) view returns (bool)", "function approve(address to, uint256 tokenId)", "function setApprovalForAll(address operator, bool approved)", "function transferFrom(address from, address to, uint256 tokenId)", "function safeTransferFrom(address from, address to, uint256 tokenId)", "function safeTransferFrom(address from, address to, uint256 tokenId, bytes data)", "function mint(address to, uint256 tokenId, string tokenURI)", "function owner() view returns (address)", "function renounceOwnership()", "function transferOwnership(address newOwner)", "event Transfer(address indexed from, address indexed to, uint256 indexed tokenId)", "event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId)", "event ApprovalForAll(address indexed owner, address indexed operator, bool approved)", "event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)" ];

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cuongpo/rootstock-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server