Skip to main content

Function Signature

func GetChains(testnet bool) []Chain
Returns all configured blockchain chains for either mainnet or testnet environments. This is the primary function for retrieving the complete list of CCTP-supported chains.

Parameters

testnet
bool
required
Set to true to get testnet chains, or false to get mainnet chains

Returns

chains
[]Chain
Array of Chain structs containing blockchain configurations. Each Chain includes:
  • Name (string) - Chain name
  • ChainID (*big.Int) - EVM chain ID
  • Domain (uint32) - CCTP domain identifier
  • RPC (string) - Default RPC endpoint URL
  • TokenMessengerV2 (string) - TokenMessenger V2 contract address
  • MessageTransmitterV2 (string) - MessageTransmitter V2 contract address
  • USDC (string) - USDC token contract address
  • Explorer (string) - Block explorer URL
  • IsTestnet (bool) - Whether this is a testnet chain
  • InstantFinality (bool) - Whether the chain has instant finality

Usage Example

package main

import (
    "fmt"
    "github.com/circlefin/cctp-go"
)

func main() {
    // Get all mainnet chains
    chains := cctp.GetChains(false)
    
    fmt.Printf("Found %d mainnet chains\n", len(chains))
    for _, chain := range chains {
        fmt.Printf("- %s (Domain %d)\n", chain.Name, chain.Domain)
    }
    
    // Get all testnet chains
    testnetChains := cctp.GetChains(true)
    
    fmt.Printf("\nFound %d testnet chains\n", len(testnetChains))
    for _, chain := range testnetChains {
        fmt.Printf("- %s (Domain %d)\n", chain.Name, chain.Domain)
    }
}

Chain Name Constants

The SDK provides constants for all supported chain names. Use these constants for type-safe chain references:

Mainnet Chains

const (
    Ethereum   = "Ethereum"
    Avalanche  = "Avalanche"
    OPMainnet  = "OP Mainnet"
    Arbitrum   = "Arbitrum"
    Base       = "Base"
    PolygonPoS = "Polygon PoS"
    Unichain   = "Unichain"
    Linea      = "Linea"
    Codex      = "Codex"
    Sonic      = "Sonic"
    WorldChain = "World Chain"
    Sei        = "Sei"
    XDC        = "XDC"
    HyperEVM   = "HyperEVM"
    Ink        = "Ink"
    Plume      = "Plume"
)

Testnet Chains

const (
    EthereumSepolia   = "Ethereum Sepolia"
    AvalancheFuji     = "Avalanche Fuji"
    OPSepolia         = "OP Sepolia"
    ArbitrumSepolia   = "Arbitrum Sepolia"
    BaseSepolia       = "Base Sepolia"
    PolygonPoSAmoy    = "Polygon PoS Amoy"
    LineaSepolia      = "Linea Sepolia"
    ArcTestnet        = "Arc Testnet"
    UnichainSepolia   = "Unichain Sepolia"
    CodexTestnet      = "Codex Testnet"
    SonicTestnet      = "Sonic Testnet"
    WorldChainSepolia = "World Chain Sepolia"
    SeiTestnet        = "Sei Testnet"
    XDCApothem        = "XDC Apothem"
    HyperEVMTestnet   = "HyperEVM Testnet"
    InkTestnet        = "Ink Testnet"
    PlumeTestnet      = "Plume Testnet"
)
Mainnet currently supports 16 chains across domains 0-22, while testnet supports 17 chains. The function internally calls either GetMainnetChains() or GetTestnetChains() based on the testnet parameter.

Build docs developers (and LLMs) love