@aptos-labs/cross-chain-core

中文文档
6.1.2发布于 2026/05/09Apache-2.0TypeScriptESM + CJS构建来源已验证近 30 天下载 6113

Aptos Cross Chain Core

原始使用文档
文档目录19 节
  1. Overview
  2. Architecture
  3. Supported Chains
  4. Supported Tokens
  5. How It Works
  6. Transfer Flow (External Chain → Aptos)
  7. Withdrawal Flow (Aptos → External Chain)
  8. Signers
  9. Available Signers
  10. Why Two Aptos Signers?
  11. Installation
  12. Quick Start
  13. API Reference
  14. CrossChainCore
  15. WormholeProvider
  16. Server-Side Solana Claim (Optional)
  17. Chain ID Mappings
  18. Error Handling
  19. Requirements

Aptos Cross-Chain Core

A TypeScript SDK for cross-chain USDC transfers to and from the Aptos blockchain using Circle's CCTP (Cross-Chain Transfer Protocol) via the Wormhole bridge.

Overview

This package enables seamless USDC transfers between Aptos and other supported blockchains. It abstracts the complexity of cross-chain transactions, providing a simple API for:

  • Transfers: Move USDC from external chains (Solana, Ethereum, etc.) to Aptos
  • Withdrawals: Move USDC from Aptos to external chains
  • Balance Queries: Check USDC balances across all supported chains
  • Quote Estimation: Get transfer costs and fees before executing

Architecture

flowchart TB
    subgraph core [CrossChainCore]
        CCCore[CrossChainCore Class]
        Config[Config - chains/tokens]
        Utils[Utils - logger, balance]
    end

    subgraph provider [WormholeProvider]
        WH[WormholeProvider]
        Quote[getQuote]
        Transfer[transfer]
        Withdraw[withdraw]
    end

    subgraph signers [Signers]
        MainSigner[Signer - Router]
        SolanaSig[SolanaSigner]
        EthSig[EthereumSigner]
        AptosSig[AptosSigner]
        SuiSig[SuiSigner]
        AptosLocal[AptosLocalSigner]
    end

    CCCore --> WH
    WH --> MainSigner
    MainSigner --> SolanaSig
    MainSigner --> EthSig
    MainSigner --> AptosSig
    MainSigner --> SuiSig

Supported Chains

NetworkMainnet Chain IDTestnet Chain IDContext
Aptos12Destination/Source
Solanamainnet-betadevnetSource/Destination
Ethereum111155111 (Sepolia)Source/Destination
Base845384532 (Sepolia)Source/Destination
Arbitrum42161421614 (Sepolia)Source/Destination
Avalanche4311443113 (Fuji)Source/Destination
Polygon13780002 (Amoy)Source/Destination
SuimainnettestnetSource/Destination

Supported Tokens

Currently, only USDC is supported via Circle's Cross-Chain Transfer Protocol (CCTP).

How It Works

  1. Initialize: Create a CrossChainCore instance with your network configuration
  2. Get Provider: Obtain a WormholeProvider for executing transfers
  3. Get Quote: Calculate fees and transfer parameters
  4. Execute Transfer: Sign and submit the cross-chain transaction
  5. Wait for Completion: The SDK handles attestation and claiming on the destination chain

Transfer Flow (External Chain → Aptos)

Source Chain Wallet → CCTP Burn → Wormhole Attestation → Aptos Claim → Aptos Wallet

Withdrawal Flow (Aptos → External Chain)

Aptos Wallet → CCTP Burn → Wormhole Attestation → External Chain Claim → Destination Wallet

Signers

A Signer is a component that handles transaction signing and submission for a specific blockchain. The SDK uses signers to interact with the Wormhole bridge protocol, implementing the SignAndSendSigner interface from the Wormhole SDK.

Available Signers

SignerChainDescription
SignerAllRouter signer that delegates to chain-specific signers based on context
SolanaSignerSolanaSigns transactions via SolanaDerivedWallet
EthereumSignerEVM chainsSigns transactions via EIP1193DerivedWallet
AptosSignerAptosSigns transactions via wallet adapter (user interaction)
AptosLocalSignerAptosSigns transactions with a local Account (programmatic)
SuiSignerSuiSigns transactions via SuiDerivedWallet

Why Two Aptos Signers?

Cross-chain transfers involve two distinct phases, each with different signing requirements:

