Skip to main content
Glama

MCP Blockchain Server

chainService.ts1.61 kB
import { api } from './api'; export interface Chain { id: string; name: string; currency: string; rpcUrl: string; explorerUrl: string; isTestnet: boolean; isActive: boolean; } /** * Get all supported chains */ export async function getChains(): Promise<Chain[]> { try { const response = await api.chains.list(); return response.chains; } catch (error) { console.error('Error fetching chains:', error); throw error; } } /** * Get chain by ID */ export async function getChainById(chainId: string): Promise<Chain | null> { try { const response = await api.chains.getById(chainId); return response; } catch (error) { console.error(`Error fetching chain ${chainId}:`, error); throw error; } } /** * Get native token balance for an address on a specific chain */ export async function getBalance( chainId: string, address: string ): Promise<{ address: string; balance: string; currency: string }> { try { const response = await api.chains.getBalance(chainId, address); return response; } catch (error) { console.error(`Error fetching balance for ${address} on chain ${chainId}:`, error); throw error; } } /** * Read data from a contract */ export async function readContract( chainId: string, address: string, method: string, args: any[] = [] ): Promise<any> { try { const response = await api.chains.readContract(chainId, address, method, args); return response.result; } catch (error) { console.error(`Error reading contract ${address} method ${method}:`, error); throw error; } }

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/zhangzhongnan928/mcp-blockchain-server'

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