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
Copy file name to clipboardExpand all lines: docs/build/more-guides/bridging-usdcx.md
+33-33Lines changed: 33 additions & 33 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ Current work is underway to abstract this entire flow via Circle's Bridge Kit SD
6
6
7
7
## Intro
8
8
9
-
[USDCx](https://app.gitbook.com/s/H74xqoobupBWwBsVMJhK/bridging/usdcx)bridges USDC into Stacks, integrating a stablecoin into its decentralized ecosystem via Circle's xReserve protocol. This enables asset transfer from Ethereum and enhances Stacks' DeFi offerings. Users access Stacks' DeFi, maintaining stable assets, increasing liquidity, and providing a reliable option for transactions and investments.
9
+
[USDCx](https://app.gitbook.com/s/H74xqoobupBWwBsVMJhK/bridging/usdcx)on Stacks opens up stablecoin liquidity into its decentralized ecosystem via Circle's xReserve protocol. This enables asset transfers from Ethereum and enhances Stacks' DeFi offerings. Users access Stacks' DeFi, maintaining stable assets, increasing liquidity, and providing a reliable option for transactions and investments.
10
10
11
11
### tl;dr
12
12
@@ -18,26 +18,26 @@ Current work is underway to abstract this entire flow via Circle's Bridge Kit SD
18
18
19
19
**Deposit**
20
20
21
-
1. Setup contract ABIs
22
-
2. Setup wallet and public clients
23
-
3. Check native ETH and USDC balance
24
-
4. Prepare deposit params
25
-
5. Approve xReserve to spend 
26
-
6. Execute deposit to remote chain
21
+
1. Setup USDC and xReserve's Solidity contract ABIs
22
+
2. Setup wallet and public clients to communicate with the Ethereum network
23
+
3. Check native ETH and USDC balances on a user's wallet.
24
+
4. Prepare deposit params before initiating deposit request.
25
+
5. Approve xReserve as a spender of your USDC.
26
+
6. Execute deposit to the remote chain Stacks.
27
27
28
28
### Key Tools To Use
29
29
30
-
* viem
31
-
*@stacks/transactions
30
+
*[viem](https://viem.sh/) - A Typescript-first library that interfaces with Ethereum.
31
+
*[stacks.js](/broken/pages/dH5waQhE6Vb7rhcrUG7z) - A js library that helps developers build Stacks apps by handling transactions, wallet authentication, and smart contract interactions.
32
32
33
33
***
34
34
35
35
## Complete Code
36
36
37
-
#### Deposit
38
-
39
37
If you want to jump straight to the full implementation, the complete working code used in this guide is shown below.
40
38
39
+
#### Deposit
40
+
41
41
{% tabs %}
42
42
{% tab title="index.ts" %}
43
43
This script bridges USDC from Ethereum Sepolia testnet to Stacks testnet by first approving the xReserve contract to spend USDC, then calling `depositToRemote` to initiate the cross-chain transfer. It encodes the Stacks recipient address into the bytes32 format required by the Ethereum contract and submits both transactions to the Sepolia network. The Stacks attestation service will receive this event and mint the equivalent amount to the specified Stacks address.
STACKS_RECIPIENT: "YOUR_STACKS_TESTNET_ADDRESS", // Address to receive minted USDCx on Stacks
348
-
DEPOSIT_AMOUNT: "1.00",
346
+
<strong> STACKS_RECIPIENT: "YOUR_STACKS_TESTNET_ADDRESS", // Address to receive minted USDCx on Stacks
347
+
</strong> DEPOSIT_AMOUNT: "1.00",
349
348
MAX_FEE: "0",
350
349
};
351
-
```
352
-
{% endcode %}
350
+
</code></pre>
353
351
{% endstep %}
354
352
355
353
{% step %}
@@ -456,17 +454,20 @@ if (nativeBalance === 0n)
456
454
457
455
Prepares the deposit parameters by converting USDC amounts to the correct decimal format (6 decimals), encoding the Stacks recipient address into bytes32 format, and setting empty hookData for the cross-chain transaction.
458
456
457
+
{% hint style="info" %}
458
+
Stacks addresses need to be reformatted and encoded to bytes32 on the Ethereum side. Special helper methods are needed for this encoding.
Executes two sequential transactions: first approves the xReserve contract to spend the specified USDC amount and waits for confirmation, then calls the `depositToRemote` function to initiate the cross-chain bridge transfer to the Stacks recipient.
0 commit comments