The Two-Phase Transfer Process

  1. Initiate Phase (Source Chain): User burns USDC on the source chain and creates an attestation
  2. Claim Phase (Destination Chain): The attested USDC is minted on the destination chain

These phases require different types of signing:

PhaseSignerUser InteractionUse Case
Initiate (Withdraw)AptosSigner✅ RequiredUser burns USDC from their Aptos wallet
Claim (Transfer)AptosLocalSigner❌ AutomaticSystem claims USDC on behalf of user

AptosSigner

Used for withdrawals where the user initiates a transaction from their Aptos wallet:

  • Requires wallet adapter connection and user approval
  • User must explicitly sign to burn their USDC
  • Standard wallet interaction flow

AptosLocalSigner

Used for transfers where USDC arrives on Aptos from another chain:

  • Signs programmatically with a local Account object
  • No user interaction required
  • Enables automatic claiming without user action

The Derived Wallet Advantage

When transferring from external chains (Solana, Ethereum, etc.) to Aptos, the SDK uses derived wallets. A derived wallet creates an Aptos account address mathematically linked to the user's external chain public key.

This means users don't need an existing Aptos wallet to receive funds!

The flow works like this:

  1. User connects their Solana wallet (for example)
  2. SDK derives a corresponding Aptos address from the Solana public key
  3. User signs the burn transaction on Solana
  4. USDC is automatically claimed on Aptos using AptosLocalSigner
  5. Funds appear in the derived Aptos address, controlled by the same Solana key

This design enables seamless onboarding: users can transfer USDC to Aptos using only their existing external chain wallet.

Installation

pnpm add @aptos-labs/cross-chain-core

or

npm install @aptos-labs/cross-chain-core

Quick Start

import { CrossChainCore, Network } from "@aptos-labs/cross-chain-core";

// Initialize the core with network configuration
const crossChainCore = new CrossChainCore({
  dappConfig: {
    aptosNetwork: Network.TESTNET,
    // Optional: Custom Solana RPC
    solanaConfig: {
      rpc: "https://api.devnet.solana.com",
    },
  },
});

// Get the Wormhole provider
const provider = crossChainCore.getProvider("Wormhole");

API Reference

CrossChainCore

The main entry point for cross-chain operations.

const core = new CrossChainCore({
  dappConfig: {
    aptosNetwork: Network.TESTNET | Network.MAINNET,
    disableTelemetry?: boolean,
    solanaConfig?: {
      rpc?: string,
      priorityFeeConfig?: {
        percentile?: number,
        percentileMultiple?: number,
        min?: number,
        max?: number,
      }
    }
  }
});

getProvider(providerType: "Wormhole")

Returns a provider instance for executing cross-chain transfers.

const provider = core.getProvider("Wormhole");

getWalletUSDCBalance(walletAddress: string, chain: Chain)

Get the USDC balance for a wallet on any supported chain.

const balance = await core.getWalletUSDCBalance(
  "0x1234...", // wallet address
  "Solana", // chain name
);
console.log(`Balance: ${balance} USDC`);

WormholeProvider

getQuote(params)

Calculate transfer costs and get a quote before executing.

const quote = await provider.getQuote({
  // Amount to transfer (as string, e.g., "100.50")
  amount: "100",
  // The external chain involved
  originChain: "Solana",
  // Transaction type:
  // - "transfer": External chain → Aptos
  // - "withdraw": Aptos → External chain
  type: "transfer",
});

Returns: Quote object containing fees, estimated time, and transfer details.

transfer(params)

Transfer USDC from an external chain wallet to an Aptos wallet.

const { originChainTxnId, destinationChainTxnId } = await provider.transfer({
  // Source blockchain
  sourceChain: "Solana",
  // Source chain wallet adapter (must support signing)
  wallet: solanaWalletAdapter,
  // Destination Aptos address
  destinationAddress: "0x1234...",
  // Aptos account to sign the claim transaction
  mainSigner: aptosAccount,
  // Optional: Amount (if not using a previous quote)
  amount: "100",
  // Optional: Sponsor account for gas fees
  sponsorAccount: feePayerAccount,
});

console.log(`Source TX: ${originChainTxnId}`);
console.log(`Destination TX: ${destinationChainTxnId}`);

Returns:

  • originChainTxnId: Transaction hash on the source chain
  • destinationChainTxnId: Transaction hash on the Aptos destination chain

withdraw(params)

Withdraw USDC from an Aptos wallet to an external chain wallet.

