compareGas
Compare gas fees across 5 EVM chains to find the lowest cost option, with USD estimates and sorted by price.
Instructions
5개 EVM 체인의 가스비를 한 번에 비교합니다 (최저가 순 정렬, USD 예상 비용 포함)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/compareGas.ts:59-95 (handler)The handler function fetches gas information for multiple EVM chains, calculates the estimated cost in USD, and returns the sorted results.
async function handler(_args: z.infer<typeof inputSchema>): Promise<ToolResult<CompareGasData>> { const cacheKey = "comparegas:all"; const cached = cache.get<CompareGasData>(cacheKey); if (cached.hit) return makeSuccess("ethereum", cached.data, true); try { const results = await Promise.allSettled( SUPPORTED_CHAINS.map((chain) => fetchChainGas(chain)), ); const chains: ChainGas[] = []; for (const result of results) { if (result.status === "fulfilled") { chains.push(result.value); } } if (chains.length === 0) { return makeError("Failed to fetch gas from any chain", "RPC_ERROR"); } // 비용 오름차순 정렬 chains.sort((a, b) => a.estimatedCostUsd - b.estimatedCostUsd); const data: CompareGasData = { chains, cheapest: chains[0].chain, mostExpensive: chains[chains.length - 1].chain, }; cache.set(cacheKey, data, CACHE_TTL); return makeSuccess("ethereum", data, false); } catch (err) { const message = sanitizeError(err); return makeError(`Failed to compare gas: ${message}`, "RPC_ERROR"); } } - src/tools/compareGas.ts:97-107 (registration)Registration of the compareGas MCP tool.
export function register(server: McpServer) { server.tool( "compareGas", "5개 EVM 체인의 가스비를 한 번에 비교합니다 (최저가 순 정렬, USD 예상 비용 포함)", inputSchema.shape, async (args) => { const result = await handler(args as z.infer<typeof inputSchema>); return { content: [{ type: "text" as const, text: JSON.stringify(result, null, 2) }] }; }, ); } - src/tools/compareGas.ts:27-27 (schema)Input schema definition for the compareGas tool (empty object).
const inputSchema = z.object({});