Skip to main content

Overview

The cctp-go SDK provides a comprehensive Go implementation for Cross-Chain Transfer Protocol (CCTP) V2 integration. It offers high-level abstractions for cross-chain USDC transfers with built-in chain configurations, contract bindings, and transfer orchestration.

Package Structure

The SDK is organized into several key packages:
cctp/
├── chains.go                  # Chain configurations and lookup functions
├── client.go                  # Iris API client for attestations
├── transfer.go                # Transfer orchestration and workflow
├── tokenmessenger/            # TokenMessengerV2 contract bindings
│   └── tokenmessenger.go
├── messagetransmitter/        # MessageTransmitterV2 contract bindings
│   └── messagetransmitter.go
└── internal/
    ├── wallet/                # Wallet management utilities
    └── util/                  # Helper functions

Core Components

Chain Configuration

Chain Type

The Chain struct contains all necessary configuration for interacting with CCTP-enabled chains:
  • Chain metadata (name, ID, domain)
  • Contract addresses (TokenMessengerV2, MessageTransmitterV2, USDC)
  • RPC endpoints and explorer URLs
  • Finality characteristics
chains.go:24
type Chain struct {
    Name                 string
    ChainID              *big.Int
    Domain               uint32
    RPC                  string
    TokenMessengerV2     string
    MessageTransmitterV2 string
    USDC                 string
    Explorer             string
    IsTestnet            bool
    InstantFinality      bool
}

Iris Client

IrisClient

Handles communication with Circle’s Iris attestation service for:
  • Fetching attestations for completed burns
  • Polling for attestation availability
  • Querying transfer fees
client.go:79
type IrisClient struct {
    baseURL    string
    httpClient *http.Client
}

Transfer Orchestrator

TransferOrchestrator

Coordinates the complete transfer workflow:
  • Balance and allowance checks
  • Token approval if needed
  • Burn transaction on source chain
  • Attestation polling
  • Mint transaction on destination chain
transfer.go:83
type TransferOrchestrator struct {
    wallet       *wallet.Wallet
    irisClient   *IrisClient
    sourceClient *ethclient.Client
    destClient   *ethclient.Client
    params       *TransferParams
}

Contract Bindings

V2 Bindings

Auto-generated Go bindings for CCTP V2 contracts:
  • TokenMessengerV2: Handles burn operations
  • MessageTransmitterV2: Handles message reception and minting
  • IERC20: Standard ERC-20 interface for approvals

Design Principles

1

Type Safety

Uses Go’s type system to prevent common errors. Contract addresses, chain IDs, and domains are validated at compile time.
2

Abigen V2

Built on Ethereum’s abigen v2 library for improved contract interaction patterns and better error handling.
3

Configurability

Allows RPC endpoint customization while providing sensible defaults for all supported chains.
4

Error Handling

Provides detailed error messages and context for debugging failed transfers.

Usage Pattern

A typical integration follows this flow:
// 1. Get chain configurations
sourceChain, _ := cctp.GetChainByName("Ethereum", false)
destChain, _ := cctp.GetChainByName("Avalanche", false)

// 2. Create wallet from private key
wallet, _ := wallet.NewWallet(privateKey)

// 3. Set up transfer parameters
params := &cctp.TransferParams{
    SourceChain:      sourceChain,
    DestChain:        destChain,
    Amount:           amount,
    RecipientAddress: recipient,
    TransferType:     cctp.TransferTypeAuto,
}

// 4. Create orchestrator
orchestrator, _ := cctp.NewTransferOrchestrator(
    wallet,
    params,
    "https://iris-api.circle.com",
)

// 5. Execute transfer
updates := make(chan cctp.TransferUpdate)
go orchestrator.Execute(ctx, updates)

// 6. Monitor progress
for update := range updates {
    fmt.Printf("Step: %s - %s\n", update.Step, update.Message)
}

Next Steps

Chain Configuration

Explore chain lookup functions and configuration

Iris Client

Learn about attestation polling and retrieval

Transfer Orchestrator

Deep dive into transfer workflow execution

Build docs developers (and LLMs) love