const { originChainTxnId, destinationChainTxnId } = await provider.withdraw({
  // Destination blockchain
  sourceChain: "Ethereum",
  // Aptos wallet adapter
  wallet: aptosWalletAdapter,
  // Destination address on the external chain
  destinationAddress: "0xabcd...",
  // Optional: Sponsor account for gas fees
  sponsorAccount: feePayerAccount,
});

console.log(`Aptos TX: ${originChainTxnId}`);
console.log(`Destination TX: ${destinationChainTxnId}`);

Returns:

  • originChainTxnId: Transaction hash on Aptos
  • destinationChainTxnId: Transaction hash on the destination chain

Server-Side Solana Claim (Optional)

When withdrawing USDC from Aptos to Solana, the claim transaction on Solana requires a signature. By default, the user's wallet signs this transaction. However, for a smoother user experience, you can configure a server-side claim where your backend signs the Solana claim transaction instead.

Benefits:

  • Users only sign once (the Aptos burn transaction)
  • No second wallet popup after the ~60 second attestation wait
  • Seamless one-click withdrawal flow

To enable server-side claiming, configure serverClaimUrl in your solanaConfig:

const crossChainCore = new CrossChainCore({
  dappConfig: {
    aptosNetwork: Network.MAINNET,
    solanaConfig: {
      serverClaimUrl: "/api/claim-withdraw", // Your API endpoint
    },
  },
});

When configured, the SDK will automatically POST the attestation receipt to your server endpoint after the Aptos burn transaction is confirmed and attested. Your server then signs and submits the Solana claim transaction using a funded keypair.

📖 See SERVERSIDE_SOLANA_SIGNER.md for complete implementation guide.

Chain ID Mappings

The SDK provides mappings from Ethereum chain IDs to chain configurations:

import {
  EthereumChainIdToTestnetChain,
  EthereumChainIdToMainnetChain,
} from "@aptos-labs/cross-chain-core";

// Get chain config from chain ID
const sepoliaConfig = EthereumChainIdToTestnetChain["11155111"];
const ethereumConfig = EthereumChainIdToMainnetChain["1"];

Error Handling

The SDK throws descriptive errors for common issues:

try {
  await provider.transfer({ ... });
} catch (error) {
  if (error.message.includes("Unsupported chain")) {
    // Handle unsupported chain
  } else if (error.message.includes("User rejected")) {
    // Handle user rejection
  }
}

Requirements

  • Node.js 18+
  • @aptos-labs/ts-sdk ^5.1.1 (peer dependency)
  • @aptos-labs/wallet-adapter-react - This package is designed to work with the Aptos Wallet Adapter ecosystem, specifically using the derived wallet adapters (@aptos-labs/derived-wallet-solana, @aptos-labs/derived-wallet-ethereum, @aptos-labs/derived-wallet-sui) that are part of this project

版本与发布记录

@aptos-labs/cross-chain-core 共发布 70 个版本,首次发布于 2025/03/26;过去 12 个月发布了 38 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
6.1.2latest2026/05/096 个月前
6.1.12026/03/287 个月前
6.1.02026/03/207 个月前
6.0.12026/03/107 个月前
6.0.02026/03/048 个月前
5.9.02026/02/198 个月前

其他发布通道:xchaininit → 5.4.15-xchaininit.0,xchaininit2 → 5.4.15-xchaininit2.0,xchaininit3 → 5.4.15-xchaininit3.3,xchaininit4 → 5.4.15-xchaininit4.2,alpha → 5.6.0-alpha.4。

关于 @aptos-labs/cross-chain-core 的常见问题

@aptos-labs/cross-chain-core 是什么?

Aptos Cross Chain Core

如何安装 @aptos-labs/cross-chain-core?

在项目目录运行 npm install @aptos-labs/cross-chain-core,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@aptos-labs/ts-sdk(^5.1.1)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@aptos-labs/cross-chain-core 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@aptos-labs/cross-chain-core 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@aptos-labs/cross-chain-core 可以商用吗?

@aptos-labs/cross-chain-core 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@aptos-labs/cross-chain-core 的下载量有多少?

根据 npm 官方下载统计,@aptos-labs/cross-chain-core 在 2026/10/07 – 2026/11/05 这 30 天内被下载 6,113 次,日均约 204 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@aptos-labs/cross-chain-core 还在维护吗?

最新版本 6.1.2 发布于 2026/05/09(6 个月前);至今共发布 70 个版本,其中过去 12 个月发布了 38 个;首次发布于 2025/03/26。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。