UNPKG

1inch-agent-kit

Version:

AI Agent Kit for 1inch - Connect any LLM to 1inch DeFi protocols

32 lines 1.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.rpcAPI = rpcAPI; const fetcher_1 = require("../../utils/fetcher"); /** * Perform JSON-RPC calls against blockchain nodes using 1inch Web3 RPC API * Provides reliable, real-time data access and interaction capabilities */ async function rpcAPI(params) { const apiKey = process.env.ONEINCH_API_KEY; if (!apiKey) { throw new Error("1inch API key is required. Set ONEINCH_API_KEY environment variable."); } const fetcher = new fetcher_1.OneInchFetcher(apiKey); // Build the request body const requestBody = { jsonrpc: "2.0", method: params.method, params: params.params || [], id: params.id || 1 }; // Build the URL with optional nodeType let url = `/web3/${params.chainId}`; if (params.nodeType) { url += `/${params.nodeType}`; } // Supported chains: 1 (Ethereum), 42161 (Arbitrum), 43114 (Avalanche), // 56 (BNB Chain), 100 (Gnosis), 7565164 (Solana), 10 (Optimism), // 137 (Polygon), 324 (zkSync Era), 8453 (Base), etc. return await fetcher.post(url, requestBody); } //# sourceMappingURL=index.js.map