mint_tokens
Mint ERC20 tokens on Rootstock by specifying the token contract address, recipient, and amount. Optional gas limit and price parameters available. Works with mintable tokens only.
Instructions
Mint tokens (only for mintable tokens)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| amount | Yes | Amount of tokens to mint | |
| gasLimit | No | Optional gas limit | |
| gasPrice | No | Optional gas price | |
| to | Yes | Address to mint tokens to | |
| tokenAddress | Yes | ERC20 token contract address |
Input Schema (JSON Schema)
{
"properties": {
"amount": {
"description": "Amount of tokens to mint",
"type": "string"
},
"gasLimit": {
"description": "Optional gas limit",
"type": "string"
},
"gasPrice": {
"description": "Optional gas price",
"type": "string"
},
"to": {
"description": "Address to mint tokens to",
"type": "string"
},
"tokenAddress": {
"description": "ERC20 token contract address",
"type": "string"
}
},
"required": [
"tokenAddress",
"to",
"amount"
],
"type": "object"
}
Implementation Reference
- src/index.ts:897-924 (handler)MCP tool handler for 'mint_tokens': retrieves current wallet, calls rootstockClient.mintTokens with parameters, formats success/error response with explorer links.private async handleMintTokens(params: MintTokensParams) { try { const wallet = this.walletManager.getCurrentWallet(); const result = await this.rootstockClient.mintTokens( wallet, params.tokenAddress, params.to, params.amount, params.gasLimit, params.gasPrice ); const explorerUrl = this.rootstockClient.getExplorerUrl(); const txExplorerLink = `${explorerUrl}/tx/${result.hash}`; const contractExplorerLink = `${explorerUrl}/address/${params.tokenAddress}`; return { content: [ { type: 'text', text: `Tokens Minted Successfully!\n\nTransaction Hash: ${result.hash}\nTransaction Explorer: ${txExplorerLink}\n\nToken Contract: ${params.tokenAddress}\nContract Explorer: ${contractExplorerLink}\n\nMint Details:\nMinted To: ${params.to}\nAmount: ${params.amount}\nStatus: ${result.status}\nGas Used: ${result.gasUsed}`, }, ], }; } catch (error) { throw new Error(`Failed to mint tokens: ${error}`); } }
- src/rootstock-client.ts:545-587 (helper)Blockchain interaction helper: connects wallet to provider, creates ERC20 contract instance, calls mint(to, amount), waits for receipt, returns transaction details.async mintTokens( wallet: ethers.Wallet | ethers.HDNodeWallet, tokenAddress: string, to: string, amount: string, gasLimit?: string, gasPrice?: string ): Promise<TransactionResponse> { try { const connectedWallet = wallet.connect(this.getProvider()); const tokenContract = new ethers.Contract( tokenAddress, this.getMintableERC20ABI(), connectedWallet ); // Get token decimals const decimals = await tokenContract.decimals(); const parsedAmount = ethers.parseUnits(amount, decimals); const tx = await tokenContract.mint(to, parsedAmount, { gasLimit: gasLimit ? BigInt(gasLimit) : undefined, gasPrice: gasPrice ? BigInt(gasPrice) : undefined, }); const receipt = await tx.wait(); return { hash: tx.hash, from: wallet.address, to: tokenAddress, value: amount, gasUsed: receipt?.gasUsed.toString(), gasPrice: tx.gasPrice?.toString(), blockNumber: receipt?.blockNumber, blockHash: receipt?.blockHash, status: receipt?.status === 1 ? 'confirmed' : 'failed', }; } catch (error) { throw new Error(`Failed to mint tokens: ${error}`); } }
- src/types.ts:209-215 (schema)TypeScript interface defining input parameters for mint_tokens tool.export interface MintTokensParams { tokenAddress: string; to: string; amount: string; gasLimit?: string; gasPrice?: string; }
- src/index.ts:458-487 (registration)Tool registration in MCP server's getAvailableTools(): defines name, description, and JSON inputSchema for validation.{ name: 'mint_tokens', description: 'Mint tokens (only for mintable tokens)', inputSchema: { type: 'object', properties: { tokenAddress: { type: 'string', description: 'ERC20 token contract address', }, to: { type: 'string', description: 'Address to mint tokens to', }, amount: { type: 'string', description: 'Amount of tokens to mint', }, gasLimit: { type: 'string', description: 'Optional gas limit', }, gasPrice: { type: 'string', description: 'Optional gas price', }, }, required: ['tokenAddress', 'to', 'amount'], }, },