LogoLogo
HomeDappGithub
  • 🌈What is Bifrost
    • Bifrost vs Others
    • Bifrost cross-chain architecture
    • Bifrost security model
  • 🧬Tokenomics 2.0
    • Overview
    • Protocol Growth Flywheel
    • Core - bbBNC
      • How to maximize your bbBNC yield?
      • How to get or redeem?
    • BNC
    • vBNC
    • Treasury
  • 📚FAQ
    • Glossary
    • What are vTokens?
      • vETH
      • vKSM
      • vDOT
      • vFIL
      • vGLMR & vMOVR
      • vMANTA
      • vASTR
      • Validator Governance
      • XCM V3 in Bifrost
      • Mint/Redeem vToken without Dapp
    • What is LoopStake?
      • LoopStake Lending Parameters
    • What is LST Governance?
    • What is LST Stable Swap?
    • What is vToken Delegation Voting?
  • 🏃Dapp Tutorials & use cases
    • Liquid Staking on Bifrost
    • Liquid Staking on Omni LS
    • Loop Stake (Leverage Staking)
    • Governance with vDOT & vKSM
    • Providing Liquidity on DEX/Perp DEX
    • Supplying Liquidity on Money Market
    • Yield DCA
    • Farming
    • Unstaking
  • 🦸For the Community
    • Ambassadors
    • Governance
      • Overview
      • Proposal Guidelines (polkadot.js)
      • Proposal Guidelines (Subsquare)
      • OpenGov Components
      • OpenGov Tracks
        • Root
        • WhitelistedCaller
        • Liquid Staking
      • Proposal Template
        • HRMP
        • Validator Boost List
      • Bifrost Fellowship
      • On-chain Identity
    • Rainbow Boost
  • ⚒️For Builders
    • Build with SLPx
      • Overview
      • Supported Networks
        • Soneium
        • Astar
        • Manta Pacific
        • Moonbeam
        • Moonriver
        • Ethereum
      • XCM Oracle
    • vToken APIs
    • Builder Programs
      • Grants and Funding Program
      • Open Bounties
      • Bug Bounty
  • 🧩For Partners
    • Reward-Share Program (RSP)
      • Why RSP?
      • Integrate RSP
      • Claim RSP Rewards
      • Terms & Conditions
      • FAQ
    • Join The Program
    • Validator Boost List (VBL)
  • ⚖️For Collators
    • Requirement
    • Run a Collator
    • Stop Collating
  • 📦Resources
    • Tools
    • Audit Report
    • Press Kit
    • Token Icon
Powered by GitBook
On this page
  • Introduction
  • Network
  • Contract info
  • Examples
  • Currency id & Destination Chain id

Was this helpful?

  1. For Builders
  2. Build with SLPx
  3. Supported Networks

Astar

PreviousSoneiumNextManta Pacific

Last updated 4 months ago

Was this helpful?

Introduction

This guide will show how to integrate SLPx in your contact logic. It is based on the SLPx . To run this example, check out the guide below.

To get started with local development on Astar, check out .

In this example we will integrate vDOT minting & redemption in our contract logic. The tokens, amount of input token, destination chain id, and channel id can be configured as inputs.

The guide will cover:

  1. Clarifying the contract info

  2. Constructing vDOT minting in your contract

  3. Constructing vDOT redemption in your contract

Network

SLPx contract address under Astar network:

Network
Slpx Address

Astar

0xc6bf0C5C78686f1D0E2E54b97D6de6e2cEFAe9fD

Contract info

/**
    * @dev Create order to mint vAsset or redeem vAsset on bifrost chain
    * @param assetAddress The address of the asset to mint or redeem
    * @param amount The amount of the asset to mint or redeem
    * @param dest_chain_id When order is executed on Bifrost, Asset/vAsset will be transferred to this chain
    * @param receiver The receiver address on the destination chain, 20 bytes for EVM, 32 bytes for Substrate
    * @param remark The remark of the order, less than 32 bytes. For example, "OmniLS"
    * @param channel_id The channel id of the order, you can set it. Bifrost chain will use it to share reward.
    **/
    function create_order(
        address assetAddress,
        uint128 amount,
        uint64 dest_chain_id,
        bytes memory receiver,
        string memory remark,
        uint32 channel_id
    ) external payable;

