@circle-fin/provider-cctp-v2 0.0.2-alpha.7 → 1.0.1

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.
Files changed (5) hide show
  1. package/README.md +32 -126
  2. package/index.cjs.js +366 -173
  3. package/index.d.ts +141 -79
  4. package/index.mjs +366 -174
  5. package/package.json +22 -6
package/README.md CHANGED
@@ -5,8 +5,9 @@
5
5
  [![npm version](https://badge.fury.io/js/@circle-fin%2Fprovider-cctp-v2.svg)](https://badge.fury.io/js/@circle-fin%2Fprovider-cctp-v2)
6
6
  [![TypeScript](https://img.shields.io/badge/TypeScript-strict-blue.svg)](https://www.typescriptlang.org/)
7
7
  [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
8
+ [![Discord](https://img.shields.io/discord/473781666251538452?label=Discord&logo=discord)](https://discord.com/invite/buildoncircle)
8
9
 
9
- **Circle's Cross-Chain Transfer Protocol v2 provider for Stablecoin Kits**
10
+ **Circle's Cross-Chain Transfer Protocol v2 provider for Bridge Kit**
10
11
 
11
12
  _Native USDC bridging across 34 chains using Circle's battle-tested protocols._
12
13
 
@@ -20,19 +21,19 @@ _Native USDC bridging across 34 chains using Circle's battle-tested protocols._
20
21
  - [Why CCTPv2 Provider?](#why-cctpv2-provider)
21
22
  - [Installation](#installation)
22
23
  - [Quick Start](#quick-start)
23
- - [Option 1: With Bridging Kit (Recommended)](#option-1-with-bridging-kit-recommended)
24
+ - [Option 1: With Bridge Kit (Recommended)](#option-1-with-bridge-kit-recommended)
24
25
  - [Option 2: Direct Provider Usage](#option-2-direct-provider-usage)
25
26
  - [Features](#features)
26
27
  - [Supported Chains \& Routes](#supported-chains--routes)
27
- - [Mainnet Chains (12 chains)](#mainnet-chains-12-chains)
28
- - [Testnet Chains (12 chains)](#testnet-chains-12-chains)
28
+ - [Mainnet Chains](#mainnet-chains)
29
+ - [Testnet Chains](#testnet-chains)
29
30
  - [Usage Examples](#usage-examples)
30
31
  - [Basic Bridge Operation](#basic-bridge-operation)
31
32
  - [Route Validation](#route-validation)
32
33
  - [Bridge Configurations](#bridge-configurations)
33
34
  - [Error Handling](#error-handling)
34
35
  - [Bridge Process](#bridge-process)
35
- - [Integration with Bridging Kit](#integration-with-bridging-kit)
36
+ - [Integration with Bridge Kit](#integration-with-bridge-kit)
36
37
  - [API Reference](#api-reference)
37
38
  - [Core Methods](#core-methods)
38
39
  - [Transfer Parameters](#transfer-parameters)
@@ -42,9 +43,9 @@ _Native USDC bridging across 34 chains using Circle's battle-tested protocols._
42
43
 
43
44
  ## Overview
44
45
 
45
- The CCTPv2 Bridging Provider is a strongly-typed implementation of Circle's Cross-Chain Transfer Protocol (CCTP) version 2 that enables **native USDC bridging** between 24+ supported blockchain networks.
46
+ The CCTPv2 Bridging Provider is a strongly-typed implementation of Circle's Cross-Chain Transfer Protocol (CCTP) version 2 that enables **native USDC bridging** between 34+ supported blockchain networks.
46
47
 
47
- While primarily designed to power the [Bridging Kit](https://www.npmjs.com/package/@circle-fin/bridging-kit), this provider can also be used **directly in applications** that need fine-grained control over the CCTP transfer process or want to integrate CCTP without the full Stablecoin Kits framework.
48
+ While primarily designed to power the [Bridge Kit](https://www.npmjs.com/package/@circle-fin/bridge-kit), this provider can also be used **directly in applications** that need fine-grained control over the CCTP transfer process or want to integrate CCTP without the full Stablecoin Kits framework.
48
49
 
49
50
  ### Why CCTPv2 Provider?
50
51
 
@@ -62,21 +63,21 @@ npm install @circle-fin/provider-cctp-v2
62
63
  yarn add @circle-fin/provider-cctp-v2
63
64
  ```
64
65
 
65
- > **Note**: This provider is included by default with the [Bridging Kit](https://www.npmjs.com/package/@circle-fin/bridging-kit). You can import this provider if you need to do a custom CCTP integration.
66
+ > **Note**: This provider is included by default with the [Bridge Kit](https://www.npmjs.com/package/@circle-fin/bridge-kit). You can import this provider if you need to do a custom CCTP integration.
66
67
 
67
68
  ## Quick Start
68
69
 
69
- ### Option 1: With Bridging Kit (Recommended)
70
+ ### Option 1: With Bridge Kit (Recommended)
70
71
 
71
72
  ```typescript
72
- import { BridgingKit } from '@circle-fin/bridging-kit'
73
+ import { BridgeKit } from '@circle-fin/bridge-kit'
73
74
 
74
75
  // Provider included by default
75
- const kit = new BridgingKit()
76
+ const kit = new BridgeKit()
76
77
 
77
78
  const result = await kit.bridge({
78
- source: { adapter: sourceAdapter },
79
- destination: { adapter: destAdapter },
79
+ from: { adapter: sourceAdapter, chain: 'Ethereum' },
80
+ to: { adapter: destAdapter, chain: 'Base' },
80
81
  amount: '100.50',
81
82
  })
82
83
  ```
@@ -113,16 +114,16 @@ const isSupported = provider.supportsRoute('Ethereum', 'Base', 'USDC')
113
114
 
114
115
  // Get bridge estimate
115
116
  const estimate = await provider.estimate({
116
- source: { adapter: sourceAdapter },
117
- destination: { adapter: destAdapter },
117
+ from: { adapter: sourceAdapter, chain: 'Ethereum' },
118
+ to: { adapter: destAdapter, chain: 'Base' },
118
119
  amount: '100.50',
119
120
  config: { transferSpeed: 'FAST' },
120
121
  })
121
122
 
122
123
  // Execute bridge operation with custom logic
123
124
  const result = await provider.bridge({
124
- source: { adapter: sourceAdapter },
125
- destination: { adapter: destAdapter },
125
+ from: { adapter: sourceAdapter, chain: 'Ethereum' },
126
+ to: { adapter: destAdapter, chain: 'Base' },
126
127
  amount: '100.50',
127
128
  config: { transferSpeed: 'FAST' },
128
129
  })
@@ -141,92 +142,14 @@ const result = await provider.bridge({
141
142
 
142
143
  The provider supports **544 total bridge routes** across these chains:
143
144
 
144
- ### Mainnet Chains (17 chains)
145
+ ### Mainnet Chains
145
146
 
146
147
  **Arbitrum**, **Avalanche**, **Base**, **Codex**, **Ethereum**, **HyperEVM**, **Ink**, **Linea**, **OP Mainnet**, **Plume**, **Polygon PoS**, **Sei**, **Solana**, **Sonic**, **Unichain**, **World Chain**, **XDC**
147
148
 
148
- ### Testnet Chains (17 chains)
149
+ ### Testnet Chains
149
150
 
150
151
  **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**
151
152
 
152
- ## Usage Examples
153
-
154
- ### Basic Bridge Operation
155
-
156
- ```typescript
157
- import { BridgingKit } from '@circle-fin/bridging-kit'
158
- import { ViemAdapter } from '@circle-fin/adapter-viem-v2'
159
- import { createPublicClient, createWalletClient, http } from 'viem'
160
- import { mainnet, base } from 'viem/chains'
161
- import { privateKeyToAccount } from 'viem/accounts'
162
-
163
- const account = privateKeyToAccount(process.env.PRIVATE_KEY)
164
- const kit = new BridgingKit() // CCTPv2 provider included by default
165
-
166
- const ethereumAdapter = new ViemAdapter({
167
- publicClient: createPublicClient({ chain: mainnet, transport: http() }),
168
- walletClient: createWalletClient({
169
- account,
170
- chain: mainnet,
171
- transport: http(),
172
- }),
173
- })
174
-
175
- const baseAdapter = new ViemAdapter({
176
- publicClient: createPublicClient({ chain: base, transport: http() }),
177
- walletClient: createWalletClient({ account, chain: base, transport: http() }),
178
- })
179
-
180
- const result = await kit.bridge({
181
- source: { adapter: ethereumAdapter },
182
- destination: { adapter: baseAdapter },
183
- amount: '100.50',
184
- config: { transferSpeed: 'FAST' },
185
- })
186
- ```
187
-
188
- ### Route Validation
189
-
190
- ```typescript
191
- import { CCTPV2BridgingProvider } from '@circle-fin/provider-cctp-v2'
192
- import { BridgingKit } from '@circle-fin/bridging-kit'
193
-
194
- const provider = new CCTPV2BridgingProvider()
195
- const kit = new BridgingKit()
196
-
197
- // Check if a route is supported
198
- const isSupported = provider.supportsRoute('Ethereum', 'Base', 'USDC')
199
- console.log('Ethereum → Base:', isSupported ? '✅' : '❌')
200
-
201
- // Validate before bridging
202
- const sourceChain = 'Ethereum'
203
- const destChain = 'Base'
204
- if (!kit.supportsRoute(sourceChain, destChain, 'USDC')) {
205
- throw new Error('Route not supported')
206
- }
207
- ```
208
-
209
- ### Bridge Configurations
210
-
211
- ```typescript
212
- // Using the same kit and adapters from the examples above
213
- // Fast bridge (higher fees, faster processing)
214
- const fastResult = await kit.bridge({
215
- source: { adapter: ethereumAdapter },
216
- destination: { adapter: baseAdapter },
217
- amount: '50.0',
218
- config: { transferSpeed: 'FAST' },
219
- })
220
-
221
- // Slow bridge (lower fees, longer processing)
222
- const slowResult = await kit.bridge({
223
- source: { adapter: ethereumAdapter },
224
- destination: { adapter: baseAdapter },
225
- amount: '50.0',
226
- config: { transferSpeed: 'SLOW' },
227
- })
228
- ```
229
-
230
153
  ## Error Handling
231
154
 
232
155
  The provider implements thoughtful error handling for different scenarios:
@@ -234,8 +157,8 @@ The provider implements thoughtful error handling for different scenarios:
234
157
  ```typescript
235
158
  // Using the same kit and adapters from the examples above
236
159
  const params = {
237
- source: { adapter: ethereumAdapter },
238
- destination: { adapter: baseAdapter },
160
+ from: { adapter: sourceAdapter, chain: 'Ethereum' },
161
+ to: { adapter: destAdapter, chain: 'Base' },
239
162
  amount: '100.50',
240
163
  }
241
164
 
@@ -276,12 +199,12 @@ The CCTPv2 provider handles the complete cross-chain bridging flow:
276
199
 
277
200
  Each step is tracked and can be monitored through the Provider's event system. Transaction details for each step include explorer URLs for easy verification on block explorers.
278
201
 
279
- ## Integration with Bridging Kit
202
+ ## Integration with Bridge Kit
280
203
 
281
- This provider is designed specifically for the [Bridging Kit](https://www.npmjs.com/package/@circle-fin/bridging-kit):
204
+ This provider is designed specifically for the [Bridge Kit](https://www.npmjs.com/package/@circle-fin/bridge-kit):
282
205
 
283
206
  ```typescript
284
- import { BridgingKit } from '@circle-fin/bridging-kit'
207
+ import { BridgeKit } from '@circle-fin/bridge-kit'
285
208
  import { ViemAdapter } from '@circle-fin/adapter-viem-v2'
286
209
  import { createPublicClient, createWalletClient, http } from 'viem'
287
210
  import { mainnet, base } from 'viem/chains'
@@ -290,7 +213,7 @@ import { privateKeyToAccount } from 'viem/accounts'
290
213
  const account = privateKeyToAccount(process.env.PRIVATE_KEY)
291
214
 
292
215
  // Provider is included by default
293
- const kit = new BridgingKit()
216
+ const kit = new BridgeKit()
294
217
 
295
218
  const sourceAdapter = new ViemAdapter({
296
219
  publicClient: createPublicClient({ chain: mainnet, transport: http() }),
@@ -309,37 +232,20 @@ const destAdapter = new ViemAdapter({
309
232
  // Monitor transfer events
310
233
  kit.on('*', (event) => console.log('Event:', event)) // subscribe to all events
311
234
  kit.on('approve', (event) => console.log('Approval:', event.values.txHash))
312
- kit.on('depositForBurn', (event) => console.log('Burn:', event.values.txHash))
313
- kit.on('attestation', (event) => console.log('Burn:', event.attestation))
235
+ kit.on('burn', (event) => console.log('Burn:', event.values.txHash))
236
+ kit.on('fetchAttestation', (event) =>
237
+ console.log('Attestation:', event.values.data),
238
+ )
314
239
  kit.on('mint', (event) => console.log('Mint:', event.values.txHash))
315
240
 
316
241
  // Execute transfer
317
242
  const result = await kit.bridge({
318
- source: { adapter: sourceAdapter },
319
- destination: { adapter: destAdapter },
243
+ from: { adapter: sourceAdapter, chain: 'Ethereum' },
244
+ to: { adapter: destAdapter, chain: 'Base' },
320
245
  amount: '25.0',
321
246
  })
322
247
  ```
323
248
 
324
- ## API Reference
325
-
326
- ### Core Methods
327
-
328
- - `supportsRoute(source, destination, token)` - Check if transfer route is supported
329
- - `bridge(params)` - Execute cross-chain bridge operation
330
- - `estimate(params)` - Get cost estimates for transfer
331
-
332
- ### Transfer Parameters
333
-
334
- ```typescript
335
- interface BridgeParams {
336
- source: WalletContextWithFlexibleChain
337
- destination: WalletContextWithFlexibleChain
338
- amount: string
339
- config?: BridgeConfig
340
- }
341
- ```
342
-
343
249
  ## Development
344
250
 
345
251
  This package is part of the Stablecoin Kits monorepo.