Skip to main content
Glama
cuongpo

Rootstock MCP Server

by cuongpo

get_transaction

Retrieve detailed information about a specific transaction on the Rootstock blockchain by providing its unique hash using the Rootstock MCP Server.

Instructions

Get details of a transaction by hash

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
hashYesTransaction hash

Implementation Reference

  • Primary MCP tool handler for 'get_transaction'. Fetches transaction details from Rootstock client and formats response with explorer link.
    private async handleGetTransaction(params: GetTransactionParams) {
      try {
        const transaction = await this.rootstockClient.getTransaction(params.hash);
        const explorerUrl = this.rootstockClient.getExplorerUrl();
        const txExplorerLink = `${explorerUrl}/tx/${transaction.hash}`;
    
        return {
          content: [
            {
              type: 'text',
              text: `Transaction Details:\n\nHash: ${transaction.hash}\nExplorer: ${txExplorerLink}\n\nFrom: ${transaction.from}\nTo: ${transaction.to}\nValue: ${transaction.value} ${this.rootstockClient.getCurrencySymbol()}\nGas Used: ${transaction.gasUsed}\nBlock: ${transaction.blockNumber}\nStatus: ${transaction.status}`,
            },
          ],
        };
      } catch (error) {
        throw new Error(`Failed to get transaction: ${error}`);
      }
    }
  • src/index.ts:256-268 (registration)
    Tool registration in getAvailableTools() method, defining name, description, and input schema for listTools response.
      name: 'get_transaction',
      description: 'Get details of a transaction by hash',
      inputSchema: {
        type: 'object',
        properties: {
          hash: {
            type: 'string',
            description: 'Transaction hash',
          },
        },
        required: ['hash'],
      },
    },
  • TypeScript interface defining input parameters for the get_transaction tool.
    export interface GetTransactionParams {
      hash: string;
    }
  • Alternative handler/registration in Smithery server variant using direct server.tool() call.
    // Get Transaction Tool
    server.tool(
      "get_transaction",
      "Get details of a transaction by hash",
      {
        hash: z.string().describe("Transaction hash"),
      },
      async ({ hash }) => {
        try {
          const transaction = await rootstockClient.getTransaction(hash);
          return {
            content: [
              {
                type: "text",
                text: `Transaction Details:\n\nHash: ${transaction.hash}\nFrom: ${transaction.from}\nTo: ${transaction.to}\nValue: ${transaction.value}\nGas Used: ${transaction.gasUsed}\nStatus: ${transaction.status}\nBlock: ${transaction.blockNumber}`,
              },
            ],
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error getting transaction: ${error instanceof Error ? error.message : String(error)}`,
              },
            ],
          };
        }
      }
    );
  • Core blockchain client method implementing the transaction retrieval logic using ethers provider.
    async getTransaction(hash: string): Promise<TransactionResponse> {
      try {
        const [tx, receipt] = await Promise.all([
          this.getProvider().getTransaction(hash),
          this.getProvider().getTransactionReceipt(hash),
        ]);
    
        if (!tx) {
          throw new Error('Transaction not found');
        }
    
        return {
          hash: tx.hash,
          from: tx.from,
          to: tx.to || '',
          value: ethers.formatEther(tx.value),
          gasUsed: receipt?.gasUsed.toString(),
          gasPrice: tx.gasPrice?.toString(),
          blockNumber: receipt?.blockNumber,
          blockHash: receipt?.blockHash,
          status: receipt ? (receipt.status === 1 ? 'confirmed' : 'failed') : 'pending',
        };
      } catch (error) {
        throw new Error(`Failed to get transaction: ${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