Skip to content

Commit 1b5f00e

Browse files
authored
Restructruing of wallet integration (#67)
* updated the wallet integration section in Developer section * spell and grammar checked * fixed broken links
1 parent f539dcb commit 1b5f00e

File tree

11 files changed

+341
-221
lines changed

11 files changed

+341
-221
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"label": "Babylon Wallet Integration",
3+
"position": 1,
4+
"link": {
5+
"type": "generated-index",
6+
"description": "Guides for wallets to integrate with Babylon Genesis chain."
7+
}
8+
}
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
---
2+
sidebar_label: Wallet Integration Guide
3+
sidebar_position: 1
4+
---
5+
6+
# Babylon Genesis Chain Wallet Integration
7+
8+
The Babylon Genesis is a PoS chain built using the
9+
Cosmos SDK and utilises most of the vanilla Cosmos SDK functionality
10+
shared among chains developed using it. Therefore,
11+
a wallet already supporting chains built using
12+
Cosmos SDK should find it straightforward to add
13+
Babylon Genesis as a supported blockchain.
14+
15+
In this document, we will walk through the considerations of integrating
16+
the Babylon Genesis blockchain into your wallet:
17+
* [Babylon Genesis network information](#babylon-genesis-network-information)
18+
* [Accounts, message signing, token balance, and token transfer](#accounts-message-signing-token-balance-and-token-transfer)
19+
* [Staking](#staking)
20+
* [Unbonding](#unbonding)
21+
22+
### Babylon Genesis Network Information
23+
24+
Following is a list of the key network details of
25+
Babylon Genesis:
26+
* RPC nodes can be found for the network you are interested in
27+
[our networks registry](https://github.com/babylonlabs-io/networks).
28+
* Token minimum denomination: `ubbn` (6 decimals)
29+
* Human-readable denomination: `BABY`
30+
31+
### Accounts, message signing, token balance, and token transfer
32+
33+
The Babylon Genesis chain utilises the default Cosmos SDK
34+
functionality for accounts, message signing,
35+
token balance, and token transfer.
36+
Please refer to the relevant
37+
[Cosmos SDK documentation](https://docs.cosmos.network/)
38+
for more details.
39+
40+
### Staking
41+
42+
The Babylon blockchain uses an epochised staking
43+
mechanism where staking transactions are executed
44+
at the end of an epoch rather than immediately.
45+
46+
* An epoch is defined as a specific block range,
47+
determined by an epoch interval defined
48+
in the `x/epoching` module's
49+
[parameters](https://github.com/babylonlabs-io/babylon/blob/release/v1.x/proto/babylon/epoching/v1/params.proto).
50+
* During each epoch, staking messages are queued
51+
in a delayed execution queue.
52+
* At the epoch's end, all queued staking messages
53+
are processed in a batch, resulting in
54+
epoch based voting power transitions.
55+
56+
To enable this mechanism,
57+
Babylon modifies the standard Cosmos SDK staking process:
58+
* Babylon replaces the default Cosmos SDK `x/staking` module
59+
with a custom module, `x/epoching`.
60+
* This custom module wraps the standard staking functionality
61+
to enforce epoch-based voting power transitions.
62+
* The wrapped staking messages are largely similar
63+
to those in the default `x/staking` module.
64+
The specifications of these wrapped messages are available
65+
[here](https://github.com/babylonlabs-io/babylon/tree/main/x/epoching).
66+
67+
Wallets wishing to support Babylon PoS delegations
68+
natively must use the custom `x/epoching` mechanism.
69+
70+
The epochised staking approach introduces the following
71+
UX considerations for wallet integration:
72+
* **Delayed Staking Activation**: Although wrapped staking messages are
73+
executed immediately, the actual staking operation takes effect only
74+
at the epoch's end. Wallets should clearly communicate this
75+
delay to users to set proper expectations.
76+
* **Delayed Funds Locking**: Users' funds remain liquid until staking
77+
activation occurs at the epoch's conclusion. This creates a for staking failure:
78+
if users transfer or spend their funds before staking takes effect,
79+
the staking transaction will fail.
80+
Wallets should warn users about this possibility.
81+
82+
Wallets can provide users with visibility into pending staking
83+
messages using the
84+
[LastEpochMsgs query in x/epoching](https://github.com/babylonlabs-io/babylon/blob/main/proto/babylon/epoching/v1/query.proto#L46).
85+
This query allows wallets to display the messages queued
86+
for execution at the end of the current epoch.
87+
88+
### Unbonding
89+
90+
Babylon speeds up the unbonding process by leveraging
91+
Bitcoin timestamping, significantly reducing
92+
the unbonding period from the default 21 days in the
93+
Cosmos SDK to approximately ~50 hours.
94+
95+
This process works as follows:
96+
* **Epoch Timestamping**: At the end of each epoch,
97+
Babylon records its blockchain state onto the
98+
Bitcoin blockchain through a Bitcoin timestamp.
99+
* **Bitcoin Confirmations**: Once the timestamp receives
100+
a sufficient number of confirmations on the Bitcoin blockchain
101+
(a parameter configurable in Babylon), the state of the epoch
102+
if considered finalized.
103+
* The number of required Bitcoin confirmations is set by the
104+
`x/btccheckpoint` module, detailed
105+
[here](https://github.com/babylonlabs-io/babylon/blob/main/proto/babylon/btccheckpoint/v1/params.proto#L24)
106+
* For example, on the Babylon Genesis mainnet,
107+
this value will be set to 300 confirmations,
108+
corresponding to roughly ~33 hours for unbonding to be completed,
109+
assuming an average Bitcoin block time of 10 minutes.
110+
* **Unbonding Finalization**: All unbonding requests submitted
111+
up to the end of that epoch are processed and finalized
112+
after the required Bitcoin confirmations are reached.
113+
114+
An example scenario demonstrating how fast unbonding
115+
works in practice:
116+
* **Setup**
117+
* Epoch interval: 300 blocks
118+
* Bitcoin confirmations for finalization: 300 blocks
119+
* **Unbonding Request**:
120+
* A user submits an unbonding transaction at block `157`
121+
* **Epoch Processing**:
122+
* The unbonding transaction is queued and processed at
123+
the end of the epoch (block 300).
124+
* The user’s status is updated to unbonding, and the epoch’s
125+
state is timestamped on Bitcoin.
126+
* **Finalization**:
127+
* After ~50 hours, the Bitcoin timestamp reaches 300 confirmations.
128+
* Babylon Genesis detects this and completes the unbonding process,
129+
fully unbonds the user’s stake.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"label": "Bitcoin Wallet Integration",
3+
"position": 2
4+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
title: Bitcoin Wallet Integration
3+
sidebar_position: 1
4+
---
5+
6+
# Bitcoin Wallet Integration
7+
8+
This section provides documentation for integrating Babylon Bitcoin Staking to different
9+
types of Bitcoin wallets. Whether you're building a web application, mobile app,
10+
or hardware wallet, specific guides are provided for each wallet type.
11+
12+
## Integration Guides
13+
14+
import DocCardList from '@theme/DocCardList';
15+
16+
<DocCardList />
17+
18+
Let's get started with your preferred wallet integration.
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
sidebar_label: Extension Wallets
3+
sidebar_position: 2
4+
---
5+
6+
# Bitcoin Staking for Extension Wallets
7+
8+
This guide outlines the various approaches for integrating Babylon bitcoin staking
9+
functionality into browser extension wallets.
10+
11+
## Option 1
12+
13+
Be added to a third party’s bitcoin staking website as
14+
a wallet for either Bitcoin or Babylon or both.
15+
This requires collaboration with the host of the
16+
website and exposing compatible wallet APIs.
17+
* To be supported in the Babylon hosted staking website as a Bitcoin or Babylon
18+
wallet, please integrate with the Tomo Wallet Connect
19+
by following the
20+
[docs](https://docs.tomo.inc/tomo-sdk/tomo-connect-sdk-lite).
21+
* This is the preferred method for wallet integration that will achieve
22+
the most timely results. The Babylon hosted website will also support
23+
native wallet integrations for select wallets with long-established
24+
support.
25+
26+
## Option 2
27+
28+
Host your own bitcoin staking website
29+
that connects to your extension wallet and retrieves
30+
staking information from a backend you operate.
31+
* For information about `developing/hosting` your own bitcoin staking website,
32+
please check:
33+
* our reference web application
34+
[implementation](https://github.com/babylonlabs-io/simple-staking/).
35+
* our
36+
[TypeScript](https://github.com/babylonlabs-io/btc-staking-ts/)
37+
and [Golang](https://github.com/babylonlabs-io/babylon/tree/main/btcstaking/)
38+
Bitcoin Staking libraries for creating bitcoin Staking transactions.
39+
* our [documentation](https://github.com/babylonlabs-io/babylon/tree/main/x/btcstaking)
40+
on the flow of bitcoin staking transaction creation and submission in
41+
conjunction with Bitcoin and Babylon Genesis blockchains.
42+
* For information about the reference Babylon staking backend, please read this
43+
[document](/guides/networks/phase-2/testnet/staking_backend/).
44+
45+
## Option 3
46+
47+
Develop bitcoin staking as a feature on your extension wallet,
48+
which connects to either third party APIs
49+
(such as the Babylon [Staking API](https://docs.babylonlabs.io/api/staking-api/babylon-staking-api/)) or a backend you operate.
50+
51+
* For information about developing your own bitcoin staking as a feature,
52+
please check:
53+
* our reference web application [implementation](https://github.com/babylonlabs-io/simple-staking/tree/main).
54+
* our
55+
[TypeScript](https://github.com/babylonlabs-io/btc-staking-ts/)
56+
and [Golang](https://github.com/babylonlabs-io/babylon/tree/main/btcstaking/)
57+
Bitcoin Staking libraries.
58+
* our [documentation](https://github.com/babylonlabs-io/babylon/tree/main/x/btcstaking)
59+
on the flow of bitcoin staking transaction creation and submission in
60+
conjunction with Bitcoin and Babylon Genesis blockchains.
61+
62+
* For information about the reference babylon staking backend, please read this
63+
[document](/guides/networks/phase-2/testnet/staking_backend/).
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
title: Hardware Wallets
3+
sidebar_label: Hardware Wallets
4+
sidebar_position: 4
5+
---
6+
7+
# Hardware Wallets
8+
9+
This guide outlines the various approaches for integrating Babylon bitcoin staking
10+
functionality into hardware wallets.
11+
12+
## Option 1
13+
14+
Develop bitcoin staking as a feature of your hardware wallet,
15+
which connects to either third party APIs
16+
(such as the Babylon [Staking API](https://staking-api.babylonlabs.io/swagger/doc.json)) or a backend you operate.
17+
18+
* For information about developing your own Bitcoin staking as a feature,
19+
please check:
20+
* our reference web application [implementation](https://github.com/babylonlabs-io/simple-staking/tree/main).
21+
* our
22+
[TypeScript](https://github.com/babylonlabs-io/btc-staking-ts/)
23+
and [Golang](https://github.com/babylonlabs-io/babylon/tree/main/btcstaking/)
24+
Bitcoin Staking libraries.
25+
* our [documentation](https://github.com/babylonlabs-io/babylon/tree/main/x/btcstaking)
26+
on the flow of bitcoin staking transaction creation and submission in
27+
conjunction with Bitcoin and Babylon Genesis blockchains.
28+
29+
* For information about the reference Babylon staking backend, please read this
30+
[document](/guides/networks/phase-2/testnet/staking_backend/).
31+
32+
## Option 2
33+
34+
Integrate via a compatible software wallet (extension or mobile)
35+
that is bitcoin staking enabled.
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
sidebar_label: Mobile App Wallets
3+
sidebar_position: 3
4+
---
5+
6+
# Bitcoin Staking for Mobile App Wallets
7+
8+
This guide outlines the various options for integrating Babylon bitcoin staking
9+
functionality into mobile app wallets.
10+
11+
## Option 1
12+
13+
Embed a third-party Bitcoin staking website to your mobile app
14+
wallet, which interacts with the Bitcoin and Babylon signers inside your wallet via
15+
the application window interface.
16+
To embed on the Babylon hosted staking website, please ensure
17+
that the interface of your mobile wallet (or a wrapper of it)
18+
adheres to the
19+
[Injectable Wallet interface](https://github.com/babylonlabs-io/wallet-connector?tab=readme-ov-file#wallet-integration).
20+
21+
22+
## Option 2
23+
24+
Host your own Bitcoin staking website that connects to your
25+
extension wallet that retrieves staking information from a backend you
26+
operate. Then embed your own Bitcoin staking website to your mobile app wallet.
27+
* For information about developing/hosting your own Bitcoin staking website,
28+
please check:
29+
* our reference web application
30+
[implementation](https://github.com/babylonlabs-io/simple-staking/).
31+
* our
32+
[TypeScript](https://github.com/babylonlabs-io/btc-staking-ts/)
33+
and [Golang](https://github.com/babylonlabs-io/babylon/tree/main/btcstaking/)
34+
Bitcoin Staking libraries for creating bitcoin Staking transactions.
35+
* our [documentation](https://github.com/babylonlabs-io/babylon/tree/main/x/btcstaking)
36+
on the flow of bitcoin Staking transaction creation and submission in
37+
conjunction with Bitcoin and Babylon blockchains.
38+
* For information about the reference Babylon staking backend, please read this
39+
[document](/guides/networks/phase-2/testnet/staking_backend/).
40+
41+
## Option 3
42+
43+
Develop bitcoin staking as a feature of your mobile wallet,
44+
which connects to either third party APIs
45+
(such as the Babylon
46+
[Staking API](/api/staking-api/babylon-staking-api/)) or a backend you operate.
47+
48+
* For information about developing your own bitcoin staking as a feature,
49+
please check:
50+
* our reference web application [implementation](https://github.com/babylonlabs-io/simple-staking/tree/main).
51+
* our
52+
[TypeScript](https://github.com/babylonlabs-io/btc-staking-ts/)
53+
and [Golang](https://github.com/babylonlabs-io/babylon/tree/main/btcstaking/)
54+
Bitcoin Staking libraries.
55+
* our [documentation](https://github.com/babylonlabs-io/babylon/tree/main/x/btcstaking)
56+
on the flow of bitcoin staking transaction creation and submission in
57+
conjunction with Bitcoin and Babylon blockchains.
58+
* For information about the reference Babylon staking backend, please read this
59+
[document](/guides/networks/phase-2/testnet/staking_backend/).

docs/developers/wallet_integration/extension_wallets.mdx

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)