Skip to main content
Glama
cuongpo

Rootstock MCP Server

by cuongpo

deploy_erc721_token

Deploy a new ERC721 NFT token contract on the Rootstock blockchain. Specify collection name, symbol, and mintable option to create your NFT smart contract using Rootstock MCP Server.

Instructions

Deploy a new ERC721 (NFT) token contract

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
gasLimitNoOptional gas limit
gasPriceNoOptional gas price
mintableNoWhether the NFT should be mintable (default: false)
nameYesNFT collection name (e.g., "My NFT Collection")
symbolYesNFT collection symbol (e.g., "MYNFT")

Implementation Reference

  • MCP tool handler function that gets the current wallet, calls rootstockClient.deployERC721Token with parameters, and returns formatted success response with contract details.
    private async handleDeployERC721Token(params: DeployERC721Params) {
      try {
        const wallet = this.walletManager.getCurrentWallet();
        const result = await this.rootstockClient.deployERC721Token(
          wallet,
          params.name,
          params.symbol,
          params.mintable || false,
          params.gasLimit,
          params.gasPrice
        );
    
        return {
          content: [
            {
              type: 'text',
              text: `ERC721 NFT Contract Deployed Successfully!\n\nContract Address: ${result.contractAddress}\nTransaction Hash: ${result.transactionHash}\nName: ${result.name}\nSymbol: ${result.symbol}\nDeployer: ${result.deployer}${result.gasUsed ? `\nGas Used: ${result.gasUsed}` : ''}${result.blockNumber ? `\nBlock Number: ${result.blockNumber}` : ''}`,
            },
          ],
        };
      } catch (error) {
        throw new Error(`Failed to deploy ERC721 token: ${error}`);
      }
  • src/index.ts:489-516 (registration)
    Tool registration in getAvailableTools() array, defining name, description, and input schema matching DeployERC721Params.
    name: 'deploy_erc721_token',
    description: 'Deploy a new ERC721 (NFT) token contract',
    inputSchema: {
      type: 'object',
      properties: {
        name: {
          type: 'string',
          description: 'NFT collection name (e.g., "My NFT Collection")',
        },
        symbol: {
          type: 'string',
          description: 'NFT collection symbol (e.g., "MYNFT")',
        },
        mintable: {
          type: 'boolean',
          description: 'Whether the NFT should be mintable (default: false)',
        },
        gasLimit: {
          type: 'string',
          description: 'Optional gas limit',
        },
        gasPrice: {
          type: 'string',
          description: 'Optional gas price',
        },
      },
      required: ['name', 'symbol'],
    },
  • TypeScript interface defining input parameters for deploy_erc721_token tool.
    export interface DeployERC721Params {
      name: string;
      symbol: string;
      mintable?: boolean;
      gasLimit?: string;
      gasPrice?: string;
  • Core helper method in RootstockClient that performs the actual ERC721 contract deployment using ethers.js ContractFactory with pre-compiled ABI/bytecode.
    async deployERC721Token(
      wallet: ethers.Wallet | ethers.HDNodeWallet,
      name: string,
      symbol: string,
      mintable: boolean = false,
      gasLimit?: string,
      gasPrice?: string
    ): Promise<ERC721DeploymentResponse> {
      try {
        const connectedWallet = wallet.connect(this.getProvider());
    
        // Check wallet balance first
        const balance = await this.getProvider().getBalance(wallet.address);
        console.log(`Wallet balance: ${ethers.formatEther(balance)} ${this.getCurrencySymbol()}`);
    
        if (balance === 0n) {
          throw new Error(`Wallet has no funds for deployment. Please fund the wallet: ${wallet.address}`);
        }
    
        // Get pre-compiled ERC721 contract
        console.log('Loading ERC721 contract...');
        const compiled = this.getCompiledERC721Contract(mintable);
        console.log('Contract loaded successfully');
    
        // Create contract factory
        const contractFactory = new ethers.ContractFactory(
          compiled.abi,
          compiled.bytecode,
          connectedWallet
        );
    
        console.log(`Deploying ERC721 contract: ${name} (${symbol})`);
    
        // Deploy contract with parameters: name, symbol
        const contract = await contractFactory.deploy(
          name,
          symbol,
          {
            gasLimit: gasLimit ? BigInt(gasLimit) : undefined,
            gasPrice: gasPrice ? BigInt(gasPrice) : undefined,
          }
        );
    
        console.log('Contract deployment transaction sent, waiting for confirmation...');
    
        // Wait for deployment
        const receipt = await contract.deploymentTransaction()?.wait();
        console.log('ERC721 contract deployed successfully!');
    
        const contractAddress = await contract.getAddress();
        console.log(`Contract address: ${contractAddress}`);
    
        return {
          contractAddress,
          transactionHash: contract.deploymentTransaction()?.hash || '',
          name,
          symbol,
          deployer: wallet.address,
          gasUsed: receipt?.gasUsed.toString(),
          blockNumber: receipt?.blockNumber,
        };
      } catch (error) {
        console.error('ERC721 deployment error:', error);
        throw new Error(`Failed to deploy ERC721 token: ${error}`);
      }

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