@circle-fin/bridge-kit 1.4.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,41 @@
1
1
  # @circle-fin/bridge-kit
2
2
 
3
+ ## 1.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Add Circle Forwarder support for CCTP v2 bridging.
8
+
9
+ Forwarding is a relay-assisted mode where Circle observes the burn transaction,
10
+ retrieves attestation data, and submits the destination mint on the user's
11
+ behalf. This removes most destination-side orchestration from client code.
12
+
13
+ What this enables:
14
+ - Opt-in forwarding with `useForwarder: true` so Circle handles destination mint
15
+ submission.
16
+ - Forwarder-only destinations (no destination adapter required) using
17
+ `{ recipientAddress, chain, useForwarder: true }`.
18
+ - Forwarding-fee-aware estimation and max-fee calculation when `maxFee` is
19
+ auto-derived.
20
+ - New hook-based burn actions: `cctp.v2.depositForBurnWithHook` and
21
+ `cctp.v2.customBurnWithHook`.
22
+ - New forwarding helpers: `buildForwardingHookData` and
23
+ `buildForwardingHookDataBuffer`.
24
+ - Chain-level forwarding metadata via `cctp.forwarderSupported` for route
25
+ capability checks.
26
+
27
+ Compatibility:
28
+ - Existing non-forwarded bridge flows remain unchanged.
29
+ - If you set `config.maxFee` manually, include any expected forwarding fee.
30
+
31
+ ## 1.5.0
32
+
33
+ ### Minor Changes
34
+
35
+ - **Monad support**: Bridge Kit now supports Monad mainnet and testnet. You can include Monad in cross-chain USDC transfer flows without additional configuration or changes to existing integrations.
36
+
37
+ - **Automatic re-attestation for fast transfers**: When retrying a failed CCTP v2 fast transfer, the kit now automatically detects if the mint failed due to an expired attestation and triggers re-attestation. This eliminates manual intervention when attestations expire before the mint transaction completes.
38
+
3
39
  ## 1.4.0
4
40
 
5
41
  ### Minor Changes
