Skip to main content
Glama

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
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • 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");
      }
    }
  • 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) }] };
        },
      );
    }
  • Input schema definition for the compareGas tool (empty object).
    const inputSchema = z.object({});

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/calintzy/evmscope'

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