Skip to main content
Compose comes with built in chain support for over 100 EVM chains, powered by our own “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.
/// <reference types="../.compose/types.d.ts" />

export async function main(
  { evm }: TaskContext,
  _args: any
) {
  // 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.
// NOTE: this reference will expose the compose "Chain" type
/// <reference types="../../.compose/types.d.ts" /> 

export async function main(
  { evm }: TaskContext,
  _args: any
) {
  // custom chain spec
  export 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 interface is available built-in with the .compose/types.d.ts reference, but here it is for reference:
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 }>;
};