Skip to main content
Glama
cuongpo

Rootstock MCP Server

by cuongpo

send_transaction

Transfer native tokens or ERC20 tokens to a specified address on the Rootstock blockchain. Define recipient, amount, and optional gas parameters for secure and efficient transactions.

Instructions

Send native tokens or ERC20 tokens to another address

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
amountYesAmount to send (in token units, not wei)
gasLimitNoOptional gas limit
gasPriceNoOptional gas price
toYesRecipient address
tokenAddressNoOptional ERC20 token contract address (for token transfers)

Implementation Reference

  • The main handler function for the 'send_transaction' MCP tool. It retrieves the current wallet, determines if it's a native or token transfer, calls the appropriate RootstockClient method, and returns the transaction details with explorer link.
    private async handleSendTransaction(params: SendTransactionParams) {
      try {
        const wallet = this.walletManager.getCurrentWallet();
    
        let result;
        if (params.tokenAddress) {
          result = await this.rootstockClient.sendTokenTransaction(
            wallet,
            params.tokenAddress,
            params.to,
            params.amount,
            params.gasLimit,
            params.gasPrice
          );
        } else {
          result = await this.rootstockClient.sendTransaction(
            wallet,
            params.to,
            params.amount,
            params.gasLimit,
            params.gasPrice
          );
        }
    
        const explorerUrl = this.rootstockClient.getExplorerUrl();
        const txExplorerLink = `${explorerUrl}/tx/${result.hash}`;
    
        return {
          content: [
            {
              type: 'text',
              text: `Transaction sent successfully!\n\nTransaction Hash: ${result.hash}\nTransaction Explorer: ${txExplorerLink}\n\nTransaction Details:\nFrom: ${result.from}\nTo: ${result.to}\nAmount: ${result.value}\nStatus: ${result.status}`,
            },
          ],
        };
      } catch (error) {
        throw new Error(`Failed to send transaction: ${error}`);
      }
    }
  • src/index.ts:225-254 (registration)
    Registration of the 'send_transaction' tool in the MCP server's list of available tools, defining its name, description, and JSON input schema.
    {
      name: 'send_transaction',
      description: 'Send native tokens or ERC20 tokens to another address',
      inputSchema: {
        type: 'object',
        properties: {
          to: {
            type: 'string',
            description: 'Recipient address',
          },
          amount: {
            type: 'string',
            description: 'Amount to send (in token units, not wei)',
          },
          tokenAddress: {
            type: 'string',
            description: 'Optional ERC20 token contract address (for token transfers)',
          },
          gasLimit: {
            type: 'string',
            description: 'Optional gas limit',
          },
          gasPrice: {
            type: 'string',
            description: 'Optional gas price',
          },
        },
        required: ['to', 'amount'],
      },
    },
  • TypeScript interface defining the parameters for the send_transaction tool.
    export interface SendTransactionParams {
      to: string;
      amount: string;
      tokenAddress?: string;
      gasLimit?: string;
      gasPrice?: string;
    }
  • Core helper method in RootstockClient for sending native token (tRBTC) transactions using ethers.js Wallet.
    async sendTransaction(
      wallet: ethers.Wallet | ethers.HDNodeWallet,
      to: string,
      amount: string,
      gasLimit?: string,
      gasPrice?: string
    ): Promise<TransactionResponse> {
      try {
        const connectedWallet = wallet.connect(this.getProvider());
        
        const tx: ethers.TransactionRequest = {
          to,
          value: ethers.parseEther(amount),
          gasLimit: gasLimit ? BigInt(gasLimit) : undefined,
          gasPrice: gasPrice ? BigInt(gasPrice) : undefined,
        };
    
        const transaction = await connectedWallet.sendTransaction(tx);
        const receipt = await transaction.wait();
    
        return {
          hash: transaction.hash,
          from: transaction.from!,
          to: transaction.to!,
          value: ethers.formatEther(transaction.value!),
          gasUsed: receipt?.gasUsed.toString(),
          gasPrice: transaction.gasPrice?.toString(),
          blockNumber: receipt?.blockNumber,
          blockHash: receipt?.blockHash,
          status: receipt?.status === 1 ? 'confirmed' : 'failed',
        };
      } catch (error) {
        throw new Error(`Failed to send transaction: ${error}`);
      }
    }
  • Core helper method in RootstockClient for transferring ERC20 tokens via the transfer function.
    async sendTokenTransaction(
      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,
          [
            'function transfer(address to, uint256 amount) returns (bool)',
            'function decimals() view returns (uint8)',
          ],
          connectedWallet
        );
    
        const decimals = await tokenContract.decimals();
        const parsedAmount = ethers.parseUnits(amount, decimals);
    
        const tx = await tokenContract.transfer(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,
          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 send token transaction: ${error}`);
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries full burden but only states the basic action. It fails to disclose critical behavioral traits: whether this is a read-only or destructive operation (likely destructive for sending tokens), authentication needs, rate limits, or what happens on failure (e.g., transaction reversion).

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste. It front-loads the core purpose without unnecessary details, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex, likely destructive tool with no annotations and no output schema, the description is inadequate. It omits essential context: expected outputs (e.g., transaction hash), error handling, dependencies on other tools like 'set_current_wallet', and how it differs from sibling 'send_contract_transaction'.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents all parameters. The description adds no additional meaning beyond implying 'tokenAddress' is for ERC20 transfers, which is already clear from the schema. Baseline 3 is appropriate as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('send') and resources ('native tokens or ERC20 tokens'), specifying what the tool does. It distinguishes from some siblings like 'get_balance' or 'deploy_erc20_token', but could better differentiate from 'send_contract_transaction' which might handle similar transfers.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives like 'send_contract_transaction' or 'mint_tokens'. The description lacks context about prerequisites, such as needing a wallet set via 'set_current_wallet', or exclusions for specific token types.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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