Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions docs/developers/dapps/staking_backend/staking_backend.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: Staking Backend
sidebar_label: Staking Backend
sidebar_position: 4
---

# Staking Backend

import { Redirect } from '@docusaurus/router';

<Redirect to="/guides/networks/phase-2/testnet/staking_backend/" />
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"label": "Babylon Wallet Integration",
"position": 1,
"link": {
"type": "generated-index",
"description": "Guides for wallets to integrate with Babylon Genesis chain."
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
---
sidebar_label: Wallet Integration Guide
sidebar_position: 1
---

# Babylon Genesis Chain Wallet Integration

The Babylon Genesis is a PoS chain built using the
Cosmos SDK and utilises most of the vanilla Cosmos SDK functionality
shared among chains developed using it. Therefore,
a wallet already supporting chains built using
Cosmos SDK should find it straightforward to add
Babylon Genesis as a supported blockchain.

In this document, we will walk through the considerations of integrating
the Babylon Genesis blockchain into your wallet:
* [Babylon Genesis network information](#babylon-genesis-network-information)
* [Accounts, message signing, token balance, and token transfer](#accounts-message-signing-token-balance-and-token-transfer)
* [Staking](#staking)
* [Unbonding](#unbonding)

### Babylon Genesis Network Information

Following is a list of the key network details of
Babylon Genesis:
* RPC nodes can be found for the network you are interested in
[our networks registry](https://github.com/babylonlabs-io/networks).
* Token minimum denomination: `ubbn` (6 decimals)
* Human-readable denomination: `BABY`

### Accounts, message signing, token balance, and token transfer

The Babylon Genesis chain utilises the default Cosmos SDK
functionality for accounts, message signing,
token balance, and token transfer.
Please refer to the relevant
[Cosmos SDK documentation](https://docs.cosmos.network/)
for more details.

### Staking

The Babylon blockchain uses an epochised staking
mechanism where staking transactions are executed
at the end of an epoch rather than immediately.

* An epoch is defined as a specific block range,
determined by an epoch interval defined
in the `x/epoching` module's
[parameters](https://github.com/babylonlabs-io/babylon/blob/release/v1.x/proto/babylon/epoching/v1/params.proto).
* During each epoch, staking messages are queued
in a delayed execution queue.
* At the epoch's end, all queued staking messages
are processed in a batch, resulting in
epoch based voting power transitions.

To enable this mechanism,
Babylon modifies the standard Cosmos SDK staking process:
* Babylon replaces the default Cosmos SDK `x/staking` module
with a custom module, `x/epoching`.
* This custom module wraps the standard staking functionality
to enforce epoch-based voting power transitions.
* The wrapped staking messages are largely similar
to those in the default `x/staking` module.
The specifications of these wrapped messages are available
[here](https://github.com/babylonlabs-io/babylon/tree/main/x/epoching).

Wallets wishing to support Babylon PoS delegations
natively must use the custom `x/epoching` mechanism.

The epochised staking approach introduces the following
UX considerations for wallet integration:
* **Delayed Staking Activation**: Although wrapped staking messages are
executed immediately, the actual staking operation takes effect only
at the epoch's end. Wallets should clearly communicate this
delay to users to set proper expectations.
* **Delayed Funds Locking**: Users' funds remain liquid until staking
activation occurs at the epoch's conclusion. This creates a for staking failure:
if users transfer or spend their funds before staking takes effect,
the staking transaction will fail.
Wallets should warn users about this possibility.

Wallets can provide users with visibility into pending staking
messages using the
[LastEpochMsgs query in x/epoching](https://github.com/babylonlabs-io/babylon/blob/main/proto/babylon/epoching/v1/query.proto#L46).
This query allows wallets to display the messages queued
for execution at the end of the current epoch.

### Unbonding

Babylon speeds up the unbonding process by leveraging
Bitcoin timestamping, significantly reducing
the unbonding period from the default 21 days in the
Cosmos SDK to approximately ~50 hours.

This process works as follows:
* **Epoch Timestamping**: At the end of each epoch,
Babylon records its blockchain state onto the
Bitcoin blockchain through a Bitcoin timestamp.
* **Bitcoin Confirmations**: Once the timestamp receives
a sufficient number of confirmations on the Bitcoin blockchain
(a parameter configurable in Babylon), the state of the epoch
if considered finalized.
* The number of required Bitcoin confirmations is set by the
`x/btccheckpoint` module, detailed
[here](https://github.com/babylonlabs-io/babylon/blob/main/proto/babylon/btccheckpoint/v1/params.proto#L24)
* For example, on the Babylon Genesis mainnet,
this value will be set to 300 confirmations,
corresponding to roughly ~33 hours for unbonding to be completed,
assuming an average Bitcoin block time of 10 minutes.
* **Unbonding Finalization**: All unbonding requests submitted
up to the end of that epoch are processed and finalized
after the required Bitcoin confirmations are reached.

An example scenario demonstrating how fast unbonding
works in practice:
* **Setup**
* Epoch interval: 300 blocks
* Bitcoin confirmations for finalization: 300 blocks
* **Unbonding Request**:
* A user submits an unbonding transaction at block `157`
* **Epoch Processing**:
* The unbonding transaction is queued and processed at
the end of the epoch (block 300).
* The user’s status is updated to unbonding, and the epoch’s
state is timestamped on Bitcoin.
* **Finalization**:
* After ~50 hours, the Bitcoin timestamp reaches 300 confirmations.
* Babylon Genesis detects this and completes the unbonding process,
fully unbonds the user’s stake.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"label": "Bitcoin Wallet Integration",
"position": 2
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
title: Bitcoin Wallet Integration
sidebar_position: 1
---

# Bitcoin Wallet Integration

This section provides documentation for integrating Babylon Bitcoin Staking to different
types of Bitcoin wallets. Whether you're building a web application, mobile app,
or hardware wallet, specific guides are provided for each wallet type.

## Integration Guides

import DocCardList from '@theme/DocCardList';

<DocCardList />

Let's get started with your preferred wallet integration.
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
sidebar_label: Extension Wallets
sidebar_position: 2
---

# Bitcoin Staking for Extension Wallets

This guide outlines the various approaches for integrating Babylon bitcoin staking
functionality into browser extension wallets.

## Option 1

Be added to a third party’s bitcoin staking website as
a wallet for either Bitcoin or Babylon or both.
This requires collaboration with the host of the
website and exposing compatible wallet APIs.
* To be supported in the Babylon hosted staking website as a Bitcoin or Babylon
wallet, please integrate with the Tomo Wallet Connect
by following the
[docs](https://docs.tomo.inc/tomo-sdk/tomo-connect-sdk-lite).
* This is the preferred method for wallet integration that will achieve
the most timely results. The Babylon hosted website will also support
native wallet integrations for select wallets with long-established
support.

## Option 2

Host your own bitcoin staking website
that connects to your extension wallet and retrieves
staking information from a backend you operate.
* For information about `developing/hosting` your own bitcoin staking website,
please check:
* our reference web application
[implementation](https://github.com/babylonlabs-io/simple-staking/).
* our
[TypeScript](https://github.com/babylonlabs-io/btc-staking-ts/)
and [Golang](https://github.com/babylonlabs-io/babylon/tree/main/btcstaking/)
Bitcoin Staking libraries for creating bitcoin Staking transactions.
* our [documentation](https://github.com/babylonlabs-io/babylon/tree/main/x/btcstaking)
on the flow of bitcoin staking transaction creation and submission in
conjunction with Bitcoin and Babylon Genesis blockchains.
* For information about the reference Babylon staking backend, please read this
[document](/guides/networks/phase-2/testnet/staking_backend/).

## Option 3

Develop bitcoin staking as a feature on your extension wallet,
which connects to either third party APIs
(such as the Babylon [Staking API](https://docs.babylonlabs.io/api/staking-api/babylon-staking-api/)) or a backend you operate.

* For information about developing your own bitcoin staking as a feature,
please check:
* our reference web application [implementation](https://github.com/babylonlabs-io/simple-staking/tree/main).
* our
[TypeScript](https://github.com/babylonlabs-io/btc-staking-ts/)
and [Golang](https://github.com/babylonlabs-io/babylon/tree/main/btcstaking/)
Bitcoin Staking libraries.
* our [documentation](https://github.com/babylonlabs-io/babylon/tree/main/x/btcstaking)
on the flow of bitcoin staking transaction creation and submission in
conjunction with Bitcoin and Babylon Genesis blockchains.

* For information about the reference babylon staking backend, please read this
[document](/guides/networks/phase-2/testnet/staking_backend/).
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
title: Hardware Wallets
sidebar_label: Hardware Wallets
sidebar_position: 4
---

# Hardware Wallets

This guide outlines the various approaches for integrating Babylon bitcoin staking
functionality into hardware wallets.

## Option 1

Develop bitcoin staking as a feature of your hardware wallet,
which connects to either third party APIs
(such as the Babylon [Staking API](https://staking-api.babylonlabs.io/swagger/doc.json)) or a backend you operate.

* For information about developing your own Bitcoin staking as a feature,
please check:
* our reference web application [implementation](https://github.com/babylonlabs-io/simple-staking/tree/main).
* our
[TypeScript](https://github.com/babylonlabs-io/btc-staking-ts/)
and [Golang](https://github.com/babylonlabs-io/babylon/tree/main/btcstaking/)
Bitcoin Staking libraries.
* our [documentation](https://github.com/babylonlabs-io/babylon/tree/main/x/btcstaking)
on the flow of bitcoin staking transaction creation and submission in
conjunction with Bitcoin and Babylon Genesis blockchains.

* For information about the reference Babylon staking backend, please read this
[document](/guides/networks/phase-2/testnet/staking_backend/).

## Option 2

Integrate via a compatible software wallet (extension or mobile)
that is bitcoin staking enabled.
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
sidebar_label: Mobile App Wallets
sidebar_position: 3
---

# Bitcoin Staking for Mobile App Wallets

This guide outlines the various options for integrating Babylon bitcoin staking
functionality into mobile app wallets.

## Option 1

Embed a third-party Bitcoin staking website to your mobile app
wallet, which interacts with the Bitcoin and Babylon signers inside your wallet via
the application window interface.
To embed on the Babylon hosted staking website, please ensure
that the interface of your mobile wallet (or a wrapper of it)
adheres to the
[Injectable Wallet interface](https://github.com/babylonlabs-io/wallet-connector?tab=readme-ov-file#wallet-integration).


## Option 2

Host your own Bitcoin staking website that connects to your
extension wallet that retrieves staking information from a backend you
operate. Then embed your own Bitcoin staking website to your mobile app wallet.
* For information about developing/hosting your own Bitcoin staking website,
please check:
* our reference web application
[implementation](https://github.com/babylonlabs-io/simple-staking/).
* our
[TypeScript](https://github.com/babylonlabs-io/btc-staking-ts/)
and [Golang](https://github.com/babylonlabs-io/babylon/tree/main/btcstaking/)
Bitcoin Staking libraries for creating bitcoin Staking transactions.
* our [documentation](https://github.com/babylonlabs-io/babylon/tree/main/x/btcstaking)
on the flow of bitcoin Staking transaction creation and submission in
conjunction with Bitcoin and Babylon blockchains.
* For information about the reference Babylon staking backend, please read this
[document](/guides/networks/phase-2/testnet/staking_backend/).

## Option 3

Develop bitcoin staking as a feature of your mobile wallet,
which connects to either third party APIs
(such as the Babylon
[Staking API](/api/staking-api/babylon-staking-api/)) or a backend you operate.

* For information about developing your own bitcoin staking as a feature,
please check:
* our reference web application [implementation](https://github.com/babylonlabs-io/simple-staking/tree/main).
* our
[TypeScript](https://github.com/babylonlabs-io/btc-staking-ts/)
and [Golang](https://github.com/babylonlabs-io/babylon/tree/main/btcstaking/)
Bitcoin Staking libraries.
* our [documentation](https://github.com/babylonlabs-io/babylon/tree/main/x/btcstaking)
on the flow of bitcoin staking transaction creation and submission in
conjunction with Bitcoin and Babylon blockchains.
* For information about the reference Babylon staking backend, please read this
[document](/guides/networks/phase-2/testnet/staking_backend/).
48 changes: 0 additions & 48 deletions docs/developers/wallet_integration/extension_wallets.mdx

This file was deleted.

Loading
Loading