Before starting, let's talk about the values we fetched here and what they represent:

  • create_order calls the SLPx contract to mint or redeem vAsset on the Bifrost chain.

  • assetAddress is the address of the asset you want to mint or redeem.

  • amount is the amount of the asset you want to mint or redeem.

  • dest_chain_id represents the chain that your contract is deploying on, once that order in create_order is executed on Bifrost, Asset/vAsset will be transferred to this chain.

  • receiver is the asset receiver address on the destination chain, 20 bytes for EVM, 32 bytes for Substrate.

  • remark is the remark of the order, less than 32 bytes. For example, "OmniLS"

Examples

We assume you're trying to integrate vDOT minting and redemption into your contract. To do this, follow the examples below and adjust your inputs accordingly.

  • Mint 1 DOT into VDOT and send it to Astar.

  • Redeem 1 VDOT into DOT and send it to Astar.

// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.10;

import "./ISlpx.sol";
import "./IERC20.sol";

contract Example { 
    ISlpx public slpx = ISlpx(0xc6bf0C5C78686f1D0E2E54b97D6de6e2cEFAe9fD);
    address dot = 0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF;
    address vdot = 0xFfFfFfff00000000000000010000000000000008;
    // Astar parachain id
    uint64 astar_chain_id = 592;
    // EVM account public key
    bytes20 receiver = 0xa05d045646ecff8760f9bc3ae4266e910a307f0c11250c3f6fe3ae611dbf8f24;
    uint128 amount = 10_000_000_000; 
    string remark = "Hello Slpx";
    uint32 channel_id = 0;
    
    function mint_vdot() public payable {
        IERC20(dot).transferFrom(msg.sender, address(this), amount);
        IERC20(dot).approve(address(slpx), amount);
        slpx.create_order(
            dot,
            amount,
            astar_chain_id,
            abi.encodePacked(receiver),
            remark,
            channel_id
        );

        //Your contract logic: 

     }

    // Redeem DOT for 0-28 days, once redeemed, it will be sent to the receiver of dest chain
     function redeem_dot() public payable {
        IERC20(vdot).transferFrom(msg.sender, address(this), amount);
        IERC20(vdot).approve(address(slpx), amount);
        slpx.create_order(
            vdot,
            amount,
            astar_chain_id,
            abi.encodePacked(receiver),
            remark,
            channel_id
        );

        //Your contract logic: 

     }
}

Currency id & Destination Chain id

Configure your currency id and chain id inputs by checking the params below:

Astar

Chains
Dest_Chain_Id
Receiver Type

Astar

592

Ethereum Address(Byets20)

Token
Address
CurrencyId
operationalMin

BNC

0xfFffFffF00000000000000010000000000000007

0x0001

1_000_000_000_000

DOT

0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF

0x0800

1_000_000_000_000

ASTR

0x0000000000000000000000000000000000000000

0x0803

1_000_000_000_000_000_000

GLMR

0xFFFFFFFF00000000000000010000000000000003

0x0801

1_000_000_000_000_000_000

Bifrost_Voucher_DOT

0xFfFfFfff00000000000000010000000000000008

0x0900

6_000_000_000

Bifrost_Voucher_GLMR

0xFFFFFFFF00000000000000010000000000000015

0x0901

800_000_000_000_000_000

Bifrost_Voucher_ASTR

0xfffFffff00000000000000010000000000000010

0x0903

800_000_000_000_000_000

channel_id is a unique identifier for the order. It's used to join Bifrost Protocol Revenue Sharing Program (RSP). You can set it if you have one. Check to learn more.

⚒️
vTokenminting code example
local development guide
here