@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.
- package/README.md +32 -126
- package/index.cjs.js +366 -173
- package/index.d.ts +141 -79
- package/index.mjs +366 -174
- package/package.json +22 -6
package/README.md
CHANGED
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
[](https://badge.fury.io/js/@circle-fin%2Fprovider-cctp-v2)
|
|
6
6
|
[](https://www.typescriptlang.org/)
|
|
7
7
|
[](https://opensource.org/licenses/Apache-2.0)
|
|
8
|
+
[](https://discord.com/invite/buildoncircle)
|
|
8
9
|
|
|
9
|
-
**Circle's Cross-Chain Transfer Protocol v2 provider for
|
|
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
|
|
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
|
|
28
|
-
- [Testnet 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
|
|
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
|
|
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 [
|
|
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 [
|
|
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
|
|
70
|
+
### Option 1: With Bridge Kit (Recommended)
|
|
70
71
|
|
|
71
72
|
```typescript
|
|
72
|
-
import {
|
|
73
|
+
import { BridgeKit } from '@circle-fin/bridge-kit'
|
|
73
74
|
|
|
74
75
|
// Provider included by default
|
|
75
|
-
const kit = new
|
|
76
|
+
const kit = new BridgeKit()
|
|
76
77
|
|
|
77
78
|
const result = await kit.bridge({
|
|
78
|
-
|
|
79
|
-
|
|
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
|
-
|
|
117
|
-
|
|
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
|
-
|
|
125
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
238
|
-
|
|
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
|
|
202
|
+
## Integration with Bridge Kit
|
|
280
203
|
|
|
281
|
-
This provider is designed specifically for the [
|
|
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 {
|
|
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
|
|
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('
|
|
313
|
-
kit.on('
|
|
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
|
-
|
|
319
|
-
|
|
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.
|