Skip to main content
Glama

Rootstock MCP Server

by cuongpo

deploy_erc20_token

Deploy a custom ERC20 token contract on the Rootstock blockchain using the Rootstock MCP Server. Specify token name, symbol, initial supply, and optional features like mintability and decimals.

Instructions

Deploy a new ERC20 token contract

Input Schema

NameRequiredDescriptionDefault
decimalsNoToken decimals (default: 18)
gasLimitNoOptional gas limit
gasPriceNoOptional gas price
initialSupplyYesInitial token supply
mintableNoWhether the token should be mintable (default: false)
nameYesToken name (e.g., "My Token")
symbolYesToken symbol (e.g., "MTK")

Input Schema (JSON Schema)

{ "properties": { "decimals": { "description": "Token decimals (default: 18)", "type": "number" }, "gasLimit": { "description": "Optional gas limit", "type": "string" }, "gasPrice": { "description": "Optional gas price", "type": "string" }, "initialSupply": { "description": "Initial token supply", "type": "string" }, "mintable": { "description": "Whether the token should be mintable (default: false)", "type": "boolean" }, "name": { "description": "Token name (e.g., \"My Token\")", "type": "string" }, "symbol": { "description": "Token symbol (e.g., \"MTK\")", "type": "string" } }, "required": [ "name", "symbol", "initialSupply" ], "type": "object" }

