Docs · guides · TypeScript

viem with FlexYield

The default TypeScript client for EVM chains — one transport with the bearer header.

Install

npm i viem

Connect and call

import { createPublicClient, http } from "viem";
import { mainnet } from "viem/chains";

const client = createPublicClient({
  chain: mainnet,
  transport: http("https://flexyield.io/rpc/eth_mainnet", {
    fetchOptions: { headers: { Authorization: "Bearer fy_your_api_key" } },
  }),
});

const block = await client.getBlockNumber();
console.log(block);

Replace fy_your_api_key with a key from your dashboard (free tier at registration). Chain slugs: eth_mainnet base_mainnet arbitrum_one optimism_mainnet polygon_pos solana_mainnet — each has its own measured page.

Notes

  • Other chains: swap the path slug (base_mainnet, arbitrum_one, optimism_mainnet, polygon_pos) and the viem chain object.
  • viem batches JSON-RPC by default when you enable `batch: true` — each call in a batch is metered on its own weight.

← Docs · All guides: integration guides · methods and limits.