package/QUICKSTART.md CHANGED
@@ -273,7 +273,7 @@ const adapter = createViemAdapterFromPrivateKey({
273
273
  createPublicClient({
274
274
  chain,
275
275
  transport: http(
276
- `https://eth-mainnet.alchemyapi.io/v2/${process.env.ALCHEMY_KEY}`,
276
+ `https://eth-mainnet.g.alchemy.com/v2/${process.env.ALCHEMY_KEY}`,
277
277
  {
278
278
  retryCount: 3,
279
279
  timeout: 10000,
@@ -1150,7 +1150,7 @@ import { mainnet } from 'viem/chains'
1150
1150
  const publicClient = createPublicClient({
1151
1151
  chain: mainnet,
1152
1152
  transport: fallback([
1153
- http('https://eth-mainnet.alchemyapi.io/v2/your-key'),
1153
+ http('https://eth-mainnet.g.alchemy.com/v2/your-key'),
1154
1154
  http('https://mainnet.infura.io/v3/your-key'),
1155
1155
  http(), // Default public RPC as fallback
1156
1156
  ]),
package/README.md CHANGED
@@ -34,19 +34,22 @@ _Making cross-chain stablecoin (USDC, and soon more tokens) transfers as simple
34
34
  - [1. **AdapterContext** - Your Transfer Endpoint](#1-adaptercontext---your-transfer-endpoint)
35
35
  - [2. **BridgeDestination** - Where Funds Go](#2-bridgedestination---where-funds-go)
36
36
  - [3. **BridgeConfig** - Transfer Settings](#3-bridgeconfig---transfer-settings)
37
- - [Complete Example with All Options](#complete-example-with-all-options)
38
37
  - [Bridge Speed Configuration](#bridge-speed-configuration)
39
38
  - [Custom Fees](#custom-fees)
40
39
  - [How Custom Fees Work](#how-custom-fees-work)
41
- - [1000 USDC Transfer Example](#1000-usdc-transfer-example)
40
+ - [1,000 USDC Transfer Example](#1000-usdc-transfer-example)
42
41
  - [Kit-Level Fee Policies](#kit-level-fee-policies)
43
42
  - [Error Handling](#error-handling)
44
43
  - [Retrying Failed Transfers](#retrying-failed-transfers)
45
- - [Examples](#examples)
46
- - [Basic Bridge Operation](#basic-bridge-operation)
47
- - [EVM to Non-EVM Bridge (EVM ↔ Solana)](#evm-to-non-evm-bridge-evm--solana)
48
- - [Third-Party Recipient](#third-party-recipient)
49
- - [Event Monitoring](#event-monitoring)
44
+ - [Method signature](#method-signature)
45
+ - [Basic usage (EVM → EVM)](#basic-usage-evm--evm)
46
+ - [When to retry vs manual intervention](#when-to-retry-vs-manual-intervention)
47
+ - [Limitations](#limitations)
48
+ - [Performance and best practices](#performance-and-best-practices)
49
+ - [Troubleshooting](#troubleshooting)
50
+ - [Forwarder Integration](#forwarder-integration)
51
+ - [Standard Bridge with Forwarder](#standard-bridge-with-forwarder)
52
+ - [Forwarder-Only Destination (No Destination Adapter)](#forwarder-only-destination-no-destination-adapter)
50
53
  - [API Reference](#api-reference)
51
54
  - [Core Methods](#core-methods)
52
55
  - [Bridge Parameters](#bridge-parameters)
@@ -54,8 +57,6 @@ _Making cross-chain stablecoin (USDC, and soon more tokens) transfers as simple
54
57
  - [Building](#building)
55
58
  - [Testing](#testing)
56
59
  - [Local Development](#local-development)
57
- - [Contributing](#contributing)
58
- - [Quick Contribution Steps](#quick-contribution-steps)
59
60
  - [Community \& Support](#community--support)
60
61
  - [License](#license)
61
62
 
@@ -72,14 +73,16 @@ The Bridge Kit enables cross-chain stablecoin transfers via a type-safe, develop
72
73
  - **🔧 Bring your own infrastructure**: Seamlessly integrate with your existing setup when needed
73
74
  - **🔒 Production-ready security**: Leverages Circle's CCTPv2 with deterministic quotes and finality tracking
74
75
  - **🚀 Developer experience**: Complete TypeScript support, comprehensive validation, and instant connectivity
75
- - **🌍 Cross-chain bridging**: The Bridge Kit supports **34 chains** with **544 total bridge routes** through Circle's CCTPv2
76
- - **Mainnet (17 chains)**: Arbitrum, Avalanche, Base, Codex, Ethereum, HyperEVM, Ink, Linea, OP Mainnet, Plume, Polygon PoS, Sei, Solana, Sonic, Unichain, World Chain, XDC
77
- - **Testnet (17 chains)**: Arbitrum Sepolia, Avalanche Fuji, Base Sepolia, Codex Testnet, Ethereum Sepolia, HyperEVM Testnet, Ink Testnet, Linea Sepolia, OP Sepolia, Plume Testnet, Polygon PoS Amoy, Sei Testnet, Solana Devnet, Sonic Testnet, Unichain Sepolia, World Chain Sepolia, XDC Apothem
76
+ - **🌍 Cross-chain bridging**: The Bridge Kit supports **37 chains** with **666 total bridge routes** through Circle's CCTPv2
77
+ - **Mainnet (18 chains)**: Arbitrum, Avalanche, Base, Codex, Ethereum, HyperEVM, Ink, Linea, Monad, OP Mainnet, Plume, Polygon PoS, Sei, Solana, Sonic, Unichain, World Chain, XDC
78
+ - **Testnet (19 chains)**: Arc Testnet, Arbitrum Sepolia, Avalanche Fuji, Base Sepolia, Codex Testnet, Ethereum Sepolia, HyperEVM Testnet, Ink Testnet, Linea Sepolia, Monad Testnet, OP Sepolia, Plume Testnet, Polygon PoS Amoy, Sei Testnet, Solana Devnet, Sonic Testnet, Unichain Sepolia, World Chain Sepolia, XDC Apothem
78
79
  - **🎯 Flexible adapters**: Supporting EVM (Viem, Ethers) and Solana (@solana/web3)
79
80
  - **⚙️ Configurable bridge speeds**: FAST/SLOW options with fee optimization
80
81
  - **📡 Real-time event monitoring**: Track progress throughout the transfer lifecycle
81
82
  - **🛡️ Robust error handling**: Graceful partial success recovery
82
83
  - **✈️ Pre-flight validation**: Verify transfers with cost estimation before execution
84
+ - **🤖 Forwarder integration**: Circle's Orbit relayer handles attestation and mint automatically
85
+ - **📭 Forwarder-only destinations**: No destination adapter required - just provide recipient address
83
86
 
84
87
  ## Architecture Flow
85
88
 
@@ -615,6 +618,93 @@ if (result.state === 'error') {
615
618
 
616
619
  > See a runnable example at `examples/basic-usdc-transfer/src/retry.ts` (script: `yarn start:retry`).
617
620
 
621
+ ## Forwarder Integration
622
+
623
+ The Bridge Kit supports Circle's Orbit relayer for automated attestation and mint handling.
624
+ When enabled, the relayer automatically fetches the attestation and submits the mint transaction on the destination chain, simplifying the bridging process.
625
+
626
+ ### Standard Bridge with Forwarder
627
+
628
+ Use `useForwarder: true` when you have adapters for both chains but want Circle to handle the mint transaction:
629
+
630
+ ```typescript
631
+ import { BridgeKit } from '@circle-fin/bridge-kit'
632
+ import { createViemAdapterFromPrivateKey } from '@circle-fin/adapter-viem-v2'
633
+
634
+ const kit = new BridgeKit()
635
+ const adapter = createViemAdapterFromPrivateKey({
636
+ privateKey: process.env.PRIVATE_KEY as `0x${string}`,
637
+ })
638
+
639
+ const result = await kit.bridge({
640
+ from: { adapter, chain: 'Ethereum' },
641
+ to: {
642
+ adapter,
643
+ chain: 'Base',
644
+ useForwarder: true, // Circle handles attestation + mint
645
+ },
646
+ amount: '100.50',
647
+ })
648
+ ```
649
+
650
+ **Benefits:**
651
+
652
+ - No manual attestation polling or destination mint submission
653
+ - Relayer handles destination mint transaction automatically
654
+ - Simplified flow with fewer client-side operations
655
+
656
+ ### Forwarder-Only Destination (No Destination Adapter)
657
+
658
+ When you don't have access to a wallet on the destination chain, use forwarder-only mode.
659
+ This is ideal for server-side transfers, custodial services, or when users don't have a wallet on the destination chain:
660
+
661
+ ```typescript
662
+ const result = await kit.bridge({
663
+ from: { adapter, chain: 'Ethereum' },
664
+ to: {
665
+ recipientAddress: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e', // Recipient on destination
666
+ chain: 'Base',
667
+ useForwarder: true, // Required for forwarder-only
668
+ },
669
+ amount: '100.50',
670
+ })
671
+ ```
672
+
673
+ **Key differences from standard bridging:**
674
+
675
+ - No destination adapter required
676
+ - Mint confirmation is based on IRIS API response (not on-chain receipt)
677
+ - Mint step's `data` field will be `undefined`
678
+
679
+ **Relay fee handling:**
680
+
681
+ - Relay fee is automatically included in `maxFee` estimate
682
+ - Fee is deducted from the minted USDC at mint time
683
+ - Net received = burn amount - relay fee
684
+
685
+ ```typescript
686
+ // Estimate includes relay fee when forwarder is enabled
687
+ const estimate = await kit.estimate({
688
+ from: { adapter, chain: 'Ethereum' },
689
+ to: {
690
+ recipientAddress: '0x...',
691
+ chain: 'Base',
692
+ useForwarder: true,
693
+ },
694
+ amount: '100.50',
695
+ })
696
+
697
+ console.log(estimate.maxFee) // Includes both burn fee and relay fee
698
+ ```
699
+
700
+ > If you provide `config.maxFee` manually, include forwarder fees yourself.
701
+ > Auto-inclusion applies when the kit computes fees from route/speed.
702
+ >
703
+ > You can discover forwarder-capable chains with
704
+ > `kit.getSupportedChains({ forwarderSupported: true })`.
705
+ >
706
+ > See runnable examples at `examples/basic-usdc-transfer/src/forwarder-*.ts`.
707
+
618
708
  ## API Reference
619
709
 
620
710
  ### Core Methods
@@ -650,7 +740,14 @@ type BridgeDestination =
650
740
  | {
651
741
  adapter: Adapter // Adapter for the destination chain
652
742
  chain: ChainIdentifier // Chain identifier
653
- recipientAddress: string // Custom recipient address
743
+ recipientAddress?: string // Custom recipient address
744
+ useForwarder?: boolean // Enable Circle's Orbit relayer
745
+ }
746
+ | {
747
+ // Forwarder-only destination (no adapter required)
748
+ recipientAddress: string // Required: where to receive USDC
749
+ chain: ChainIdentifier // Chain identifier
750
+ useForwarder: true // Required: must be true
654
751
  }
655
752
  ```
656
753