Integrate RSP

Table of Contents

RSP members (with existing channel_id) can integrate RSP through the following three options:

Option 1 - Bifrost SLP API

Target Audience: Your front end can directly connect to the Bifrost (Polkadot / Kusama) parachain, such as Wallets and Dapps, etc.

Showcase 1: Staking Rewards - A PoS Data Platform

Showcase 2: Subwallet - Polkadot Wallet

Integrating Steps

  1. Get your UI & UX ready.

  2. Integrate Bifrost (Polkadot) vToken Mint API: vtokenminting_mint

    Call data: 0x7300080000e40b54020000000000000000000000000100000000

    • Check Bifrost Token indexes and decimals at here.

    • Input your channel_id (Apply you channel id via here)

Option 2 - Bifrost SLPx API (Cross-chain)

Target Audience: Blockchains that can call or deploy Bifrost SLPx across chains, such as Hydration, Moonbeam, Astar, Manta, Ethereum (coming soon), Base etc.

Integrating with EVM Contract

Showcase: Moonbeam, Astar, Manta (Omni.ls) - An omni-chain liquid staking dapp

Integrating Steps

  1. Get your UI & UX ready.

Integrating with Parachain

Showcase: Hydration’s Treasury Minted vDOT via SLPx

Hydration democracy called Bifrost SLPx via XCM and minted 1M DOT to vDOT: https://hydration.subscan.io/referenda/138?tab=preimage

Check the Preimage
[
  {
    "name": "calls",
    "type": "Vec<hydradx_runtime:RuntimeCall>",
    "value": [
      {
        "call_module": "Utility",
        "call_name": "dispatch_as",
        "call_index": "0d03",
        "params": [
          {
            "name": "as_origin",
            "type": "hydradx_runtime:OriginCaller",
            "value": {
              "system": {
                "Signed": "0x6d6f646c70792f74727372790000000000000000000000000000000000000000"
              }
            }
          },
          {
            "name": "call",
            "type": "Call",
            "value": {
              "call_index": "8900",
              "call_module": "XTokens",
              "call_name": "transfer",
              "params": [
                {
                  "name": "currency_id",
                  "type": "U32",
                  "value": 5
                },
                {
                  "name": "amount",
                  "type": "U128",
                  "value": "10000000000000000"
                },
                {
                  "name": "dest",
                  "type": "staging_xcm:VersionedMultiLocation",
                  "value": {
                    "V3": {
                      "interior": {
                        "X2": {
                          "col0": {
                            "Parachain": 2030
                          },
                          "col1": {
                            "AccountId32": {
                              "id": "0x5f13cfa22c9625df362d4f8f71647a50ed5d558a0c3d3dc72df679ecd7888d88",
                              "network": null
                            }
                          }
                        }
                      },
                      "parents": 1
                    }
                  }
                },
                {
                  "name": "dest_weight_limit",
                  "type": "staging_xcm:v3:WeightLimit",
                  "value": {
                    "Unlimited": "NULL"
                  }
                }
              ]
            }
          }
        ]
      },
      {
        "call_module": "Scheduler",
        "call_name": "schedule_after",
        "call_index": "0504",
        "params": [
          {
            "name": "after",
            "type": "U32",
            "value": 1
          },
          {
            "name": "maybe_periodic",
            "type": "option<Tuple:U32U32>",
            "value": null
          },
          {
            "name": "priority",
            "type": "U8",
            "value": 0
          },
          {
            "name": "call",
            "type": "Call",
            "value": {
              "call_index": "6b00",
              "call_module": "PolkadotXcm",
              "call_name": "send",
              "params": [
                {
                  "name": "dest",
                  "type": "staging_xcm:VersionedMultiLocation",
                  "value": {
                    "V3": {
                      "interior": {
                        "X1": {
                          "Parachain": 2030
                        }
                      },
                      "parents": 1
                    }
                  }
                },
                {
                  "name": "message",
                  "type": "staging_xcm:VersionedXcm@377",
                  "value": {
                    "V3": [
                      {
                        "DescendOrigin": {
                          "X1": {
                            "AccountId32": {
                              "id": "0x6d6f646c70792f74727372790000000000000000000000000000000000000000",
                              "network": null
                            }
                          }
                        }
                      },
                      {
                        "WithdrawAsset": [
                          {
                            "fun": {
                              "Fungible": "1000000000"
                            },
                            "id": {
                              "Concrete": {
                                "interior": {
                                  "Here": "NULL"
                                },
                                "parents": 1
                              }
                            }
                          }
                        ]
                      },
                      {
                        "BuyExecution": {
                          "fees": {
                            "fun": {
                              "Fungible": "1000000000"
                            },
                            "id": {
                              "Concrete": {
                                "interior": {
                                  "Here": "NULL"
                                },
                                "parents": 1
                              }
                            }
                          },
                          "weight_limit": {
                            "Unlimited": "NULL"
                          }
                        }
                      },
                      {
                        "Transact": {
                          "call": "0x7d0000000000000000000000000000000000000000000800026d6f646c70792f747273727900000000000000000000000000000000000000000467",
                          "origin_kind": "SovereignAccount",
                          "require_weight_at_most": {
                            "proof_size": 100000,
                            "ref_time": 10000000000
                          }
                        }
                      },
                      {
                        "DepositAsset": {
                          "assets": {
                            "Wild": {
                              "All": "NULL"
                            }
                          },
                          "beneficiary": {
                            "interior": {
                              "X1": {
                                "Parachain": 2034
                              }
                            },
                            "parents": 1
                          }
                        }
                      }
                    ]
                  }
                }
              ]
            }
          }
        ]
      }
    ]
  }
]

