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/sbtc/bridging-bitcoin/btc-to-sbtc.md
+75-3Lines changed: 75 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,12 @@
1
1
# Depositing: Pegging BTC into sBTC
2
2
3
+
## Intro
4
+
3
5
This guides shows how you can integrate the deposit (peg-in) flow from your front-end app to allow users to peg BTC into sBTC on the Stacks network. For more information about sBTC and an explainer of its architecture, check out the general sBTC section [here](https://app.gitbook.com/s/H74xqoobupBWwBsVMJhK/sbtc) in the Learn category.
4
6
5
-
### Breakdown of the deposit (peg-in) flow
7
+
<details>
8
+
9
+
<summary>Full breakdown of the deposit (peg-in) flow explained</summary>
6
10
7
11
***Create Deposit (Bitcoin) Transaction:**
8
12
* Structure a Bitcoin transaction to send funds to the group of signers.
@@ -21,15 +25,83 @@ This guides shows how you can integrate the deposit (peg-in) flow from your fron
21
25
* The minted sBTC is sent to the depositor's designated Stacks address, completing the deposit process.
22
26
* sBTC is SIP-010 compatible and will show up in Stacks wallets and explorers.
23
27
28
+
</details>
29
+
30
+
### tl;dr
31
+
32
+
* We'll be implementing the deposit (peg-in) flow of bridging BTC into sBTC on a front-end app using the `sbtc` js library.
33
+
* The flow consists of building a P2TR deposit address, sending BTC to that address, and then notifying the sBTC Signers of this deposit transaction.
34
+
* Implementing this flow within your app is great for UX/UI control and supporting programmable bitcoin.
35
+
36
+
### Steps
37
+
24
38
In this guide you'll touch on some of the steps above but its much simpler than you'd expect. Using the `sbtc` and `@stacks/connect` libraries, putting together the peg-in process from BTC into sBTC will simply involve the following steps:
25
39
26
40
1. Building the sBTC deposit address
27
41
2. Invoking the user's wallet to sign and broadcast the bitcoin transaction
28
42
3. Notifying the sBTC signers
29
43
4. Confirm user's sBTC balance
30
44
45
+
### Key Tools To Use
46
+
47
+
***sbtc**: A Javascript/Typescript package for integrating your own peg-in/out sbtc bridging flow.
48
+
***Stacks Connect**: A front-end library for authenticating and interacting with Stacks-supported wallets.
49
+
50
+
***
51
+
52
+
## Complete Code
53
+
54
+
If you’d like to skip the step-by-step walkthrough, here’s the complete code used in this guide.
let response =awaitclient.notifySbtc({ transaction, ...deposit });
95
+
console.log('Notify response:', response);
96
+
```
97
+
{% endcode %}
98
+
99
+
***
100
+
101
+
## Walkthrough
102
+
31
103
{% hint style="info" %}
32
-
This guide assumes you have a front-end bootstrapped with the Stacks Connect library for wallet interactions. Head to the guides for Stacks Connect before continuing with this guide.
104
+
This guide assumes you have a front-end bootstrapped with the Stacks Connect library for wallet interactions. Head to the Stacks Connect guides before continuing with this guide.
33
105
{% endhint %}
34
106
35
107
{% stepper %}
@@ -199,7 +271,7 @@ And that's all to it. You've successfully allowed your app to handle incoming BT
199
271
200
272
***
201
273
202
-
### \[Additional Insights]
274
+
##Additional Insights
203
275
204
276
### What scripts make up the custom P2TR bitcoin address?
Copy file name to clipboardExpand all lines: docs/build/more-guides/sbtc/bridging-bitcoin/sbtc-to-btc.md
+107-2Lines changed: 107 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,12 @@
1
1
# Withdrawing: Pegging sBTC into BTC
2
2
3
+
## Intro
4
+
3
5
This guides shows how you can integrate the withdrawal (peg-out) flow from your front-end app to allow users to peg sBTC back into BTC on the Bitcoin network. For more information about sBTC and an explainer of its architecture, check out the general sBTC section [here](https://app.gitbook.com/s/H74xqoobupBWwBsVMJhK/sbtc) in the Learn category.
4
6
5
-
### Breakdown of the withdrawal (peg-in) flow
7
+
<details>
8
+
9
+
<summary>Full breakdown of the withdrawal (peg-in) flow explained</summary>
6
10
7
11
***Validate and deconstruct bitcoin address**
8
12
* Validate user's inputted bitcoin address, to be used to receive BTC, is a valid bitcoin address.
@@ -17,16 +21,117 @@ This guides shows how you can integrate the withdrawal (peg-out) flow from your
* The returned BTC is sent to the depositor's designated bitcoin address, completing the withdrawal process.
19
23
24
+
</details>
25
+
20
26
{% hint style="info" %}
21
27
At the moment, the `sbtc` library does not have any direct helper methods, but as you'll see in the guide, it's relatively straightforward to do it without any abstraction methods.
22
28
{% endhint %}
23
29
30
+
### Steps
31
+
24
32
In this guide you'll touch on some of the steps above but its much less complex than the deposit flow. Putting together the peg-out process from sBTC into BTC will simply involve the following steps:
25
33
26
34
1. Validating the withdrawal bitcoin address
27
35
2. Contract call to `initiate-withdrawal-request`
28
36
3. Confirm BTC withdrawal
29
37
38
+
### Key Tools To Use
39
+
40
+
***sbtc**: A Javascript/Typescript package for integrating your own peg-in/out sbtc bridging flow.
41
+
***Stacks Connect**: A front-end library for authenticating and interacting with Stacks-supported wallets.
let withdrawalRequestId =awaitfetch(`https://sbtc-emily.com/withdrawal/sender/${stxAddress.value}`).then(response=> {
121
+
// @ts-ignore
122
+
returnresponse.withdrawals[0].requestId
123
+
})
124
+
125
+
let withdrawalInfo =awaitfetch(`https://sbtc-emily.com/withdrawal/${withdrawalRequestId}`)
126
+
console.log(withdrawalInfo);
127
+
}
128
+
```
129
+
{% endcode %}
130
+
131
+
***
132
+
133
+
## Walkthrough
134
+
30
135
{% hint style="info" %}
31
136
This guide assumes you have a front-end bootstrapped with the Stacks Connect library for wallet interactions. Head to the guides for Stacks Connect before continuing with this guide.
32
137
{% endhint %}
@@ -171,7 +276,7 @@ And that's all to it. You've successfully allowed your app to handle incoming sB
0 commit comments