get_token_holders_count
Retrieve the total number of token holders for a specific token address on a chosen blockchain network using chain ID and token address inputs.
Instructions
Get the number of token holders for a given token address
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chain_id | Yes | The chain ID | |
| token_address | Yes | The address of the token |
Implementation Reference
- index.ts:393-432 (handler)Handler function that implements the tool logic by querying the Etherscan API for the number of token holders given chain ID and token address.async function handleGetTokenHoldersCount(req: any, apiKey: string) { const chainId = req.params.arguments.chain_id; const tokenAddress = req.params.arguments.token_address; try { const response = await axios.get( `https://api.etherscan.io/v2/api?chainid=${chainId}&module=token&action=tokenholdercount&contractaddress=${tokenAddress}&apikey=${apiKey}` ); if (response.data.status === "1") { const tokenHoldersCount = response.data.result; return { content: [ { type: "text", text: `Number of token holders for token ${tokenAddress} on chain ${chainId}: ${tokenHoldersCount}`, }, ], }; } else { return { content: [ { type: "text", text: `Failed to get token holders count: ${response.data.message}`, }, ], }; } } catch (error) { return { content: [ { type: "text", text: `Failed to get token holders count: ${error}`, }, ], }; } }
- index.ts:173-190 (schema)ToolDefinition providing the input schema, name, and description for the tool.const getTokenHoldersCount: ToolDefinition = { name: "get_token_holders_count", description: "Get the number of token holders for a given token address", inputSchema: { type: "object", properties: { chain_id: { type: "integer", description: "The chain ID", }, token_address: { type: "string", description: "The address of the token", }, }, required: ["chain_id", "token_address"], }, };
- index.ts:216-223 (registration)Registration of the tool in the toolDefinitions map, which is used in server capabilities for listing tools.const toolDefinitions: { [key: string]: ToolDefinition } = { [getFilteredRpcList.name]: getFilteredRpcList, [getChainId.name]: getChainId, [getTotalSupply.name]: getTotalSupply, [getTokenBalance.name]: getTokenBalance, [getTokenHolders.name]: getTokenHolders, [getTokenHoldersCount.name]: getTokenHoldersCount };
- index.ts:489-490 (registration)Registration in the switch statement dispatcher that routes calls to the handler function.case getTokenHoldersCount.name: return await handleGetTokenHoldersCount(req, apiKey);