Inside of this preimage, it contained the call data to call SLPx mint for vDOT.

Integrating Steps

  1. Construct a XCM batch call to call Bifrost-Polkadot API: slpx_mint

The cases below demonstrate the workflow of how to mint and redeem vToken on Hydration (parachain) via Bifrost SLPx, which leveraged by XCM.

Let’s assume Alice wants to mint DOT to vDOT on Hydration, a utility.batchAll call is needed:

Extrinsic Call Data, which includes several calls inside

  • Call 1:

Call xToken sending 1 DOT to Alice’s derived account on Bifrost.

  • Call 2:

Call xToken sending 0.02 BNC to Alice’s derived account on Bifrost.

Check Bifrost Token indexes and decimals at here.

  • Call 3:

Execute slpx_mint

FAQs:

  1. Why do I need to send 0.02 BNC when minting/redeeming DOT?

Because after the user on Hydration sends an XCM transact with the command to Bifrost, it needs the derived address of the Hydration user to perform the SLPx mint operation, and there is no asset in the derived address, which will cause the transaction fail.

  1. How that derived account is being calculated?

# Alice 
yarn calculate-multilocation-derivative-account \\
--ws-provider wss://eu.bifrost-polkadot-rpc.liebi.com/ws \\
--address 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY \\
--para-id 2034 \\
--parents 1

# console
Remote Origin calculated as SiblingChain
ParaID 2034
Parents 1
AccountId32: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
32 byte address is 0xf959d131179b0264f98ac96d2c9c13c403129f5de93e52f3a611ccd4294d1741
20 byte address is 0xf959d131179b0264f98ac96d2c9c13c403129f5d

Option 3 - Bifrost Dapp Portal

Target Audience: Any entities need a Bifrost Dapp Portol to direct users by attached with your channel_id.

  1. Make sure you already have a channel_id

  2. Generate your Bifrost Dapp Portal

Bifrost Dapp frontend has adapted to the RSP. Attach your channel ID at the end of app.bifrost.io, for instance, https://app.bifrost.io/?channel=[channel_id]. All stakes via this link will be counted as your valid minting.

For example, the channel_id of Staking Rewards is 1, the vToken minting of users who enter the Bifrost Dapp through the https://app.bifrost.io/?channel=1 will be counted as the effective minting amount of Staking Rewards.

Last updated