githubEdit

USDC Transfers With Connect SDK

The Connect SDK enables fast, cheap, native USDC bridging powered by Circle's Cross Chain Transfer Protocol. Using CCTP to transfer native USDC across chains with the Connect SDK works very much like a standard Token Transfer with the SDK.

Installation

First install the SDK package

npm install @wormhole-foundation/sdk

Usage

To use the CCTP bridge, the platform must be imported and registered

import { Wormhole } from "@wormhole-foundation/sdk";
import evm from "@wormhole-foundation/sdk/evm";

// ...

const wh = await wormhole("Testnet", [evm]);

Manual Transfer

  const srcAddress = Wormhole.chainAddress("Ethereum", "0xdeadbeef...") 
  const dstAddress = Wormhole.chainAddress("Avalanche", "0xbeefdead...") 

  const xfer = await wh.circleTransfer(
    1_000_000n, // 
    srcAddress,
    dstAddress
  );
  console.log(xfer);

A Manual transfer has 3 steps:

  1. Initiate The transfer by calling initiateTransfer and passing a Signer to sign the transactions.

  1. Wait for the Circle Attestation to be available, optionally passing a

  1. Complete the transfer by calling, you guessed it, completeTransfer and again passing a Signer for the destination chain

Automatic Transfer

Using the Automatic Relaying feature is even easier and only involves initiating the transfer. The Relayer infrastructure will handle fetching and delivering the Attestation for you.

Complete Partial Transfer

In the case that a manual transfer is started but not finished, the transfer object can be reconstituted from only the source chain and transaction hash.

This is especially useful in cases where a user has terminated their session prior to completing the transfer or even for debugging.

The full source of a working example is available herearrow-up-right

Last updated

Was this helpful?