Implementation Reference

  • src/index.ts:406-443 (registration)
    Tool registration in getAvailableTools() including name, description, and input schema for deploy_erc20_token
    { name: 'deploy_erc20_token', description: 'Deploy a new ERC20 token contract', inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Token name (e.g., "My Token")', }, symbol: { type: 'string', description: 'Token symbol (e.g., "MTK")', }, decimals: { type: 'number', description: 'Token decimals (default: 18)', }, initialSupply: { type: 'string', description: 'Initial token supply', }, mintable: { type: 'boolean', description: 'Whether the token should be mintable (default: false)', }, gasLimit: { type: 'string', description: 'Optional gas limit', }, gasPrice: { type: 'string', description: 'Optional gas price', }, }, required: ['name', 'symbol', 'initialSupply'], }, },
  • MCP server handler that gets current wallet, calls rootstockClient.deployERC20Token, and formats success response with explorer links
    private async handleDeployERC20Token(params: DeployERC20Params) { try { const wallet = this.walletManager.getCurrentWallet(); const result = await this.rootstockClient.deployERC20Token( wallet, params.name, params.symbol, params.decimals || 18, params.initialSupply, params.mintable || false, params.gasLimit, params.gasPrice ); const explorerUrl = this.rootstockClient.getExplorerUrl(); const contractExplorerLink = `${explorerUrl}/address/${result.contractAddress}`; const txExplorerLink = `${explorerUrl}/tx/${result.transactionHash}`; return { content: [ { type: 'text', text: `ERC20 Token Deployed Successfully!\n\nContract Address: ${result.contractAddress}\nContract Explorer: ${contractExplorerLink}\n\nTransaction Hash: ${result.transactionHash}\nTransaction Explorer: ${txExplorerLink}\n\nToken Details:\nName: ${result.name}\nSymbol: ${result.symbol}\nDecimals: ${result.decimals}\nInitial Supply: ${result.initialSupply}\nDeployer: ${result.deployer}\nGas Used: ${result.gasUsed}\nBlock Number: ${result.blockNumber}`, }, ], }; } catch (error) { throw new Error(`Failed to deploy ERC20 token: ${error}`); } }
  • Core deployment logic in RootstockClient: checks balance, loads pre-compiled contract bytecode/ABI based on mintable, deploys via ethers.ContractFactory.deploy(name, symbol, initialSupply, decimals), waits for receipt, returns contract details
    async deployERC20Token( wallet: ethers.Wallet | ethers.HDNodeWallet, name: string, symbol: string, decimals: number = 18, initialSupply: string, mintable: boolean = false, gasLimit?: string, gasPrice?: string ): Promise<{ contractAddress: string; transactionHash: string; name: string; symbol: string; decimals: number; initialSupply: string; deployer: string; gasUsed?: string; blockNumber?: number; }> { 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 contract console.log('Loading ERC20 contract...'); const compiled = this.getCompiledERC20Contract(mintable); console.log('Contract loaded successfully'); // Create contract factory const contractFactory = new ethers.ContractFactory( compiled.abi, compiled.bytecode, connectedWallet ); // Parse initial supply (raw number, contract handles decimals) const parsedInitialSupply = BigInt(initialSupply); console.log(`Deploying contract with initial supply: ${parsedInitialSupply.toString()}`); // Deploy contract with Hyperion-compatible parameters: name, symbol, initialSupply, decimals const contract = await contractFactory.deploy( name, symbol, parsedInitialSupply, decimals, { 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('Contract deployed successfully!'); const contractAddress = await contract.getAddress(); console.log(`Contract address: ${contractAddress}`); return { contractAddress, transactionHash: contract.deploymentTransaction()?.hash || '', name, symbol, decimals, initialSupply, deployer: wallet.address, gasUsed: receipt?.gasUsed.toString(), blockNumber: receipt?.blockNumber, }; } catch (error) { console.error('Deployment error:', error); throw new Error(`Failed to deploy ERC20 token: ${error}`); } }
  • Helper that returns ABI and hardcoded bytecode for standard or mintable ERC20 contract used in deployment
    private getCompiledERC20Contract(mintable: boolean): { abi: string[], bytecode: string } { // Use the working Hyperion-compatible bytecode directly if (mintable) { return { abi: this.getMintableERC20ABI(), bytecode: "0x60806040523480156200001157600080fd5b506040516200104538038062001045833981016040819052620000349162000361565b33848460036200004583826200047d565b5060046200005482826200047d565b5050506001600160a01b0381166200008757604051631e4fbdf760e01b8152600060048201526024015b60405180910390fd5b6200009281620000d9565b506005805460ff60a01b1916600160a01b60ff841602179055620000cf33620000bd83600a6200065e565b620000c9908562000676565b6200012b565b50505050620006a6565b600580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b038216620001575760405163ec442f0560e01b8152600060048201526024016200007e565b620001656000838362000169565b5050565b6001600160a01b038316620001985780600260008282546200018c919062000690565b909155506200020c9050565b6001600160a01b03831660009081526020819052604090205481811015620001ed5760405163391434e360e21b81526001600160a01b038516600482015260248101829052604481018390526064016200007e565b6001600160a01b03841660009081526020819052604090209082900390555b6001600160a01b0382166200022a5760028054829003905562000249565b6001600160a01b03821660009081526020819052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040516200028f91815260200190565b60405180910390a3505050565b634e487b7160e01b600052604160045260246000fd5b600082601f830112620002c457600080fd5b81516001600160401b0380821115620002e157620002e16200029c565b604051601f8301601f19908116603f011681019082821181831017156200030c576200030c6200029c565b816040528381526020925086838588010111156200032957600080fd5b600091505b838210156200034d57858201830151818301840152908201906200032e565b600093810190920192909252949350505050565b600080600080608085870312156200037857600080fd5b84516001600160401b03808211156200039057600080fd5b6200039e88838901620002b2565b95506020870151915080821115620003b557600080fd5b50620003c487828801620002b2565b93505060408501519150606085015160ff81168114620003e357600080fd5b939692955090935050565b600181811c908216806200040357607f821691505b6020821081036200042457634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200047857600081815260208120601f850160051c81016020861015620004535750805b601f850160051c820191505b8181101562000474578281556001016200045f565b5050505b505050565b81516001600160401b038111156200049957620004996200029c565b620004b181620004aa8454620003ee565b846200042a565b602080601f831160018114620004e95760008415620004d05750858301515b600019600386901b1c1916600185901b17855562000474565b600085815260208120601f198616915b828110156200051a57888601518255948401946001909101908401620004f9565b5085821015620005395787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b600052601160045260246000fd5b600181815b80851115620005a057816000190482111562000584576200058462000549565b808516156200059257918102915b93841c939080029062000564565b509250929050565b600082620005b95750600162000658565b81620005c85750600062000658565b8160018114620005e15760028114620005ec576200060c565b600191505062000658565b60ff84111562000600576200060062000549565b50506001821b62000658565b5060208310610133831016604e8410600b841016171562000631575081810a62000658565b6200063d83836200055f565b806000190482111562000654576200065462000549565b0290505b92915050565b60006200066f60ff841683620005a8565b9392505050565b808202811582820484141762000658576200065862000549565b8082018082111562000658576200065862000549565b61098f80620006b66000396000f3fe608060405234801561001057600080fd5b50600436106100f55760003560e01c806370a082311161009757806395d89b411161006657806395d89b4114610206578063a9059cbb1461020e578063dd62ed3e14610221578063f2fde38b1461025a57600080fd5b806370a08231146101a7578063715018a6146101d057806379cc6790146101d85780638da5cb5b146101eb57600080fd5b806323b872dd116100d357806323b872dd1461014d578063313ce5671461016057806340c10f191461017f57806342966c681461019457600080fd5b806306fdde03146100fa578063095ea7b31461011857806318160ddd1461013b575b600080fd5b61010261026d565b60405161010f91906107c0565b60405180910390f35b61012b61012636600461082a565b6102ff565b604051901515815260200161010f565b6002545b60405190815260200161010f565b61012b61015b366004610854565b610319565b600554600160a01b900460ff1660405160ff909116815260200161010f565b61019261018d36600461082a565b61033d565b005b6101926101a2366004610890565b610353565b61013f6101b53660046108a9565b6001600160a01b031660009081526020819052604090205490565b610192610360565b6101926101e636600461082a565b610374565b6005546040516001600160a01b03909116815260200161010f565b610102610389565b61012b61021c36600461082a565b610398565b61013f61022f3660046108cb565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6101926102683660046108a9565b6103a6565b60606003805461027c906108fe565b80601f01602080910402602001604051908101604052809291908181526020018280546102a8906108fe565b80156102f55780601f106102ca576101008083540402835291602001916102f5565b820191906000526020600020905b8154815290600101906020018083116102d857829003601f168201915b5050505050905090565b60003361030d8185856103e6565b60019150505b92915050565b6000336103278582856103f8565b610332858585610477565b506001949350505050565b6103456104d6565b61034f8282610503565b5050565b61035d3382610539565b50565b6103686104d6565b610372600061056f565b565b61037f8233836103f8565b61034f8282610539565b60606004805461027c906108fe565b60003361030d818585610477565b6103ae6104d6565b6001600160a01b0381166103dd57604051631e4fbdf760e01b8152600060048201526024015b60405180910390fd5b61035d8161056f565b6103f383838360016105c1565b505050565b6001600160a01b03838116600090815260016020908152604080832093861683529290522054600019811015610471578181101561046257604051637dc7a0d960e11b81526001600160a01b038416600482015260248101829052604481018390526064016103d4565b610471848484840360006105c1565b50505050565b6001600160a01b0383166104a157604051634b637e8f60e11b8152600060048201526024016103d4565b6001600160a01b0382166104cb5760405163ec442f0560e01b8152600060048201526024016103d4565b6103f3838383610696565b6005546001600160a01b031633146103725760405163118cdaa760e01b81523360048201526024016103d4565b6001600160a01b03821661052d5760405163ec442f0560e01b8152600060048201526024016103d4565b61034f60008383610696565b6001600160a01b03821661056357604051634b637e8f60e11b8152600060048201526024016103d4565b61034f82600083610696565b600580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b0384166105eb5760405163e602df0560e01b8152600060048201526024016103d4565b6001600160a01b03831661061557604051634a1406b160e11b8152600060048201526024016103d4565b6001600160a01b038085166000908152600160209081526040808320938716835292905220829055801561047157826001600160a01b0316846001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258460405161068891815260200190565b60405180910390a350505050565b6001600160a01b0383166106c15780600260008282546106b69190610938565b909155506107339050565b6001600160a01b038316600090815260208190526040902054818110156107145760405163391434e360e21b81526001600160a01b038516600482015260248101829052604481018390526064016103d4565b6001600160a01b03841660009081526020819052604090209082900390555b6001600160a01b03821661074f5760028054829003905561076e565b6001600160a01b03821660009081526020819052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040516107b391815260200190565b60405180910390a3505050565b600060208083528351808285015260005b818110156107ed578581018301518582016040015282016107d1565b506000604082860101526040601f19601f8301168501019250505092915050565b80356001600160a01b038116811461082557600080fd5b919050565b6000806040838503121561083d57600080fd5b6108468361080e565b946020939093013593505050565b60008060006060848603121561086957600080fd5b6108728461080e565b92506108806020850161080e565b9150604084013590509250925092565b6000602082840312156108a257600080fd5b5035919050565b6000602082840312156108bb57600080fd5b6108c48261080e565b9392505050565b600080604083850312156108de57600080fd5b6108e78361080e565b91506108f56020840161080e565b90509250929050565b600181811c9082168061091257607f821691505b60208210810361093257634e487b7160e01b600052602260045260246000fd5b50919050565b8082018082111561031357634e487b7160e01b600052601160045260246000fdfea2646970667358221220938ed275b5511b8b2f96e26e5f9612165645a0fd30b36a37d277c10770552ed464736f6c63430008140033" }; } else { return { abi: this.getStandardERC20ABI(), bytecode: "0x60806040523480156200001157600080fd5b5060405162000d4938038062000d498339810160408190526200003491620002cd565b83836003620000448382620003e9565b506004620000538282620003e9565b50506005805460ff191660ff84161790555062000089336200007783600a620005ca565b620000839085620005e2565b62000093565b5050505062000612565b6001600160a01b038216620000c35760405163ec442f0560e01b8152600060048201526024015b60405180910390fd5b620000d160008383620000d5565b5050565b6001600160a01b03831662000104578060026000828254620000f89190620005fc565b90915550620001789050565b6001600160a01b03831660009081526020819052604090205481811015620001595760405163391434e360e21b81526001600160a01b03851660048201526024810182905260448101839052606401620000ba565b6001600160a01b03841660009081526020819052604090209082900390555b6001600160a01b0382166200019657600280548290039055620001b5565b6001600160a01b03821660009081526020819052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef83604051620001fb91815260200190565b60405180910390a3505050565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126200023057600080fd5b81516001600160401b03808211156200024d576200024d62000208565b604051601f8301601f19908116603f0116810190828211818310171562000278576200027862000208565b816040528381526020925086838588010111156200029557600080fd5b600091505b83821015620002b957858201830151818301840152908201906200029a565b600093810190920192909252949350505050565b60008060008060808587031215620002e457600080fd5b84516001600160401b0380821115620002fc57600080fd5b6200030a888389016200021e565b955060208701519150808211156200032157600080fd5b5062000330878288016200021e565b93505060408501519150606085015160ff811681146200034f57600080fd5b939692955090935050565b600181811c908216806200036f57607f821691505b6020821081036200039057634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115620003e457600081815260208120601f850160051c81016020861015620003bf5750805b601f850160051c820191505b81811015620003e057828155600101620003cb565b5050505b505050565b81516001600160401b0381111562000405576200040562000208565b6200041d816200041684546200035a565b8462000396565b602080601f8311600181146200045557600084156200043c5750858301515b600019600386901b1c1916600185901b178555620003e0565b600085815260208120601f198616915b82811015620004865788860151825594840194600190910190840162000465565b5085821015620004a55787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b600052601160045260246000fd5b600181815b808511156200050c578160001904821115620004f057620004f0620004b5565b80851615620004fe57918102915b93841c9390800290620004d0565b509250929050565b6000826200052557506001620005c4565b816200053457506000620005c4565b81600181146200054d5760028114620005585762000578565b6001915050620005c4565b60ff8411156200056c576200056c620004b5565b50506001821b620005c4565b5060208310610133831016604e8410600b84101617156200059d575081810a620005c4565b620005a98383620004cb565b8060001904821115620005c057620005c0620004b5565b0290505b92915050565b6000620005db60ff84168362000514565b9392505050565b8082028115828204841417620005c457620005c4620004b5565b80820180821115620005c457620005c4620004b5565b61072780620006226000396000f3fe608060405234801561001057600080fd5b50600436106100935760003560e01c8063313ce56711610066578063313ce567146100fe57806370a082311461011357806395d89b411461013c578063a9059cbb14610144578063dd62ed3e1461015757600080fd5b806306fdde0314610098578063095ea7b3146100b657806318160ddd146100d957806323b872dd146100eb575b600080fd5b6100a0610190565b6040516100ad9190610571565b60405180910390f35b6100c96100c43660046105db565b610222565b60405190151581526020016100ad565b6002545b6040519081526020016100ad565b6100c96100f9366004610605565b61023c565b60055460405160ff90911681526020016100ad565b6100dd610121366004610641565b6001600160a01b031660009081526020819052604090205490565b6100a0610260565b6100c96101523660046105db565b61026f565b6100dd610165366004610663565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b60606003805461019f90610696565b80601f01602080910402602001604051908101604052809291908181526020018280546101cb90610696565b80156102185780601f106101ed57610100808354040283529160200191610218565b820191906000526020600020905b8154815290600101906020018083116101fb57829003601f168201915b5050505050905090565b60003361023081858561027d565b60019150505b92915050565b60003361024a85828561028f565b610255858585610313565b506001949350505050565b60606004805461019f90610696565b600033610230818585610313565b61028a8383836001610372565b505050565b6001600160a01b0383811660009081526001602090815260408083209386168352929052205460001981101561030d57818110156102fe57604051637dc7a0d960e11b81526001600160a01b038416600482015260248101829052604481018390526064015b60405180910390fd5b61030d84848484036000610372565b50505050565b6001600160a01b03831661033d57604051634b637e8f60e11b8152600060048201526024016102f5565b6001600160a01b0382166103675760405163ec442f0560e01b8152600060048201526024016102f5565b61028a838383610447565b6001600160a01b03841661039c5760405163e602df0560e01b8152600060048201526024016102f5565b6001600160a01b0383166103c657604051634a1406b160e11b8152600060048201526024016102f5565b6001600160a01b038085166000908152600160209081526040808320938716835292905220829055801561030d57826001600160a01b0316846001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258460405161043991815260200190565b60405180910390a350505050565b6001600160a01b03831661047257806002600082825461046791906106d0565b909155506104e49050565b6001600160a01b038316600090815260208190526040902054818110156104c55760405163391434e360e21b81526001600160a01b038516600482015260248101829052604481018390526064016102f5565b6001600160a01b03841660009081526020819052604090209082900390555b6001600160a01b0382166105005760028054829003905561051f565b6001600160a01b03821660009081526020819052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405161056491815260200190565b60405180910390a3505050565b600060208083528351808285015260005b8181101561059e57858101830151858201604001528201610582565b506000604082860101526040601f19601f8301168501019250505092915050565b80356001600160a01b03811681146105d657600080fd5b919050565b600080604083850312156105ee57600080fd5b6105f7836105bf565b946020939093013593505050565b60008060006060848603121561061a57600080fd5b610623846105bf565b9250610631602085016105bf565b9150604084013590509250925092565b60006020828403121561065357600080fd5b61065c826105bf565b9392505050565b6000806040838503121561067657600080fd5b61067f836105bf565b915061068d602084016105bf565b90509250929050565b600181811c908216806106aa57607f821691505b6020821081036106ca57634e487b7160e01b600052602260045260246000fd5b50919050565b8082018082111561023657634e487b7160e01b600052601160045260246000fdfea26469706673582212201e68b46dcb693b803d805da44bfc3b18ba7b19addfa4b50f59dedc2a8c5f9be364736f6c63430008140033" }; } }
  • TypeScript interface defining input parameters for deploy_erc20_token tool
    export interface DeployERC20Params { name: string; symbol: string; decimals?: number; initialSupply: string; mintable?: boolean; burnable?: boolean; gasLimit?: string; gasPrice?: string; }

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