You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pool-Based 就是在 A 链和 B 链之间各自锁定相同的 token,比如 USDT。当用户需要从 A 链跨到 B 链的时候,先会把 USDT 转入 A 链这边的 Vault 中,然后在 B 链这边把 USDT transfer 给用户。这个情况下,就需要在 A 链和 B 链上各自建立 pool 来完成这个操作,当 pool 中的资金不足时,就会出现无法 bridge 的情况。这种模式被称为 lock/unlock。
9
+
Canonical Mapping 对应的就是 lock/mint。用户 bridge 的时候,会把 USDT lock 到 A 链这边的 vault,然后在 B 链这边 mint 出对应的资产给用户。反过来,当用户想把 B 链上的 USDT bridge 会 A 链的时候,会把 B 链上的 USDT burn 掉,然后在 A 链这边把 USDT 从 vault 再 transfer 给用户。
10
+
11
+
本测试将以 OP mainnet 和 Polygon mainnet 进行测试
12
+
13
+
## 测试环境要求
14
+
node 版本需要为 v18.17.0, 可以使用 nvm 切换当前 node 版本
15
+
16
+
## 准备测试环境
17
+
- 安装依赖
18
+
```
19
+
npm install
20
+
```
21
+
22
+
- 配置环境
23
+
```
24
+
cp .env.example .env
25
+
## 之后在 .env 中配置具体的私钥
26
+
```
27
+
28
+
## 执行跨链
29
+
- 以流动性池方式进行跨链
30
+
```
31
+
npx hardhat run scripts/1-poolBasedTransfer.js --network optim
32
+
```
33
+
34
+
- 检查跨链结果
35
+
```
36
+
npx hardhat run scripts/2-queryPoolBasedTrasnferStatus.js --network optim
37
+
```
38
+
39
+
- 以映射方式进行跨链
40
+
```
41
+
npx hardhat run scripts/3.1-canonicalTokenTransfer.js --network optim
42
+
```
43
+
44
+
- 检查跨链结果
45
+
大概需要 15 分钟左右才能确定最终跨链状态,可等待 15 分钟后再来查询结果
46
+
```
47
+
npx hardhat run scripts/4.1-queryCanonicalTrasnferStatus.js --network optim
cBridge introduces the best cross-chain token bridging experience, providing users with deep liquidity, efficient and easy-to-use liquidity management for cBridge node operators and liquidity providers who do not want to operate cBridge nodes. It also offers exciting developer-oriented features such as a universal message bridging for scenarios like cross-chain DEX and NFT.
6
+
7
+
cBridge has two bridge modes, one is Pool-Based, and the other is Canonical Mapping.
8
+
Pool-Based involves locking the same token on both Chain A and Chain B, taking USDT as an example. When a user needs to cross from Chain A to Chain B, they first deposit USDT into the Vault on Chain A, and then transfer the USDT to the user on Chain B. In this case, pools need to be established on Chain A and Chain B respectively to complete this operation. When the funds in the pool are insufficient, it may result in an inability to bridge. This mode is known as lock/unlock.
9
+
Canonical Mapping corresponds to lock/mint. When a user bridges, they lock USDT into the vault on Chain A, and then mint the corresponding asset to the user on Chain B. Conversely, when a user wants to bridge USDT from Chain B back to Chain A, they burn the USDT on Chain B, and then transfer the USDT from the vault to the user on Chain A.
10
+
11
+
This test will be conducted on the OP mainnet and Polygon mainnet.
12
+
13
+
## Test Environment Requirements
14
+
The node version needs to be v18.17.0, you can use nvm to switch to the current node version.
15
+
16
+
17
+
## Preparing the Testing Environment
18
+
- Install dependencies
19
+
```
20
+
npm install
21
+
```
22
+
23
+
- Configure the environment
24
+
```
25
+
cp .env.example .env
26
+
## Then configure the specific private key in .env
27
+
```
28
+
29
+
## Executing Cross-Chain Operations
30
+
- Cross-chain operation in Pool-Based mode
31
+
```
32
+
npx hardhat run scripts/1-poolBasedTransfer.js --network optim
33
+
```
34
+
35
+
- Check the cross-chain results
36
+
```
37
+
npx hardhat run scripts/2-queryPoolBasedTrasnferStatus.js --network optim
38
+
```
39
+
40
+
- Cross-chain operation in the mapping mode
41
+
```
42
+
npx hardhat run scripts/3.1-canonicalTokenTransfer.js --network optim
43
+
```
44
+
45
+
- Check the cross-chain results
46
+
It takes approximately 15 minutes to confirm the final cross-chain status. You can wait for 15 minutes before querying the results.
47
+
```
48
+
npx hardhat run scripts/4.1-queryCanonicalTrasnferStatus.js --network optim
49
+
```
50
+
51
+
## Cross-Chain Refund
52
+
When a cross-chain operation fails, users can refund their assets. The following tests demonstrate how to initiate a refund.
53
+
54
+
- Cross-chain operation using the mapping method
55
+
```
56
+
## For testing purposes, this cross-chain operation will fail, and the OP token will be unlocked, preparing for the subsequent refund.
57
+
npx hardhat run scripts/3.2-canonicalTokenTransfer_ForRefund.js --network optim
58
+
```
59
+
60
+
- Check the cross-chain results
61
+
It takes approximately 15 minutes to confirm the final cross-chain status. You can wait for 15 minutes before querying the results.
62
+
```
63
+
npx hardhat run scripts/4.2-queryCanonicalTrasnferStatus_ForRefund.js --network optim
64
+
```
65
+
66
+
- Refund
67
+
```
68
+
npx hardhat run scripts/5-canonicalTrasnferRefund.js --network optim
69
+
```
70
+
71
+
## Reference Documentation
72
+
- Official doc: https://cbridge-docs.celer.network/
0 commit comments