Skip to main content

Method Signature

align.blockchain.providers.setCustomRpc(
  network: Network,
  rpcUrl: string
): void

Parameters

network
string
required
Network to configure
rpcUrl
string
required
Custom RPC URL

Examples

import Align from "@tolbel/align";

const align = new Align({
  apiKey: process.env.ALIGN_API_KEY!,
  environment: "sandbox",
});

// Use Alchemy for Ethereum
align.blockchain.providers.setCustomRpc(
  "ethereum",
  "https://eth-mainnet.g.alchemy.com/v2/YOUR-API-KEY"
);

// Use Infura for Polygon
align.blockchain.providers.setCustomRpc(
  "polygon",
  "https://polygon-mainnet.infura.io/v3/YOUR-PROJECT-ID"
);

// Now getProvider uses the custom URLs
const provider = align.blockchain.providers.getProvider("ethereum");

Configure at Initialization

const align = new Align({
  apiKey: process.env.ALIGN_API_KEY!,
  environment: "production",
  blockchain: {
    customRpcUrls: {
      ethereum: "https://eth-mainnet.g.alchemy.com/v2/KEY",
      polygon: "https://polygon-mainnet.g.alchemy.com/v2/KEY",
    },
  },
});
Premium RPC providers offer higher rate limits, better uptime, and additional features like archive data access.