get_solana_token_metadata
Retrieve SPL token metadata including decimals, supply, and authorities using a Solana mint address. Supports mainnet and testnet networks for token information access.
Instructions
Get SPL token metadata (decimals, supply, authorities)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mintAddress | Yes | SPL token mint address | |
| network | No | Network type (defaults to mainnet) |
Implementation Reference
- src/handlers/solana-handlers.ts:38-56 (registration)Tool registration object defining the name, description, and input schema for get_solana_token_metadata.{ name: 'get_solana_token_metadata', description: 'Get SPL token metadata (decimals, supply, authorities)', inputSchema: { type: 'object', properties: { mintAddress: { type: 'string', description: 'SPL token mint address', }, network: { type: 'string', enum: ['mainnet', 'testnet'], description: 'Network type (defaults to mainnet)', }, }, required: ['mintAddress'], }, },
- src/handlers/solana-handlers.ts:271-286 (handler)Handler case in handleSolanaTool function that processes tool arguments and invokes the SolanaService.getTokenMetadata method.case 'get_solana_token_metadata': { const mintAddress = args?.mintAddress as string; const network = (args?.network as 'mainnet' | 'testnet') || 'mainnet'; const result = await solanaService.getTokenMetadata(mintAddress, network); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], isError: !result.success, }; }
- Core helper method in SolanaService that retrieves SPL token metadata by calling getAccountInfo RPC on the mint address and parsing the mint info.async getTokenMetadata( mintAddress: string, network: 'mainnet' | 'testnet' = 'mainnet' ): Promise<EndpointResponse> { const service = this.blockchainService.getServiceByBlockchain('solana', network); if (!service) { return { success: false, error: `Solana service not found for ${network}`, }; } try { // Get account info for the mint const result = await this.blockchainService.callRPCMethod( service.id, 'getAccountInfo', [ mintAddress, { encoding: 'jsonParsed', }, ] ); if (!result.success || !result.data?.value) { return { success: false, error: 'Token mint not found or invalid', }; } const mintInfo = result.data.value.data?.parsed?.info; if (!mintInfo) { return { success: false, error: 'Invalid token mint data', }; } return { success: true, data: { mint: mintAddress, decimals: mintInfo.decimals, supply: mintInfo.supply, mintAuthority: mintInfo.mintAuthority, freezeAuthority: mintInfo.freezeAuthority, isInitialized: mintInfo.isInitialized, }, metadata: result.metadata, }; } catch (error) { return { success: false, error: error instanceof Error ? error.message : 'Failed to get Solana token metadata', }; } }