ethereum_getRecentTransactions
Retrieve the most recent transactions for a specified Ethereum address using the Veri5ight MCP Server. Input an address and optional limit to fetch transaction details.
Instructions
Get recent transactions for an Ethereum address
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"address": "<address>"
},
"name": "ethereum_getRecentTransactions"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| address | Yes | Ethereum address or ENS name | |
| limit | No | Number of transactions to return (default: 3) |
Implementation Reference
- src/index.ts:278-362 (handler)The main handler function that implements the logic for ethereum_getRecentTransactions. It fetches recent blocks, filters transactions for the given address, resolves ENS names, and returns formatted transaction details.
private async handleGetRecentTransactions(request: any) { try { const address = request.params.arguments?.address; const limit = request.params.arguments?.limit || 3; if (!address) { throw new Error("Address is required"); } // Get latest block number const latestBlock = await this.provider.getBlockNumber(); const transactions: ethers.TransactionResponse[] = []; // Scan recent blocks for transactions for (let i = 0; i < 10 && transactions.length < limit; i++) { const block = (await this.provider.getBlock( latestBlock - i, true )) as ethers.Block & { transactions: ethers.TransactionResponse[]; }; if (!block || !block.transactions) continue; const addressTxs = block.transactions.filter( (tx: ethers.TransactionResponse) => tx.from?.toLowerCase() === address.toLowerCase() || tx.to?.toLowerCase() === address.toLowerCase() ); transactions.push(...(addressTxs as ethers.TransactionResponse[])); if (transactions.length >= limit) break; } // Process transactions with ENS resolution const processedTxs = await Promise.all( transactions.map(async (tx: ethers.TransactionResponse) => { // Lookup ENS names in parallel const [fromENS, toENS] = await Promise.all([ tx.from ? this.provider.lookupAddress(tx.from).catch(() => null) : null, tx.to ? this.provider.lookupAddress(tx.to).catch(() => null) : null, ]); return { hash: tx.hash, from: fromENS || tx.from, to: toENS || tx.to || "Contract Creation", value: ethers.formatEther(tx.value), }; }) ); return { content: [ { type: "text", text: `Recent transactions for ${address}:\n` + processedTxs .map( (tx, i) => `${i + 1}. Hash: ${tx.hash}\n` + ` From: ${tx.from}\n` + ` To: ${tx.to}\n` + ` Value: ${tx.value} ETH` ) .join("\n\n"), }, ], }; } catch (error: unknown) { console.error("Error getting recent transactions:", error); const errorMessage = error instanceof Error ? error.message : "Unknown error occurred"; return { content: [ { type: "text", text: `Error getting recent transactions: ${errorMessage}`, }, ], }; } } - src/index.ts:61-78 (schema)Tool specification including name, description, and input schema definition used in the list tools response.
{ name: "ethereum_getRecentTransactions", description: "Get recent transactions for an Ethereum address", inputSchema: { type: "object", properties: { address: { type: "string", description: "Ethereum address or ENS name", }, limit: { type: "number", description: "Number of transactions to return (default: 3)", }, }, required: ["address"], }, }, - src/index.ts:152-153 (registration)Switch case in the CallToolRequest handler that registers and dispatches to the ethereum_getRecentTransactions handler function.
case "ethereum_getRecentTransactions": return await this.handleGetRecentTransactions(request);