Skip to main content
Glama
5ajaki
by 5ajaki

ethereum_getTokenDelegation

Retrieve delegation details for an ERC20 governance token by providing an Ethereum address and token contract. Part of Veri5ight MCP Server for Ethereum interactions.

Instructions

Get delegation info for an ERC20 governance token

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYesEthereum address or ENS name
tokenYesToken contract address or ENS name

Implementation Reference

  • The main handler function that implements the ethereum_getTokenDelegation tool. It queries the token contract for the delegate address and voting power using the provider.
    private async handleGetTokenDelegation(request: any) { try { const address = request.params.arguments?.address; const tokenAddress = request.params.arguments?.token; if (!address || !tokenAddress) { throw new Error("Address and token address are required"); } // Create contract instance with both ERC20 and governance functions const tokenContract = new ethers.Contract( tokenAddress, [...ERC20_ABI, ...GOVERNANCE_ABI], this.provider ); // Check if contract supports delegation try { const [delegate, votingPower, decimals, symbol] = await Promise.all([ tokenContract.delegates(address), tokenContract.getVotes(address), tokenContract.decimals(), tokenContract.symbol(), ]); const formattedVotingPower = ethers.formatUnits(votingPower, decimals); return { content: [ { type: "text", text: `Token Delegation Info for ${address}: • Delegated To: ${delegate === ethers.ZeroAddress ? "No delegation" : delegate} • Voting Power: ${formattedVotingPower} ${symbol}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Token at ${tokenAddress} does not support delegation.`, }, ], }; } } catch (error: unknown) { console.error("Error getting token delegation:", error); const errorMessage = error instanceof Error ? error.message : "Unknown error occurred"; return { content: [ { type: "text", text: `Error getting token delegation: ${errorMessage}`, }, ], }; }
  • The input schema definition for the ethereum_getTokenDelegation tool, specifying required address and token parameters.
    { name: "ethereum_getTokenDelegation", description: "Get delegation info for an ERC20 governance token", inputSchema: { type: "object", properties: { address: { type: "string", description: "Ethereum address or ENS name", }, token: { type: "string", description: "Token contract address or ENS name", }, }, required: ["address", "token"], }, },
  • src/index.ts:156-157 (registration)
    The switch case registration that routes calls to the ethereum_getTokenDelegation handler function.
    case "ethereum_getTokenDelegation": return await this.handleGetTokenDelegation(request);
  • Governance ABI fragment used by the handler to query delegation and votes.
    const GOVERNANCE_ABI = [ "function delegates(address) view returns (address)", "function getVotes(address) view returns (uint256)", ];
  • ERC20 ABI fragment used in the handler for token metadata like decimals and symbol.
    const ERC20_ABI = [ "function name() view returns (string)", "function symbol() view returns (string)", "function decimals() view returns (uint8)", "function totalSupply() view returns (uint256)", "function balanceOf(address) view returns (uint256)", ];

Other Tools

Related Tools

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/5ajaki/veri5ight'

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