### Install x402 packages Source: https://nodeflare.app/docs/x402 Install the required packages for the x402 quick start: @x402/fetch, @x402/evm, and viem. ```bash npm install @x402/fetch @x402/evm viem ``` -------------------------------- ### Install web3.py Source: https://nodeflare.app/docs/examples/web3py Install the web3.py library using pip. ```bash pip install web3 ``` -------------------------------- ### Install viem Source: https://nodeflare.app/docs/examples/viem Install the viem package with npm. ```terminal npm install viem ``` -------------------------------- ### WebSocket Subscription Example Source: https://nodeflare.app/docs/endpoints/optimism JavaScript example for connecting to the WebSocket endpoint and subscribing to newHeads. Replace YOUR_KEY with your actual key. ```javascript const ws = new WebSocket("wss://rpc.nodeflare.app/op/ws/v1/YOUR_KEY"); ws.onopen = () => ws.send(JSON.stringify({ jsonrpc: "2.0", id: 1, method: "eth_subscribe", params: ["newHeads"] })); ``` -------------------------------- ### WebSocket Subscription Example (JavaScript) Source: https://nodeflare.app/docs/endpoints/hyperliquid JavaScript example to connect to the WebSocket endpoint and subscribe to newHeads. Replace YOUR_KEY with your actual key. ```javascript const ws = new WebSocket("wss://rpc.nodeflare.app/hl/ws/v1/YOUR_KEY"); ws.onopen = () => ws.send(JSON.stringify({ jsonrpc: "2.0", id: 1, method: "eth_subscribe", params: ["newHeads"] })); ws.onmessage = (e) => console.log(JSON.parse(e.data)); ``` -------------------------------- ### WebSocket Subscription Example Source: https://nodeflare.app/docs/endpoints/ethereum JavaScript example for connecting to the WebSocket endpoint and subscribing to newHeads. Replace YOUR_KEY with your API key. ```javascript const ws = new WebSocket("wss://rpc.nodeflare.app/eth/ws/v1/YOUR_KEY"); ws.onopen = () => ws.send(JSON.stringify({ jsonrpc: "2.0", id: 1, method: "eth_subscribe", params: ["newHeads"] })); ws.onmessage = (e) => console.log(JSON.parse(e.data)); ``` -------------------------------- ### WebSocket Subscription Example (JavaScript) Source: https://nodeflare.app/docs/endpoints/bnb JavaScript example to connect to the WebSocket endpoint and subscribe to new block headers using eth_subscribe. ```javascript const ws = new WebSocket("wss://rpc.nodeflare.app/bnb/ws/v1/YOUR_KEY"); ws.onopen = () => ws.send(JSON.stringify({ jsonrpc: "2.0", id: 1, method: "eth_subscribe", params: ["newHeads"] })); ``` -------------------------------- ### WebSocket Subscription Example (JavaScript) Source: https://nodeflare.app/docs/endpoints/base JavaScript example to connect to the WebSocket endpoint and subscribe to newHeads. Replace YOUR_KEY with your API key. ```javascript const ws = new WebSocket("wss://rpc.nodeflare.app/base/ws/v1/YOUR_KEY"); ws.onopen = () => ws.send(JSON.stringify({ jsonrpc: "2.0", id: 1, method: "eth_subscribe", params: ["newHeads"] })); ws.onmessage = (e) => console.log(JSON.parse(e.data)); ``` -------------------------------- ### Install ethers.js v6 Source: https://nodeflare.app/docs/examples/ethers Installs ethers.js v6, the current stable release of the Ethereum JavaScript library. ```bash npm install ethers ``` -------------------------------- ### WebSocket Subscription Example in JavaScript Source: https://nodeflare.app/docs/endpoints/arbitrum Connects to the authenticated WebSocket endpoint and subscribes to new block headers using eth_subscribe. ```javascript const ws = new WebSocket("wss://rpc.nodeflare.app/arb/ws/v1/YOUR_KEY"); ws.onopen = () => ws.send(JSON.stringify({ jsonrpc: "2.0", id: 1, method: "eth_subscribe", params: ["newHeads"] })); ``` -------------------------------- ### GET https://x402.nodeflare.app/ Source: https://nodeflare.app/docs/x402 Returns a machine-readable list of chains supported by the x402 endpoint. ```APIDOC ## [GET] https://x402.nodeflare.app/ ### Description Returns a machine-readable list of chains supported by the x402 endpoint. ### Method GET ### Endpoint https://x402.nodeflare.app/ ### Response #### Success Response (200) - **body** (object) - Machine-readable chain list. ### Notes - No authentication required. ``` -------------------------------- ### WebSocket Subscription Example (JavaScript) Source: https://nodeflare.app/docs/endpoints/avalanche Connects to the authenticated WebSocket endpoint and subscribes to new block headers using eth_subscribe. Replace YOUR_KEY with your API key. ```javascript const ws = new WebSocket("wss://rpc.nodeflare.app/avax/ws/v1/YOUR_KEY"); ws.onopen = () => ws.send(JSON.stringify({ jsonrpc: "2.0", id: 1, method: "eth_subscribe", params: ["newHeads"] })); ``` -------------------------------- ### Quick Test with curl Source: https://nodeflare.app/docs/endpoints/hyperliquid Example curl command to test the endpoint by calling eth_blockNumber. Replace YOUR_KEY with your actual key. ```bash curl https://rpc.nodeflare.app/hl/v1/YOUR_KEY \ -X POST \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' ``` -------------------------------- ### Quick Test with curl Source: https://nodeflare.app/docs/endpoints/robinhood Example curl command to test the endpoint by calling eth_blockNumber. Replace YOUR_KEY with your actual API key. ```bash curl https://rpc.nodeflare.app/robinhood/v1/YOUR_KEY \ -X POST \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' ``` -------------------------------- ### Quick Test with curl Source: https://nodeflare.app/docs/endpoints/soneium Example curl command to test the Soneium RPC endpoint by fetching the current block number. ```bash curl https://rpc.nodeflare.app/soneium/v1/YOUR_KEY \ -X POST \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' ``` -------------------------------- ### HTTP header authentication with curl Source: https://nodeflare.app/docs/authentication Send an authenticated request using the X-API-Key header. This example posts a JSON-RPC request to get the latest block number. ```bash curl https://rpc.nodeflare.app/eth/v1/ \ -H "X-API-Key: nf_live_YOUR_KEY" \ -X POST \ -d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' ``` -------------------------------- ### Fetch Portfolio with curl Source: https://nodeflare.app/docs/data POST to /data/portfolio to get native-coin USD valuation and a totalUsd, with a per-chain breakdown sorted by value. This endpoint adds USD valuation to the balances data. ```bash curl -X POST https://rpc.nodeflare.app/data/portfolio \ -H 'Content-Type: application/json' \ -d '{ "address": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045" }' ``` -------------------------------- ### Quick Test with curl Source: https://nodeflare.app/docs/endpoints/bnb Example curl command to test the BNB Chain RPC endpoint by calling eth_blockNumber. Replace YOUR_KEY with your actual key. ```bash curl https://rpc.nodeflare.app/bnb/v1/YOUR_KEY \ -X POST \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' ``` -------------------------------- ### Switch chains with web3.py Source: https://nodeflare.app/docs/examples/web3py Switch chains by changing the chain slug in the RPC URL path. Examples for Base, Arbitrum, and BNB are shown. ```python base_w3 = Web3(Web3.HTTPProvider("https://rpc.nodeflare.app/base/v1/YOUR_KEY")) arb_w3 = Web3(Web3.HTTPProvider("https://rpc.nodeflare.app/arb/v1/YOUR_KEY")) bnb_w3 = Web3(Web3.HTTPProvider("https://rpc.nodeflare.app/bnb/v1/YOUR_KEY")) ``` -------------------------------- ### Get account balance Source: https://nodeflare.app/docs/examples/web3py Get the ETH balance of an address and convert from wei to ether. ```python address = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045" balance_wei = w3.eth.get_balance(address) balance_eth = w3.from_wei(balance_wei, "ether") print(f"{balance_eth} ETH") ``` -------------------------------- ### Token Discovery with x402 in JavaScript Source: https://nodeflare.app/docs/data Set discover: true to find holdings without passing contract addresses. Discovery scans incoming Transfer logs (eth_getLogs) and is a paid method using /x402 endpoints. This example uses @x402/fetch and @x402/evm to pay for the request. Discovered tokens are USD-priced via DefiLlama; junk-symbol spam is filtered on well-covered chains and near-worthless tokens are dropped by default, while legitimate tokens without a market price are still returned. ```javascript import { wrapFetchWithPaymentFromConfig } from "@x402/fetch"; import { ExactEvmScheme } from "@x402/evm"; import { privateKeyToAccount } from "viem/accounts"; const account = privateKeyToAccount(process.env.PRIVATE_KEY); // USDC on Base const pay = wrapFetchWithPaymentFromConfig(fetch, { schemes: [{ network: "eip155:8453", client: new ExactEvmScheme(account) }], }); const res = await pay("https://rpc.nodeflare.app/data/portfolio/x402", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ address: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045", discover: true }), }); ``` -------------------------------- ### Get an account balance with viem Source: https://nodeflare.app/docs/examples/viem Fetches the balance of a specified address using the public client. The balance is returned as a BigInt in wei. ```typescript const balance = await client.getBalance({ address: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045", }); console.log(balance); // BigInt in wei ``` -------------------------------- ### Quick Test with curl Source: https://nodeflare.app/docs/endpoints/base Example curl command to test the Base RPC endpoint. Sends a JSON-RPC request to eth_blockNumber. Replace YOUR_KEY with your API key. ```bash curl https://rpc.nodeflare.app/base/v1/YOUR_KEY \ -X POST \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' ``` -------------------------------- ### Connect to Ethereum with ethers.js Source: https://nodeflare.app/docs/quick-start Connect to NodeFlare's Ethereum endpoint using ethers.js. Replace YOUR_KEY with your API key. The example fetches the latest block number and logs it. ```javascript import { ethers } from 'ethers'; const provider = new ethers.JsonRpcProvider( `https://rpc.nodeflare.app/eth/v1/${YOUR_KEY}` ); const block = await provider.getBlockNumber(); console.log(block); // 19842301 ``` -------------------------------- ### Quick Test with curl Source: https://nodeflare.app/docs/endpoints/mode Run this curl command in a terminal to test the endpoint. Replace YOUR_KEY with your actual API key. It sends a JSON-RPC request to get the current block number. ```bash curl https://rpc.nodeflare.app/mode/v1/YOUR_KEY \ -X POST \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' ``` -------------------------------- ### Quick Test with curl Source: https://nodeflare.app/docs/endpoints/xlayer Quick test to verify connectivity to the XLayer RPC endpoint. Sends a JSON-RPC request to get the latest block number. Replace YOUR_KEY with your API key. ```bash curl https://rpc.nodeflare.app/xlayer/v1/YOUR_KEY \ -X POST \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' ``` -------------------------------- ### Get an Account Balance Source: https://nodeflare.app/docs/examples/ethers Gets the ETH balance of a specified address and formats it using ethers.formatEther. ```javascript const balance = await provider.getBalance("0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"); console.log(ethers.formatEther(balance), "ETH"); ``` -------------------------------- ### viem client configuration Source: https://nodeflare.app/docs/rpc-for-ai-agents Create a viem public client using the base chain and NodeFlare RPC URL with your free key. ```TypeScript import { createPublicClient, http } from "viem"; import { base } from "viem/chains"; const client = createPublicClient({ chain: base, transport: http("https://rpc.nodeflare.app/base/v1/YOUR_KEY"), }); ``` -------------------------------- ### Create a public client with viem Source: https://nodeflare.app/docs/examples/viem Create a public client using the mainnet chain and the NodeFlare HTTP RPC endpoint. ```typescript import { createPublicClient, http } from "viem"; import { mainnet } from "viem/chains"; const client = createPublicClient({ chain: mainnet, transport: http("https://rpc.nodeflare.app/eth/v1/YOUR_KEY"), }); ``` -------------------------------- ### Send a transaction with viem Source: https://nodeflare.app/docs/examples/viem Creates a wallet client using a private key and sends a transaction. Then waits for the transaction receipt and logs the block number. ```typescript import { createWalletClient } from "viem"; import { privateKeyToAccount } from "viem/accounts"; const account = privateKeyToAccount("0xYOUR_PRIVATE_KEY"); const walletClient = createWalletClient({ account, chain: mainnet, transport: http("https://rpc.nodeflare.app/eth/v1/YOUR_KEY"), }); const hash = await walletClient.sendTransaction({ to: "0xRecipientAddress", value: 10000000000000000n, // 0.01 ETH }); const receipt = await client.waitForTransactionReceipt({ hash }); console.log("Block:", receipt.blockNumber); ``` -------------------------------- ### web3.py HTTP provider configuration Source: https://nodeflare.app/docs/rpc-for-ai-agents Create a web3.py Web3 instance using an HTTP provider with NodeFlare's RPC URL. ```Python from web3 import Web3 w3 = Web3(Web3.HTTPProvider("https://rpc.nodeflare.app/base/v1/YOUR_KEY")) ``` -------------------------------- ### Read the latest block with viem Source: https://nodeflare.app/docs/examples/viem Uses the public client to get the latest block number and logs it to the console. ```typescript const block = await client.getBlockNumber(); console.log("Block:", block); ``` -------------------------------- ### Switch chains with viem Source: https://nodeflare.app/docs/examples/viem Create a public client for Base, Arbitrum, BSC, or Optimism by importing the corresponding chain and using the NodeFlare RPC endpoint. ```typescript import { base, arbitrum, bsc, optimism } from "viem/chains"; const baseClient = createPublicClient({ chain: base, transport: http("https://rpc.nodeflare.app/base/v1/YOUR_KEY"), }); ``` -------------------------------- ### Quick Test with curl Source: https://nodeflare.app/docs/endpoints/avalanche Sends a JSON-RPC request to the authenticated endpoint to get the current block number. Replace YOUR_KEY with your API key. ```bash curl https://rpc.nodeflare.app/avax/v1/YOUR_KEY \ -X POST \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' ``` -------------------------------- ### Connect a Provider with ethers.JsonRpcProvider Source: https://nodeflare.app/docs/examples/ethers Creates a JsonRpcProvider for the Ethereum mainnet endpoint. Replace YOUR_KEY with your API key from the dashboard. ```javascript import { ethers } from "ethers"; const provider = new ethers.JsonRpcProvider( "https://rpc.nodeflare.app/eth/v1/YOUR_KEY" ); ``` -------------------------------- ### POST https://rpc.nodeflare.app/eth/v1/{YOUR_KEY} Source: https://nodeflare.app/docs/endpoints/ethereum Authenticated Ethereum mainnet RPC endpoint. Replace YOUR_KEY with your API key. Supports all standard eth_ methods over JSON-RPC 2.0. ```APIDOC ## POST https://rpc.nodeflare.app/eth/v1/{YOUR_KEY} ### Description Authenticated Ethereum mainnet RPC endpoint. Replace YOUR_KEY with your API key. Supports all standard eth_ methods over JSON-RPC 2.0. ### Method POST ### Endpoint https://rpc.nodeflare.app/eth/v1/{YOUR_KEY} ### Parameters #### Path Parameters - **YOUR_KEY** (string) - Required - Your API key. #### Request Body - **jsonrpc** (string) - Required - JSON-RPC version, e.g., "2.0". - **method** (string) - Required - The Ethereum JSON-RPC method, e.g., "eth_blockNumber". - **params** (array) - Required - Array of parameters for the method. - **id** (number) - Required - Request identifier. ### Request Example { "jsonrpc": "2.0", "method": "eth_blockNumber", "params": [], "id": 1 } ### Response #### Success Response (200) - **jsonrpc** (string) - JSON-RPC version. - **result** (string) - The result, typically a hexadecimal block number. - **id** (number) - Request identifier. #### Response Example { "jsonrpc": "2.0", "result": "0x4b7", "id": 1 } ``` -------------------------------- ### Quick Test with curl Source: https://nodeflare.app/docs/endpoints/arbitrum Sends a JSON-RPC request to the Arbitrum One endpoint to get the current block number. Replace YOUR_KEY with your actual API key. ```bash curl https://rpc.nodeflare.app/arb/v1/YOUR_KEY \ -X POST \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' ``` -------------------------------- ### POST /robinhood/v1/{YOUR_KEY} Source: https://nodeflare.app/docs/endpoints/robinhood Main RPC endpoint for Robinhood Chain. Requires an API key for full access, including heavy methods like eth_getLogs. Use this endpoint for authenticated requests. ```APIDOC ## [POST] /robinhood/v1/{YOUR_KEY} ### Description Main RPC endpoint for Robinhood Chain. Requires an API key for full access, including heavy methods like eth_getLogs. Use this endpoint for authenticated requests. ### Method POST ### Endpoint https://rpc.nodeflare.app/robinhood/v1/{YOUR_KEY} ### Parameters #### Path Parameters - **YOUR_KEY** (string) - Required - Your API key for authentication. ### Request Example ```json { "jsonrpc": "2.0", "method": "eth_blockNumber", "params": [], "id": 1 } ``` ### Response #### Success Response (200) - **jsonrpc** (string) - JSON-RPC version. - **id** (number) - Request ID. - **result** (string) - The result of the method call, e.g., block number in hex. #### Response Example ```json { "jsonrpc": "2.0", "id": 1, "result": "0x1" } ``` ``` -------------------------------- ### curl eth_chainId request to Arc RPC Source: https://nodeflare.app/docs/endpoints/arc Sends a JSON-RPC request to the public Arc endpoint to get the chain ID. Expected result is 0x13b2 (5042). ```bash curl https://rpc.nodeflare.app/arc/public \ -X POST \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":1}' ``` -------------------------------- ### Send a transaction Source: https://nodeflare.app/docs/examples/web3py Send a transaction using web3.py. Replace YOUR_PRIVATE_KEY and RecipientAddress. The example sends 0.01 ETH with a gas limit of 21000 and chainId 1 (Ethereum mainnet). ```python from eth_account import Account private_key = "0xYOUR_PRIVATE_KEY" account = Account.from_key(private_key) tx = { "to": "0xRecipientAddress", "value": w3.to_wei(0.01, "ether"), "gas": 21000, "gasPrice": w3.eth.gas_price, "nonce": w3.eth.get_transaction_count(account.address), "chainId": 1, } signed = w3.eth.account.sign_transaction(tx, private_key) tx_hash = w3.eth.send_raw_transaction(signed.raw_transaction) receipt = w3.eth.wait_for_transaction_receipt(tx_hash) print(f"Confirmed in block {receipt['blockNumber']}") ``` -------------------------------- ### POST /bob/v1/{YOUR_KEY} Source: https://nodeflare.app/docs/endpoints/bob The main RPC endpoint for BOB mainnet. Requires an API key for full access, including heavy methods. Use this endpoint for production workloads with higher rate limits. ```APIDOC ## [POST] /bob/v1/{YOUR_KEY} ### Description Main RPC endpoint for BOB mainnet. Requires an API key for full access, including heavy methods. Use this endpoint for production workloads with higher rate limits. ### Method POST ### Endpoint https://rpc.nodeflare.app/bob/v1/{YOUR_KEY} ### Parameters #### Path Parameters - **YOUR_KEY** (string) - Required - Your API key for authentication and higher rate limits. #### Request Body - **jsonrpc** (string) - Required - JSON-RPC version, e.g., "2.0". - **method** (string) - Required - The RPC method to call, e.g., "eth_blockNumber". - **params** (array) - Required - Parameters for the method, can be empty. - **id** (number) - Required - Request identifier. ### Request Example { "jsonrpc": "2.0", "method": "eth_blockNumber", "params": [], "id": 1 } ### Response #### Success Response (200) - **jsonrpc** (string) - JSON-RPC version. - **id** (number) - Request identifier. - **result** (string) - The result of the method call, e.g., a hex block number. #### Response Example { "jsonrpc": "2.0", "id": 1, "result": "0x4b7" } ``` -------------------------------- ### WS wss://rpc.nodeflare.app/hl/ws/v1/{YOUR_KEY} Source: https://nodeflare.app/docs/endpoints/hyperliquid Connects to the HyperEVM WebSocket endpoint for real-time subscriptions. Requires an API key. ```APIDOC ## [WS] wss://rpc.nodeflare.app/hl/ws/v1/{YOUR_KEY} ### Description Connects to the HyperEVM WebSocket endpoint for real-time subscriptions. Requires an API key. ### Method WebSocket ### Endpoint wss://rpc.nodeflare.app/hl/ws/v1/{YOUR_KEY} ### Parameters #### Path Parameters - **YOUR_KEY** (string) - Required - Your API key. ### Request Example ```json { "jsonrpc": "2.0", "id": 1, "method": "eth_subscribe", "params": ["newHeads"] } ``` ### Response #### Success Response - **jsonrpc** (string) - JSON-RPC version. - **id** (number) - Request identifier. - **result** (string) - Subscription identifier. #### Response Example ```json { "jsonrpc": "2.0", "id": 1, "result": "0x9cef" } ``` ``` -------------------------------- ### Fetch Balances with curl Source: https://nodeflare.app/docs/data POST to /data/balances to retrieve native and token balances for an address across specified chains. Each chain returns native balance and token entries with symbol, decimals, human-readable balance, raw, and USD price/value when available. If decimals() cannot be read, balance is null and raw is preserved. ```bash curl -X POST https://rpc.nodeflare.app/data/balances \ -H 'Content-Type: application/json' \ -d '{ "address": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045", "chains": ["base", "eth", "robinhood"], "tokens": { "base": ["0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"] } }' ``` -------------------------------- ### POST /data/portfolio Source: https://nodeflare.app/docs/data Returns a portfolio summary with total USD value and per-chain breakdown. ```APIDOC ## POST /data/portfolio ### Description Adds native-coin USD valuation and rolls everything into a `totalUsd`, with a per-chain breakdown sorted by value. ### Method POST ### Endpoint https://rpc.nodeflare.app/data/portfolio ### Parameters #### Request Body - **address** (string) - Required - The wallet address to query. ### Request Example { "address": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045" } ### Response #### Success Response (200) - **totalUsd** - Total portfolio value in USD. - **per-chain breakdown** - Each chain's holdings with USD valuation, sorted by value. #### Response Example { "totalUsd": 1234.56, "chains": [ { "chain": "base", "usdValue": 1000.0, "tokens": [...] } ] } ``` -------------------------------- ### Quick Test with curl Source: https://nodeflare.app/docs/endpoints/optimism Quick test to verify connectivity to the Optimism RPC endpoint. Sends a JSON-RPC request for eth_blockNumber. Replace YOUR_KEY with your actual key. ```bash curl https://rpc.nodeflare.app/op/v1/YOUR_KEY \ -X POST \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' ``` -------------------------------- ### WS wss://rpc.nodeflare.app/hl/ws/public Source: https://nodeflare.app/docs/endpoints/hyperliquid Connects to the public HyperEVM WebSocket endpoint for real-time subscriptions. No API key required, but rate-limited to 2 req/s. ```APIDOC ## [WS] wss://rpc.nodeflare.app/hl/ws/public ### Description Connects to the public HyperEVM WebSocket endpoint for real-time subscriptions. No API key required, but rate-limited to 2 req/s. ### Method WebSocket ### Endpoint wss://rpc.nodeflare.app/hl/ws/public ### Request Example ```json { "jsonrpc": "2.0", "id": 1, "method": "eth_subscribe", "params": ["newHeads"] } ``` ### Response #### Success Response - **jsonrpc** (string) - JSON-RPC version. - **id** (number) - Request identifier. - **result** (string) - Subscription identifier. #### Response Example ```json { "jsonrpc": "2.0", "id": 1, "result": "0x9cef" } ``` ``` -------------------------------- ### BOB Public RPC Endpoint (No API Key) Source: https://nodeflare.app/docs/endpoints/bob Public endpoint for BOB mainnet RPC. No API key required, but rate-limited to 2 req/s per IP. Heavy methods (eth_getLogs, trace_*, debug_*) are restricted. ```text https://rpc.nodeflare.app/bob/public ``` -------------------------------- ### URL path authentication Source: https://nodeflare.app/docs/authentication Use the recommended URL path authentication by appending your API key to the endpoint. Replace YOUR_KEY with your actual key. ```text https://rpc.nodeflare.app/eth/v1/nf_live_YOUR_KEY ``` -------------------------------- ### WebSocket transport for mainnet with viem Source: https://nodeflare.app/docs/examples/viem Create a public client using WebSocket transport for real-time subscriptions and lower latency. ```typescript import { createPublicClient, webSocket } from "viem"; import { mainnet } from "viem/chains"; const client = createPublicClient({ chain: mainnet, transport: webSocket("wss://rpc.nodeflare.app/eth/ws/v1/YOUR_KEY"), }); ``` -------------------------------- ### WebSocket transport for Base with viem Source: https://nodeflare.app/docs/examples/viem Create a public client using WebSocket transport for the Base chain. ```typescript import { base } from "viem/chains"; const baseClient = createPublicClient({ chain: base, transport: webSocket("wss://rpc.nodeflare.app/base/ws/v1/YOUR_KEY"), }); ``` -------------------------------- ### POST https://rpc.nodeflare.app/hl/v1/{YOUR_KEY} Source: https://nodeflare.app/docs/endpoints/hyperliquid Sends a JSON-RPC request to the HyperEVM RPC endpoint. Requires an API key for full access. ```APIDOC ## [POST] https://rpc.nodeflare.app/hl/v1/{YOUR_KEY} ### Description Sends a JSON-RPC request to the HyperEVM RPC endpoint. Requires an API key for full access. ### Method POST ### Endpoint https://rpc.nodeflare.app/hl/v1/{YOUR_KEY} ### Parameters #### Path Parameters - **YOUR_KEY** (string) - Required - Your API key. #### Request Body - **jsonrpc** (string) - Required - JSON-RPC version (e.g., "2.0"). - **method** (string) - Required - The JSON-RPC method to call (e.g., "eth_blockNumber"). - **params** (array) - Required - Parameters for the method. - **id** (number) - Required - Request identifier. ### Request Example ```json { "jsonrpc": "2.0", "method": "eth_blockNumber", "params": [], "id": 1 } ``` ### Response #### Success Response (200) - **jsonrpc** (string) - JSON-RPC version. - **id** (number) - Request identifier. - **result** (string) - The result of the method call. #### Response Example ```json { "jsonrpc": "2.0", "id": 1, "result": "0x4b7" } ``` ``` -------------------------------- ### POST /bob/public Source: https://nodeflare.app/docs/endpoints/bob Public RPC endpoint for BOB mainnet. No API key required, but rate-limited to 2 requests per second per IP. Heavy methods are restricted. ```APIDOC ## [POST] /bob/public ### Description Public RPC endpoint for BOB mainnet. No API key required, but rate-limited to 2 requests per second per IP. Heavy methods are restricted. ### Method POST ### Endpoint https://rpc.nodeflare.app/bob/public ### Parameters #### Request Body - **jsonrpc** (string) - Required - JSON-RPC version, e.g., "2.0". - **method** (string) - Required - The RPC method to call, e.g., "eth_blockNumber". - **params** (array) - Required - Parameters for the method, can be empty. - **id** (number) - Required - Request identifier. ### Request Example { "jsonrpc": "2.0", "method": "eth_blockNumber", "params": [], "id": 1 } ### Response #### Success Response (200) - **jsonrpc** (string) - JSON-RPC version. - **id** (number) - Request identifier. - **result** (string) - The result of the method call, e.g., a hex block number. #### Response Example { "jsonrpc": "2.0", "id": 1, "result": "0x4b7" } ``` -------------------------------- ### POST /data/balances/x402 Source: https://nodeflare.app/docs/data Token discovery and higher limits for balance queries, running over x402 without an account. ```APIDOC ## POST /data/balances/x402 ### Description Token discovery and higher limits for balance queries, running over x402 without an account. ### Method POST ### Endpoint https://rpc.nodeflare.app/data/balances/x402 ### Parameters #### Request Body - **address** (string) - Required - The 0x address to look up. - **chains** (string[]) - Optional - Chains to include — slug (base), name (ethereum), or numeric ID (8453). Defaults to every supported chain. - **tokens** (object) - Optional - ERC-20 contracts per chain, e.g. { "base": ["0x833589…"] }. - **discover** (boolean) - Optional - Auto-find every ERC-20 the address holds (paid; x402 endpoints only). - **fromBlock** (string) - Optional - Discovery start block (hex or "earliest"). - **minUsd** (number) - Optional - Discovery: drop priced tokens worth less than this USD (default 0.01). - **includeSpam** (boolean) - Optional - Discovery: keep junk-symbol tokens (default off). - **includeDust** (boolean) - Optional - Discovery: keep sub-1e-9 balances (default off). ### Response #### Success Response (200) Returns native and ERC-20 token balances for the specified address across the requested chains, with token discovery and higher limits. ``` -------------------------------- ### POST https://rpc.nodeflare.app/xlayer/v1/{YOUR_KEY} Source: https://nodeflare.app/docs/endpoints/xlayer Authenticated JSON-RPC endpoint for XLayer mainnet. Requires an API key in the URL path. Supports all documented methods. ```APIDOC ## [POST] https://rpc.nodeflare.app/xlayer/v1/{YOUR_KEY} ### Description Sends a JSON-RPC request to the XLayer mainnet. Requires an API key in the URL path. Supports all documented methods. ### Method POST ### Endpoint https://rpc.nodeflare.app/xlayer/v1/{YOUR_KEY} ### Parameters #### Path Parameters - **YOUR_KEY** (string) - Required - Your API key. #### Request Body - **jsonrpc** (string) - Required - JSON-RPC version, e.g., "2.0". - **method** (string) - Required - The JSON-RPC method to call. - **params** (array) - Required - Parameters for the method. - **id** (number) - Required - Request identifier. ### Request Example { "jsonrpc": "2.0", "method": "eth_blockNumber", "params": [], "id": 1 } ### Response #### Success Response (200) - **jsonrpc** (string) - JSON-RPC version. - **id** (number) - Request identifier. - **result** (any) - The result of the method call. #### Response Example { "jsonrpc": "2.0", "id": 1, "result": "0x..." } ``` -------------------------------- ### POST /robinhood/public Source: https://nodeflare.app/docs/endpoints/robinhood Public RPC endpoint for Robinhood Chain. No API key required, but rate-limited to 1 request per 10 seconds per IP and only basic methods are available. Heavy methods like eth_getLogs require a key. ```APIDOC ## [POST] /robinhood/public ### Description Public RPC endpoint for Robinhood Chain. No API key required, but rate-limited to 1 request per 10 seconds per IP and only basic methods are available. Heavy methods like eth_getLogs require a key. ### Method POST ### Endpoint https://rpc.nodeflare.app/robinhood/public ### Request Example ```json { "jsonrpc": "2.0", "method": "eth_blockNumber", "params": [], "id": 1 } ``` ### Response #### Success Response (200) - **jsonrpc** (string) - JSON-RPC version. - **id** (number) - Request ID. - **result** (string) - The result of the method call, e.g., block number in hex. #### Response Example ```json { "jsonrpc": "2.0", "id": 1, "result": "0x1" } ``` ``` -------------------------------- ### POST https://rpc.nodeflare.app/mode/v1/{YOUR_KEY} Source: https://nodeflare.app/docs/endpoints/mode Main RPC endpoint for Mode mainnet. Requires an API key for full access. Supports JSON-RPC methods for chain, blocks, transactions, state, gas, logs, and tracing. ```APIDOC ## POST https://rpc.nodeflare.app/mode/v1/{YOUR_KEY} ### Description Main RPC endpoint for Mode mainnet. Requires an API key for full access. Supports JSON-RPC methods for chain, blocks, transactions, state, gas, logs, and tracing. ### Method POST ### Endpoint https://rpc.nodeflare.app/mode/v1/{YOUR_KEY} ### Parameters #### Path Parameters - **YOUR_KEY** (string) - Required - Your API key. #### Request Body - **jsonrpc** (string) - Required - JSON-RPC version (e.g., "2.0"). - **method** (string) - Required - The RPC method to call (e.g., "eth_blockNumber"). - **params** (array) - Required - Parameters for the method. - **id** (number) - Required - Request identifier. ### Request Example { "jsonrpc": "2.0", "method": "eth_blockNumber", "params": [], "id": 1 } ### Response #### Success Response (200) - **jsonrpc** (string) - JSON-RPC version. - **id** (number) - Request identifier. - **result** (any) - The result of the RPC call. #### Response Example { "jsonrpc": "2.0", "id": 1, "result": "0x..." } ``` -------------------------------- ### POST /data/portfolio/x402 Source: https://nodeflare.app/docs/data Token discovery and higher limits for portfolio queries, running over x402 without an account. ```APIDOC ## POST /data/portfolio/x402 ### Description Token discovery and higher limits for portfolio queries, running over x402 without an account. ### Method POST ### Endpoint https://rpc.nodeflare.app/data/portfolio/x402 ### Parameters #### Request Body - **address** (string) - Required - The 0x address to look up. - **chains** (string[]) - Optional - Chains to include — slug (base), name (ethereum), or numeric ID (8453). Defaults to every supported chain. - **tokens** (object) - Optional - ERC-20 contracts per chain, e.g. { "base": ["0x833589…"] }. - **discover** (boolean) - Optional - Auto-find every ERC-20 the address holds (paid; x402 endpoints only). - **fromBlock** (string) - Optional - Discovery start block (hex or "earliest"). - **minUsd** (number) - Optional - Discovery: drop priced tokens worth less than this USD (default 0.01). - **includeSpam** (boolean) - Optional - Discovery: keep junk-symbol tokens (default off). - **includeDust** (boolean) - Optional - Discovery: keep sub-1e-9 balances (default off). ### Response #### Success Response (200) Returns balances, USD valuation, and total portfolio value for the specified address across the requested chains, with token discovery and higher limits. ``` -------------------------------- ### POST https://rpc.nodeflare.app/avax/public Source: https://nodeflare.app/docs/endpoints/avalanche Public Avalanche C-Chain RPC endpoint. No API key required. Rate-limited to 2 req/s per IP. Heavy methods (eth_getLogs, trace_*, debug_*) are restricted. ```APIDOC ## [POST] https://rpc.nodeflare.app/avax/public ### Description Public Avalanche C-Chain RPC endpoint. No API key required. Rate-limited to 2 req/s per IP. Heavy methods (eth_getLogs, trace_*, debug_*) are restricted. ### Method POST ### Endpoint https://rpc.nodeflare.app/avax/public ### Request Example ```json {"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1} ``` ### Response #### Success Response (200) - **jsonrpc** (string) - JSON-RPC version. - **id** (number) - Request ID. - **result** (string) - Hex-encoded block number. #### Response Example ```json {"jsonrpc":"2.0","id":1,"result":"0x4b7"} ``` ``` -------------------------------- ### AgentKit transport configuration Source: https://nodeflare.app/docs/rpc-for-ai-agents Create a viem HTTP transport with NodeFlare's RPC URL to supply to your AgentKit WalletProvider or viem client. ```TypeScript import { http } from "viem"; const transport = http("https://rpc.nodeflare.app/base/v1/YOUR_KEY"); // supply this transport to your AgentKit WalletProvider / viem client ``` -------------------------------- ### POST /data/portfolio Source: https://nodeflare.app/docs/data Returns native and ERC-20 token balances with USD valuation and total portfolio value for a given address across multiple EVM chains. ```APIDOC ## POST /data/portfolio ### Description Returns native and ERC-20 token balances with USD valuation and total portfolio value for a given address across multiple EVM chains. ### Method POST ### Endpoint https://rpc.nodeflare.app/data/portfolio ### Parameters #### Request Body - **address** (string) - Required - The 0x address to look up. - **chains** (string[]) - Optional - Chains to include — slug (base), name (ethereum), or numeric ID (8453). Defaults to every supported chain. - **tokens** (object) - Optional - ERC-20 contracts per chain, e.g. { "base": ["0x833589…"] }. - **discover** (boolean) - Optional - Auto-find every ERC-20 the address holds (paid; x402 endpoints only). - **fromBlock** (string) - Optional - Discovery start block (hex or "earliest"). - **minUsd** (number) - Optional - Discovery: drop priced tokens worth less than this USD (default 0.01). - **includeSpam** (boolean) - Optional - Discovery: keep junk-symbol tokens (default off). - **includeDust** (boolean) - Optional - Discovery: keep sub-1e-9 balances (default off). ### Response #### Success Response (200) Returns balances, USD valuation, and total portfolio value for the specified address across the requested chains. ``` -------------------------------- ### POST https://rpc.nodeflare.app/hl/public Source: https://nodeflare.app/docs/endpoints/hyperliquid Sends a JSON-RPC request to the public HyperEVM RPC endpoint. No API key required, but rate-limited to 2 req/s per IP. Heavy methods are restricted. ```APIDOC ## [POST] https://rpc.nodeflare.app/hl/public ### Description Sends a JSON-RPC request to the public HyperEVM RPC endpoint. No API key required, but rate-limited to 2 req/s per IP. Heavy methods are restricted. ### Method POST ### Endpoint https://rpc.nodeflare.app/hl/public ### Parameters #### Request Body - **jsonrpc** (string) - Required - JSON-RPC version (e.g., "2.0"). - **method** (string) - Required - The JSON-RPC method to call (e.g., "eth_blockNumber"). - **params** (array) - Required - Parameters for the method. - **id** (number) - Required - Request identifier. ### Request Example ```json { "jsonrpc": "2.0", "method": "eth_blockNumber", "params": [], "id": 1 } ``` ### Response #### Success Response (200) - **jsonrpc** (string) - JSON-RPC version. - **id** (number) - Request identifier. - **result** (string) - The result of the method call. #### Response Example ```json { "jsonrpc": "2.0", "id": 1, "result": "0x4b7" } ``` ``` -------------------------------- ### Public endpoint (no API key) Source: https://nodeflare.app/docs/endpoints/robinhood Public endpoint that does not require an API key. Rate-limited to 1 request per 10 seconds per IP, basic methods only. Heavy methods like eth_getLogs need a key. ```text https://rpc.nodeflare.app/robinhood/public ``` -------------------------------- ### Connect to NodeFlare with web3.py Source: https://nodeflare.app/docs/examples/web3py Connect to NodeFlare's Ethereum RPC endpoint using web3.py. Replace YOUR_KEY with your API key. The is_connected() call returns True if the connection is successful. ```python from web3 import Web3 w3 = Web3(Web3.HTTPProvider("https://rpc.nodeflare.app/eth/v1/YOUR_KEY")) print(w3.is_connected()) # True ``` -------------------------------- ### Make a paid RPC call with ExactEvmScheme Source: https://nodeflare.app/docs/x402 Use the exact payment scheme to make a paid RPC call to the x402 endpoint. Requires a private key with USDC on Base (network eip155:8453). The response is the JSON-RPC result. ```typescript import { wrapFetchWithPaymentFromConfig } from "@x402/fetch"; import { ExactEvmScheme } from "@x402/evm"; import { privateKeyToAccount } from "viem/accounts"; const account = privateKeyToAccount(process.env.PRIVATE_KEY); const fetchWithPayment = wrapFetchWithPaymentFromConfig(fetch, { schemes: [{ network: "eip155:8453", client: new ExactEvmScheme(account) }], }); const res = await fetchWithPayment("https://rpc.nodeflare.app/base/x402", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "eth_blockNumber", params: [] }), }); console.log(await res.json()); // { jsonrpc: "2.0", id: 1, result: "0x..." } ```