Skip to main content
Compose comes with built in chain support for over 100 EVM chains, powered by our own “RPC Edge” product for ultimate RPC reliability. You can access all the built-in chains with evm.chains.<<chainName>>. Additionally, compose supports custom chain configurations. See Wallets and Smart Contracts for more details on how chains are used.

Using built-in chains

This is the easiest and most reliable option for most scenarios.
import { TaskContext } from "compose";

export async function main({ evm }: TaskContext) {
  // the "chains" object is typed and holds all our current natively supported chains
  // native chains are pre-configured to use goldsky's "edge" rpc technology
  console.log(evm.chains.base);
}

Using custom chains

To use a custom chain you just need to create an object that fulfills our Chain interface.
import { TaskContext, Chain } from "compose";

export async function main({ evm, env }: TaskContext) {
  // custom chain spec
  const myCustomChain: Chain = {
    id: 480,
    name: "My Custom Chain",
    testnet: false,
    nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
    rpcUrls: {
      default: { http: [`https://mycustomchain-mainnet.g.alchemy.com/v2/${env.MY_CUSTOM_CHAIN_API}`] },
      public: { http: ["https://mycustomchain-mainnet.g.alchemy.com/public"] },
    },
    blockExplorers: {
      default: { name: "myCustomChainScan", url: "https://myCustomChainScan.org" },
    },
  };

  // you can now use the myCustomChain const anywhere you'd use a built-in chain (see Wallets and Smart Contracts for details)
  console.log(myCustomChain);
}
The Chain type is available from the TaskContext interface. Here it is for reference:
export type Chain = {
  id: number;
  name: string;
  testnet: boolean;
  nativeCurrency: {
    name: string;
    symbol: string;
    decimals: number;
  };
  rpcUrls: {
    public: { http: string[] };
    default: { http: string[] };
  };
  blockExplorers: {
    default: { name: string; url: string };
  };
  contracts?: Record<string, { address: string }>;
};