Skip to main content
Glama

fetchTransfers

Query blockchain transfer data by specifying sender, receiver, contract addresses, and block ranges to analyze transaction flows.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fromBlockNoThe block number to start the search from. e.g. "1234567890". Inclusive from block (hex string, int, latest, or indexed).0x0
toBlockNoThe block number to end the search at. e.g. "1234567890". Inclusive to block (hex string, int, latest, or indexed).latest
fromAddressNoThe wallet address to query the transfer was sent from.
toAddressNoThe wallet address to query the transfer was sent to.
contractAddressesNoThe contract addresses to query. e.g. ["0x1234567890123456789012345678901234567890"]
categoryNoThe category of transfers to query. e.g. "external" or "internal"
orderNoThe order of the results. e.g. "asc" or "desc".asc
withMetadataNoWhether to include metadata in the results.
excludeZeroValueNoWhether to exclude zero value transfers.
maxCountNoThe maximum number of results to return. e.g. "0x3E8".0xA
pageKeyNoThe cursor to start the search from. Use this to paginate through the results.
networkNoThe blockchain network to query. e.g. "eth-mainnet" or "base-mainnet").eth-mainnet

Implementation Reference

  • The handler function registered for the 'fetchTransfers' MCP tool. It calls alchemyApi.getAssetTransfers with the input params and returns the result as formatted JSON text, handling errors appropriately.
    }, async (params) => { try { const result = await alchemyApi.getAssetTransfers(params); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], }; } catch (error) { if (error instanceof Error) { console.error('Error in fetchTransfers:', error); return { content: [{ type: "text", text: `Error: ${error.message}` }], isError: true }; } return { content: [{ type: "text", text: 'Unknown error occurred' }], isError: true }; } });
  • Zod schema defining the input parameters for the 'fetchTransfers' tool, matching Alchemy's getAssetTransfers API.
    fromBlock: z.string().default('0x0').describe('The block number to start the search from. e.g. "1234567890". Inclusive from block (hex string, int, latest, or indexed).'), toBlock: z.string().default('latest').describe('The block number to end the search at. e.g. "1234567890". Inclusive to block (hex string, int, latest, or indexed).'), fromAddress: z.string().optional().describe('The wallet address to query the transfer was sent from.'), toAddress: z.string().optional().describe('The wallet address to query the transfer was sent to.'), contractAddresses: z.array(z.string()).default([]).describe('The contract addresses to query. e.g. ["0x1234567890123456789012345678901234567890"]'), category: z.array(z.string()).default(['external', 'erc20']).describe('The category of transfers to query. e.g. "external" or "internal"'), order: z.string().default('asc').describe('The order of the results. e.g. "asc" or "desc".'), withMetadata: z.boolean().default(false).describe('Whether to include metadata in the results.'), excludeZeroValue: z.boolean().default(true).describe('Whether to exclude zero value transfers.'), maxCount: z.string().default('0xA').describe('The maximum number of results to return. e.g. "0x3E8".'), pageKey: z.string().optional().describe('The cursor to start the search from. Use this to paginate through the results.'), network: z.string().default('eth-mainnet').describe('The blockchain network to query. e.g. "eth-mainnet" or "base-mainnet").'),
  • index.ts:215-215 (registration)
    Registration of the 'fetchTransfers' tool on the MCP server.
    server.tool('fetchTransfers', {
  • Helper function implementing the core logic to fetch asset transfers by calling the Alchemy JSON-RPC method 'alchemy_getAssetTransfers'.
    async getAssetTransfers(params: AssetTransfersParams) { const { network, ...otherParams } = params; try { const client = createAlchemyJsonRpcClient(network); const response = await client.post('', { method: "alchemy_getAssetTransfers", params: [{ ...otherParams }] }); return response.data; } catch (error) { console.error('Error fetching asset transfers:', error); throw error; } },
  • TypeScript interface defining the parameters for asset transfers, used in the alchemyApi.getAssetTransfers function.
    export interface AssetTransfersParams { fromBlock: string; toBlock: string; fromAddress?: string; toAddress?: string; contractAddresses: string[]; category: string[]; order: string; withMetadata: boolean; excludeZeroValue: boolean; maxCount: string; pageKey?: string; network: string; }

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