Using built-in chains

Nexus ships with a handful of built-in chains. These can be accessed via the CHAIN constant.

import {
  NodeProvider,
  CHAIN,
} from "@whatsgood/nexus";

const alchemyNodeProvider = new NodeProvider({
  name: "llama-rpc",
  chain: CHAIN.ETHEREUM_MAINNET,
  url: "https://eth.llamarpc.com",
});

Adding custom chains

If your target chain is not supported by Nexus, you can add it as a custom chain. When creating a chain, you need to provide a name, chainId, and blockTime. These values are then used to identify access, and fine-tune caching and other features.

import {
  NodeProvider,
  CHAIN,
} from "@whatsgood/nexus";

export const ETHEREUM_SEPOLIA = new Chain({
  name: "Ethereum Sepolia",
  chainId: 11155111,
  blockTime: 60,
});

const alchemyNodeProvider = new NodeProvider({
  name: "alchemy",
  chain: ETHEREUM_SEPOLIA,
  url: process.env.ALCHEMY_URL,
});