Skip to content

Commit 312c351

Browse files
authored
Merge pull request #1024 from 0x-stan/main
add basic/task-80 circle cttp
2 parents 837e58d + 7a6d8e8 commit 312c351

File tree

9 files changed

+846
-0
lines changed

9 files changed

+846
-0
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,10 @@ You are welcome to PR improvements to existing tutorial projects or to create mo
187187
74. [erc20-meta-token](https://github.com/0xsequence/erc20-meta-token)
188188
75. [golang-dapp](basic/75-golang-dapp)
189189
76. [Push Protocol](https://docs.epns.io/developers)
190+
77. [orbit](basic/77-orbit)
191+
78. [wallet connect](basic/78-wallet-connect)
192+
79. [hardhat-foundry](basic/79-hardhat-foundry)
193+
80. [Circle CCTP](basic/80-circle-cctp)
190194

191195
Welcome to submit pull request, [Add a new basic task or update the above task](https://github.com/Dapp-Learning-DAO/Dapp-Learning/issues/new)
192196

basic/80-circle-cctp/.env.example

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ALCHEMY_KEY=
2+
SEPOLIA_ACCOUNT_PK=
3+
AVAX_FUJI_PRIVATE_KEY=

basic/80-circle-cctp/.gitignore

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
_cjs
2+
_esm
3+
_types
4+
*.local
5+
.DS_Store
6+
.eslintcache
7+
.next
8+
bench
9+
cache
10+
coverage
11+
node_modules
12+
tsconfig*.tsbuildinfo
13+
14+
# local env files
15+
.env
16+
.env.local
17+
.env.development.local
18+
.env.test.local
19+
.env.production.local
20+
.envrc
21+
22+
# tests
23+
generated.ts
24+
vectors/**/*.json
25+
26+
# docs
27+
site/dist
28+
.vercel
29+
30+
# build
31+
dist/

basic/80-circle-cctp/README-cn.md

+209
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
# Circle CCTP
2+
3+
中文 / [English](./README.md)
4+
5+
## 概览
6+
7+
跨链转账协议(CCTP)是一个无需许可的链上工具,通过原生的 burn 和 mint 机制,在区块链网络之间安全地转移 USDC。提高使用跨区块链网络 USDC 时的资本效率。CCTP 使开发者能够构建多链应用,为用户提供跨区块链的安全、1:1 的 USDC 转账。
8+
9+
## 工作原理
10+
11+
在源链上燃烧 USDC:在源链上燃烧指定数量的 USDC。
12+
从 Circle 获取签名的证明:Circle 观察并证明源链上的 brun 事件。从 Circle 请求证明,Circle 提供授权在目的链上铸造指定数量的 USDC。
13+
在目标链上铸造 USDC:使用证明触发 USDC 的 mint,并发送到接收者的钱包地址。
14+
15+
跨链转账协议(CCTP)消息传递机制,在支持的区块链之间 burn 和 mint USDC,这一过程包括三个步骤:
16+
17+
1. 源域上的链上组件发出消息。
18+
2. Circle 的链下证明服务对消息进行签名。
19+
3. 目的域上的链上组件接收消息,并将消息体转发给指定的接收者。
20+
21+
## Get-Started
22+
23+
将 USDC 从 Ethereum 测试网 跨链到 Avalanche 测试网
24+
25+
- install
26+
27+
```sh
28+
pnpm install
29+
```
30+
31+
- run script
32+
33+
```sh
34+
pnpm start
35+
```
36+
37+
### Script Output
38+
39+
```sh
40+
Ethereum Sepolia testnet Wallet address: 0xe45d43FEb3F65B4587510A68722450b629154e6f
41+
Avalache Fuji testnet Wallet address: 0xe45d43FEb3F65B4587510A68722450b629154e6f
42+
sepolia test USDC balanceOf 9900000
43+
Amount that will be transferred 100000
44+
45+
STEP 1: Approve messenger contract to withdraw from our active eth address
46+
ApproveTx 0x3a6e906cfd6d6af92ae0520662dd40d126f6e8cb1e76c0b98904d2e3e5739a4f
47+
ApproveTxReceipt: {
48+
...
49+
}
50+
51+
STEP 2: Burn USDC
52+
BurnTx 0x95d6a57ce1c4cc35e50cf7561dcbe6bc1df0924912a13d5c293d23472cad6616
53+
BurnTxReceipt: {
54+
blockHash: '0x895655d141bc5d34c49d9bf47b3678bedfd43f6f1450a9547653a4196ca3b456',
55+
blockNumber: 5334096n,
56+
contractAddress: null,
57+
cumulativeGasUsed: 10852617n,
58+
effectiveGasPrice: 5774590432n,
59+
from: '0xe45d43feb3f65b4587510a68722450b629154e6f',
60+
gasUsed: 103504n,
61+
logs: [
62+
{
63+
address: '0x1c7d4b196cb0c7b01d743fbc6116a902379c7238',
64+
topics: [Array],
65+
data: '0x00000000000000000000000000000000000000000000000000000000000186a0',
66+
blockNumber: 5334096n,
67+
transactionHash: '0x95d6a57ce1c4cc35e50cf7561dcbe6bc1df0924912a13d5c293d23472cad6616',
68+
transactionIndex: 106,
69+
blockHash: '0x895655d141bc5d34c49d9bf47b3678bedfd43f6f1450a9547653a4196ca3b456',
70+
logIndex: 171,
71+
removed: false
72+
},
73+
{
74+
address: '0x1c7d4b196cb0c7b01d743fbc6116a902379c7238',
75+
topics: [Array],
76+
data: '0x00000000000000000000000000000000000000000000000000000000000186a0',
77+
blockNumber: 5334096n,
78+
transactionHash: '0x95d6a57ce1c4cc35e50cf7561dcbe6bc1df0924912a13d5c293d23472cad6616',
79+
transactionIndex: 106,
80+
blockHash: '0x895655d141bc5d34c49d9bf47b3678bedfd43f6f1450a9547653a4196ca3b456',
81+
logIndex: 172,
82+
removed: false
83+
},
84+
{
85+
address: '0x1c7d4b196cb0c7b01d743fbc6116a902379c7238',
86+
topics: [Array],
87+
data: '0x00000000000000000000000000000000000000000000000000000000000186a0',
88+
blockNumber: 5334096n,
89+
transactionHash: '0x95d6a57ce1c4cc35e50cf7561dcbe6bc1df0924912a13d5c293d23472cad6616',
90+
transactionIndex: 106,
91+
blockHash: '0x895655d141bc5d34c49d9bf47b3678bedfd43f6f1450a9547653a4196ca3b456',
92+
logIndex: 173,
93+
removed: false
94+
},
95+
{
96+
address: '0x7865fafc2db2093669d92c0f33aeef291086befd',
97+
topics: [Array],
98+
data: '0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000f8000000000000000000000001000000000003ec700000000000000000000000009f3b8679c73c2fef8b59b4f3444d4e156fb70aa5000000000000000000000000eb08f243e5d3fcff26a9e38ae5520a669f4019d00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c7d4b196cb0c7b01d743fbc6116a902379c7238000000000000000000000000e45d43feb3f65b4587510a68722450b629154e6f00000000000000000000000000000000000000000000000000000000000186a0000000000000000000000000e45d43feb3f65b4587510a68722450b629154e6f0000000000000000',
99+
blockNumber: 5334096n,
100+
transactionHash: '0x95d6a57ce1c4cc35e50cf7561dcbe6bc1df0924912a13d5c293d23472cad6616',
101+
transactionIndex: 106,
102+
blockHash: '0x895655d141bc5d34c49d9bf47b3678bedfd43f6f1450a9547653a4196ca3b456',
103+
logIndex: 174,
104+
removed: false
105+
},
106+
{
107+
address: '0x9f3b8679c73c2fef8b59b4f3444d4e156fb70aa5',
108+
topics: [Array],
109+
data: '0x00000000000000000000000000000000000000000000000000000000000186a0000000000000000000000000e45d43feb3f65b4587510a68722450b629154e6f0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000eb08f243e5d3fcff26a9e38ae5520a669f4019d00000000000000000000000000000000000000000000000000000000000000000',
110+
blockNumber: 5334096n,
111+
transactionHash: '0x95d6a57ce1c4cc35e50cf7561dcbe6bc1df0924912a13d5c293d23472cad6616',
112+
transactionIndex: 106,
113+
blockHash: '0x895655d141bc5d34c49d9bf47b3678bedfd43f6f1450a9547653a4196ca3b456',
114+
logIndex: 175,
115+
removed: false
116+
}
117+
],
118+
logsBloom: '0x00000000000000000000000000000000000000000000001000000000000200002000000000000200000000000000000000002010000004000000000000000000100000000000000000000008000000000000000000000000000200020000000001000000022000400000000000000800080000000040000000100010100000000000000000101004000000000000000000000000000000000000000000200000000000000000000000000000000000040000008000000000000000000000000000000002000000000480000000000000000000000000000000000000020020000000000400000020000010000000000000080000000000000000000000000000',
119+
status: 'success',
120+
to: '0x9f3b8679c73c2fef8b59b4f3444d4e156fb70aa5',
121+
transactionHash: '0x95d6a57ce1c4cc35e50cf7561dcbe6bc1df0924912a13d5c293d23472cad6616',
122+
transactionIndex: 106,
123+
type: 'eip1559'
124+
}
125+
126+
STEP 3: Retrieve message bytes from logs
127+
128+
message
129+
0x000000000000000000000001000000000003ec700000000000000000000000009f3b8679c73c2fef8b59b4f3444d4e156fb70aa5000000000000000000000000eb08f243e5d3fcff26a9e38ae5520a669f4019d00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c7d4b196cb0c7b01d743fbc6116a902379c7238000000000000000000000000e45d43feb3f65b4587510a68722450b629154e6f00000000000000000000000000000000000000000000000000000000000186a0000000000000000000000000e45d43feb3f65b4587510a68722450b629154e6f
130+
131+
messageHash 0x921854a0cc7746e05082591412747ffa0c497e6c4785504b29061c5d36b0e1b0
132+
133+
STEP 4: Fetch attestation signature
134+
Signature: 0x5c515abc1964dfe1e46a4a4daacb897a24d586e15d0ff93617e8f22793ed6192565957db1dc55b4011409f4b7dbb4e072a8365fa11071b393c41a6e2527a1b421c6d49f035e9665c55568afea143e3490fa8a1d5f6409fbc94956a9a95cfe258f6236e0805e96080d8347153d64d8823983e9cdfbdb08140d1933b3d8f874356551c
135+
136+
STEP 5: Using the message bytes and signature recieve the funds on destination chain and address
137+
ReceiveTx 0xa4960f3caad924ffd6982bde512dff930cc1276e4d2ea92b7ab2f1f81bf17bc4
138+
139+
ReceiveTxReceipt: {
140+
blockHash: '0xc7635b7727dd31d44f7b75edfb7298cfe661da5c8910fda8eaa1638a98b9fc68',
141+
blockNumber: 30168739n,
142+
contractAddress: null,
143+
cumulativeGasUsed: 325719n,
144+
effectiveGasPrice: 25000000000n,
145+
from: '0xe45d43feb3f65b4587510a68722450b629154e6f',
146+
gasUsed: 143755n,
147+
logs: [
148+
{
149+
address: '0x5425890298aed601595a70ab815c96711a31bc65',
150+
topics: [Array],
151+
data: '0x00000000000000000000000000000000000000000000000000000000000186a0',
152+
blockNumber: 30168739n,
153+
transactionHash: '0xa4960f3caad924ffd6982bde512dff930cc1276e4d2ea92b7ab2f1f81bf17bc4',
154+
transactionIndex: 1,
155+
blockHash: '0xc7635b7727dd31d44f7b75edfb7298cfe661da5c8910fda8eaa1638a98b9fc68',
156+
logIndex: 2,
157+
removed: false
158+
},
159+
{
160+
address: '0x5425890298aed601595a70ab815c96711a31bc65',
161+
topics: [Array],
162+
data: '0x00000000000000000000000000000000000000000000000000000000000186a0',
163+
blockNumber: 30168739n,
164+
transactionHash: '0xa4960f3caad924ffd6982bde512dff930cc1276e4d2ea92b7ab2f1f81bf17bc4',
165+
transactionIndex: 1,
166+
blockHash: '0xc7635b7727dd31d44f7b75edfb7298cfe661da5c8910fda8eaa1638a98b9fc68',
167+
logIndex: 3,
168+
removed: false
169+
},
170+
{
171+
address: '0xeb08f243e5d3fcff26a9e38ae5520a669f4019d0',
172+
topics: [Array],
173+
data: '0x00000000000000000000000000000000000000000000000000000000000186a0',
174+
blockNumber: 30168739n,
175+
transactionHash: '0xa4960f3caad924ffd6982bde512dff930cc1276e4d2ea92b7ab2f1f81bf17bc4',
176+
transactionIndex: 1,
177+
blockHash: '0xc7635b7727dd31d44f7b75edfb7298cfe661da5c8910fda8eaa1638a98b9fc68',
178+
logIndex: 4,
179+
removed: false
180+
},
181+
{
182+
address: '0xa9fb1b3009dcb79e2fe346c16a604b8fa8ae0a79',
183+
topics: [Array],
184+
data: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000009f3b8679c73c2fef8b59b4f3444d4e156fb70aa500000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000084000000000000000000000000000000001c7d4b196cb0c7b01d743fbc6116a902379c7238000000000000000000000000e45d43feb3f65b4587510a68722450b629154e6f00000000000000000000000000000000000000000000000000000000000186a0000000000000000000000000e45d43feb3f65b4587510a68722450b629154e6f00000000000000000000000000000000000000000000000000000000',
185+
blockNumber: 30168739n,
186+
transactionHash: '0xa4960f3caad924ffd6982bde512dff930cc1276e4d2ea92b7ab2f1f81bf17bc4',
187+
transactionIndex: 1,
188+
blockHash: '0xc7635b7727dd31d44f7b75edfb7298cfe661da5c8910fda8eaa1638a98b9fc68',
189+
logIndex: 5,
190+
removed: false
191+
}
192+
],
193+
logsBloom: '0x0000000000000000008000000000000100004000000000000000010000200000200000000400000000000000000002000000a000000000000000000000000000000000000000000000000008000000000080000000000000000000200000000001020000020000000000000000012800000000000000000000400010000000000000000000000400000000001000000000000000000002000000000000010400000000000000000004100000000000040000000000000000000000000000000000000002000010000080000000000000000000000000000000000000020020000000000000000000000000000000004000000000000800000000000000000000',
194+
status: 'success',
195+
to: '0xa9fb1b3009dcb79e2fe346c16a604b8fa8ae0a79',
196+
transactionHash: '0xa4960f3caad924ffd6982bde512dff930cc1276e4d2ea92b7ab2f1f81bf17bc4',
197+
transactionIndex: 1,
198+
type: 'eip1559'
199+
}
200+
Check USDC on Avax testnet balanceOf 10000
201+
```
202+
203+
## 参考链接
204+
205+
- doc <https://developers.circle.com/stablecoins/docs/transfer-usdc-on-testnet-from-ethereum-to-avalanche>
206+
207+
- contract deployment <https://developers.circle.com/stablecoins/docs/evm-smart-contracts>
208+
209+
- USDC Testnet faucet <https://faucet.circle.com/?_gl=1*ouhs7l*_ga_GJDVPCQNRV*MTcwODUwNDQ1OC4zLjEuMTcwODUwNDQ5MS4yNy4wLjA>

0 commit comments

Comments
 (0)