The Connect SDK enables fast, cheap, native USDC bridging powered by Circle's Cross Chain Transfer Protocol. Using to transfer native USDC across chains with the 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]);
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.
const xfer = await wh.circleTransfer(
amount,
srcAddress,
dstAddress,
true, // automatic transfer plz
undefined, // An arbitrary bytes payload if one is necessary
0n, // no native gas dropoff for this demo
);
console.log(xfer);
console.log("Starting Transfer");
const srcTxids = await xfer.initiateTransfer(src.signer);
console.log(`Started Transfer: `, srcTxids);
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.
const timeout = 60 * 1000
// Rebuild the transfer from the source txid
const xfer = await CircleTransfer.from(wh, {
chain: "Avalanche",
txid: "0x6b6d5f101a32aa6d2f7bf0bf14d72bfbf76a640e1b2fdbbeeac5b82069cda4dd",
}, timeout);
const dstTxIds = await xfer.completeTransfer(signer);
console.log("Completed transfer: ", dstTxIds);
Initiate The transfer by calling initiateTransfer and passing a to sign the transactions.