Skip to main content
This example demonstrates the basic usage of the CCTP Go SDK, including getting available chains, creating an Iris client, and polling for attestations.

What This Example Demonstrates

  • Getting available chains for mainnet or testnet
  • Creating an Iris client for attestation polling
  • Polling for attestations using a burn transaction hash
  • Basic error handling

Complete Code Example

This is the exact example from the SDK README showing the fundamental usage:
package main

import (
    "context"
    "fmt"
    "math/big"

    "github.com/ethereum/go-ethereum/common"
    "github.com/circlefin/cctp-go"
)

func main() {
    // Get available chains
    chains := cctp.GetChains(false) // false = mainnet

    // Create an Iris client for attestations
    irisClient := cctp.NewIrisClient("https://iris-api.circle.com")

    // Poll for an attestation
    ctx := context.Background()
    msg, err := irisClient.PollForAttestation(
        ctx,
        0, // source domain (Ethereum)
        "0x...", // burn transaction hash
        nil, // optional progress callback
    )
    if err != nil {
        panic(err)
    }

    fmt.Printf("Attestation received: %s\n", msg.Attestation)
}

Breaking Down the Example

1

Get Available Chains

Use GetChains(false) to retrieve all mainnet chains. Pass true for testnet chains:
chains := cctp.GetChains(false) // false = mainnet
testnetChains := cctp.GetChains(true) // true = testnet
The chains slice contains all supported CCTP chains with their configuration including RPC endpoints, contract addresses, and domain IDs.
2

Create an Iris Client

The IrisClient is used to fetch attestations from Circle’s Iris API:
irisClient := cctp.NewIrisClient("https://iris-api.circle.com")
For testnet, use: https://iris-api-sandbox.circle.com
3

Poll for Attestation

Use the PollForAttestation method to wait for an attestation to be ready:
ctx := context.Background()
msg, err := irisClient.PollForAttestation(
    ctx,
    0,       // source domain (Ethereum = 0)
    "0x...", // burn transaction hash
    nil,     // optional progress callback
)
The method will automatically retry with exponential backoff until the attestation is ready.
4

Handle the Result

Once the attestation is received, you can access various fields:
if err != nil {
    panic(err)
}

fmt.Printf("Attestation: %s\n", msg.Attestation)
fmt.Printf("Message: %s\n", msg.Message)
fmt.Printf("Status: %s\n", msg.Status)
The progress callback parameter is optional. See Attestation Polling for an example with progress tracking.

Chain Domains

Common domain IDs you’ll use:
ChainDomain
Ethereum0
Avalanche1
OP Mainnet2
Arbitrum3
Base6
Polygon PoS7
See the Supported Chains page for the complete list.

Next Steps

Chain Configuration

Learn about chain configurations and helper functions

Iris Client

Explore the Iris client for attestation management

Build docs developers (and LLMs) love