cctp-sdk
An SDK to integrate with Circle CCTP
Install
npm i @automata-network/cctp-sdk -S
Usage
import { CCTPDomain, CCTPSdk } from "@automata-network/cctp-sdk";
const testnetSdk = CCTPSdk().testnet();
const result = await testnetSdk.transferUSDC({
signer,
sourceDomain: CCTPDomain.Ethereum
destinationDomain: CCTPDomain.Avalanche,
destinationAddress: "0xAbD1626FCc4b288aF31695b007Ca1268D7E9Fe19",
amount: ethers.utils
.parseUnits("0.0001", 6)
.toString(),
onApprove: () => {
},
onBurnUSDC: () => {
},
onGetMessageBytes: () => {
},
onFetchAttestation: () => {
},
onMintUSDC: () => {
},
beforeMintUSDC: async () => {
},
destinationSigner,
});
or you can do it step by step:
await testnetSdk.approveUSDC();
await testnetSdk.burnUSDC();
await testnetSdk.getMessageBytes();
await testnetSdk.waitForAttestation();
await testnetSdk.fetchAttestation();
await testnetSdk.mintUSDC();
see here for more details
if you need to add your configs:
import {
CCTPDomain,
CCTPSdk,
defaultConfigs,
} from "@automata-network/cctp-sdk";
const testnetSdk = CCTPSdk({
mainnet: {
irisApiHost: defaultConfigs.mainnet.irisApiHost,
networks: [
{
domain: CCTPDomain.Avalanche,
usdcContractAddress: "0x5425890298aed601595a70ab815c96711a31bc65",
cctpMessageTransmitterContractAddress:
"0xa9fb1b3009dcb79e2fe346c16a604b8fa8ae0a79",
cctpMessengerContractAddress:
"0xeb08f243e5d3fcff26a9e38ae5520a669f4019d0",
rpc: "https://rpc.ankr.com/avalanche_fuji",
},
],
},
testnet: {
irisApiHost: defaultConfigs.testnet.irisApiHost,
networks: [
{
domain: CCTPDomain.Avalanche,
usdcContractAddress: "0x5425890298aed601595a70ab815c96711a31bc65",
cctpMessageTransmitterContractAddress:
"0xa9fb1b3009dcb79e2fe346c16a604b8fa8ae0a79",
cctpMessengerContractAddress:
"0xeb08f243e5d3fcff26a9e38ae5520a669f4019d0",
rpc: "https://rpc.ankr.com/avalanche_fuji",
},
],
},
}).testnet();
check if the transfer is completed
const isTransferCompleted = await testnetSdk.isTransferCompleted({
messageBytes: result.messageBytes,
});
LICENSE
MIT