Skip to main content
Glama

getAccountState

Retrieve account balances and staking positions across blockchain networks, automatically converting raw amounts to human-readable formats using verified decimal precision.

Instructions

Get the state of an account (balances and staking positions). CRITICAL: Balance amounts are returned in SMALLEST UNITS (wei for ETH, satoshis for BTC, µATOM for ATOM, etc.). NEVER show raw amounts to users! Always convert first! MANDATORY CONVERSION STEPS - ALWAYS CALL THESE ENDPOINTS: 1. For NATIVE currency: MUST call listFeatures(chainId) first to get the exact decimal places - NEVER assume! 2. For TOKENS: MUST call getTokenDetails(chainId, tokenId) for each token to get its exact decimals - NEVER assume! 3. Convert ALL amounts: human_readable = raw_amount ÷ 10^decimals (using the decimals from the API calls above) 4. Present in human-readable format to users COMMON ERRORS TO AVOID: • ATOM: Raw '4191769000' with 6 decimals = 4.191769 ATOM (NOT 4,191.769 ATOM!) • ETH: Raw '5354656887913579' with 18 decimals = 0.005354656887913579 ETH (NOT 5.35 ETH!) • Always divide by 10^decimals, check your decimal point placement!

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chainIdYes
accountIdYes

Implementation Reference

  • The handler function for the getAccountState tool. It takes chainId and accountId as parameters, makes an API request to the Adamik API to fetch the account state, stringifies the response, and returns it as text content.
    async ({ chainId, accountId }: GetAccountStatePathParams) => { const state = await makeApiRequest<GetAccountStateResponse>( `${ADAMIK_API_BASE_URL}/${chainId}/account/${accountId}/state`, ADAMIK_API_KEY ); const text = JSON.stringify(state); return { content: [ { type: "text", text, }, ], }; }
  • src/module.ts:316-354 (registration)
    Registration of the getAccountState tool using McpServer.tool(), including detailed description emphasizing decimal handling, inline input schema, and the handler function.
    server.tool( "getAccountState", [ "Get the state of an account (balances and staking positions).", "CRITICAL: Balance amounts are returned in SMALLEST UNITS (wei for ETH, satoshis for BTC, µATOM for ATOM, etc.).", "NEVER show raw amounts to users! Always convert first!", "\n", "MANDATORY CONVERSION STEPS - ALWAYS CALL THESE ENDPOINTS:", "1. For NATIVE currency: MUST call listFeatures(chainId) first to get the exact decimal places - NEVER assume!", "2. For TOKENS: MUST call getTokenDetails(chainId, tokenId) for each token to get its exact decimals - NEVER assume!", "3. Convert ALL amounts: human_readable = raw_amount ÷ 10^decimals (using the decimals from the API calls above)", "4. Present in human-readable format to users", "\n", "COMMON ERRORS TO AVOID:", "• ATOM: Raw '4191769000' with 6 decimals = 4.191769 ATOM (NOT 4,191.769 ATOM!)", "• ETH: Raw '5354656887913579' with 18 decimals = 0.005354656887913579 ETH (NOT 5.35 ETH!)", "• Always divide by 10^decimals, check your decimal point placement!", ].join(" "), { chainId: ChainIdSchema, accountId: z.string(), }, async ({ chainId, accountId }: GetAccountStatePathParams) => { const state = await makeApiRequest<GetAccountStateResponse>( `${ADAMIK_API_BASE_URL}/${chainId}/account/${accountId}/state`, ADAMIK_API_KEY ); const text = JSON.stringify(state); return { content: [ { type: "text", text, }, ], }; } );
  • Zod schema and TypeScript type for GetAccountStatePathParams (input parameters: chainId and accountId).
    export const GetAccountStatePathParamsSchema = z.object({ chainId: ChainIdSchema, accountId: z.string(), }); export type GetAccountStatePathParams = z.infer<typeof GetAccountStatePathParamsSchema>;
  • Zod schema and TypeScript type for GetAccountStateResponse (output structure including balances for native, tokens, and staking).
    export const GetAccountStateResponseSchema = z.object({ chainId: ChainIdSchema, accountId: z.string(), balances: AccountBalancesSchema, }); export type GetAccountStateResponse = z.infer<typeof GetAccountStateResponseSchema>;

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/AdamikHQ/adamik-mcp-server'

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