Skip to main content
Glama

fetchAddressTransactionHistory

Retrieve transaction history for specified wallet addresses across multiple blockchain networks using the Alchemy MCP Server, enabling pagination and custom result limits.

Input Schema

NameRequiredDescriptionDefault
addressesYesA list of wallet address and network pairs
afterNoThe cursor that points to the next set of results. Use this to paginate through the results.
beforeNoThe cursor that points to the previous set of results. Use this to paginate through the results.
limitNoThe number of results to return. Default is 25. Max is 100

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "addresses": { "description": "A list of wallet address and network pairs", "items": { "additionalProperties": false, "properties": { "address": { "description": "The wallet address to query. e.g. \"0x1234567890123456789012345678901234567890\"", "type": "string" }, "networks": { "description": "The blockchain networks to query. e.g. [\"eth-mainnet\", \"base-mainnet\"]", "items": { "type": "string" }, "type": "array" } }, "required": [ "address", "networks" ], "type": "object" }, "type": "array" }, "after": { "description": "The cursor that points to the next set of results. Use this to paginate through the results.", "type": "string" }, "before": { "description": "The cursor that points to the previous set of results. Use this to paginate through the results.", "type": "string" }, "limit": { "default": 25, "description": "The number of results to return. Default is 25. Max is 100", "type": "number" } }, "required": [ "addresses" ], "type": "object" }

Implementation Reference

  • Inline asynchronous handler function that executes the core logic for the 'fetchAddressTransactionHistory' tool: fetches transaction history via alchemyApi, formats timestamps and ETH values using utility functions, and returns formatted JSON response or error.
    }, async (params) => { try { let result = await alchemyApi.getTransactionHistoryByMultichainAddress(params); // List the transaction hash when returning the result to the user const formattedTxns = result.transactions.map((transaction: any) => ({ ...transaction, date: convertTimestampToDate(transaction.blockTimestamp), ethValue: convertWeiToEth(transaction.value) })); result.transactions = formattedTxns; return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], }; } catch (error) { if (error instanceof Error) { console.error('Error in getTransactionHistoryByMultichainAddress:', error); return { content: [{ type: "text", text: `Error: ${error.message}` }], isError: true }; } return { content: [{ type: "text", text: 'Unknown error occurred' }], isError: true }; } });
  • index.ts:175-210 (registration)
    Registration of the 'fetchAddressTransactionHistory' MCP tool using server.tool(), including Zod input schema validation and inline handler.
    server.tool('fetchAddressTransactionHistory', { addresses: z.array(z.object({ address: z.string().describe('The wallet address to query. e.g. "0x1234567890123456789012345678901234567890"'), networks: z.array(z.string()).describe('The blockchain networks to query. e.g. ["eth-mainnet", "base-mainnet"]') })).describe('A list of wallet address and network pairs'), before: z.string().optional().describe('The cursor that points to the previous set of results. Use this to paginate through the results.'), after: z.string().optional().describe('The cursor that points to the next set of results. Use this to paginate through the results.'), limit: z.number().default(25).optional().describe('The number of results to return. Default is 25. Max is 100') }, async (params) => { try { let result = await alchemyApi.getTransactionHistoryByMultichainAddress(params); // List the transaction hash when returning the result to the user const formattedTxns = result.transactions.map((transaction: any) => ({ ...transaction, date: convertTimestampToDate(transaction.blockTimestamp), ethValue: convertWeiToEth(transaction.value) })); result.transactions = formattedTxns; return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], }; } catch (error) { if (error instanceof Error) { console.error('Error in getTransactionHistoryByMultichainAddress:', error); return { content: [{ type: "text", text: `Error: ${error.message}` }], isError: true }; } return { content: [{ type: "text", text: 'Unknown error occurred' }], isError: true }; } });
  • TypeScript interface defining the input structure for the fetchAddressTransactionHistory tool parameters, matching the Zod schema.
    export interface MultiChainTransactionHistoryByAddress extends MultiChainTokenByAddress { before?: string; after?: string; limit?: number; }
  • Helper function in alchemyApi that handles the HTTP POST request to Alchemy's multi-chain transaction history API endpoint using the dedicated client.
    async getTransactionHistoryByMultichainAddress(params: MultiChainTransactionHistoryByAddress) { try { const { addresses, ...otherParams } = params; const client = createMultiChainTransactionHistoryClient(); const response = await client.post('/by-address', { addresses: params.addresses.map((pair: AddressPair) => ({ address: pair.address, networks: pair.networks })), ...otherParams }); return response.data; } catch (error) { console.error('Error fetching transaction history:', error); throw error; } },
  • Utility helper function used in the tool handler to convert Unix timestamps from transaction data to human-readable dates.
    export function convertTimestampToDate(unixTimestamp: number) { const date = new Date(unixTimestamp); const humanReadableDate = date.toLocaleString(); return humanReadableDate; }

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/alchemyplatform/alchemy-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server