Bifrost Developers

Ethereum

Integrate SLPx protocol on Ethereum

Getting started

Make sure you add RPC for Moonbeam. Information can be obtained from chainlist.org

Or manual input with the information below

NameValue
Network NameSoneium Network
DescriptionThe public mainnet for Soneium Network.
Network URLhttps://soneium.org/
Explorer URLhttps://soneium.blockscout.com/
RPC URLhttps://rpc.soneium.org/
Chain ID1868
Currency SymbolETH

xcASTR token

NameValue
Address0xFfFFFfffA893AD19e540E172C10d78D4d479B5Cf
NamexcASTR
SymbolxcASTR
Decimals18

MoonbeamSlpx.sol contract

Integration

MoonbeamSLPx contract does not support atomic contract calls. That means you can't integrate within your contract logic. The reason are as follows:

  • there is a wait time of about 45 to 60 to receive the vAsset token.

However, you can still interact with the contract directly from the frontend or use another contract but the call is structured at the end of the logic.

There are 2 main functions you use to integrate with MoonbeamSlpx:

addressToAssetInfo (derived from the public mapping addressToAssetInfo)

function addressToAssetInfo(address assetAddress) public view returns (currencyId bytes2, operationalMin uint256)

Sample call

MoonbeamSlpx.addressToAssetInfo(0x0000000000000000000000000000000000000802)

Sample return

currencyId       bytes2   :  0x0801
operationalMin   uint256  :  5000000000000000000

create_order

/**
  * @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;
VariableInput valueDefinition
address assetAddressa valid Moonbeam token contract addressAddress of different tokens on Moonbeam
uint128 amountuint128Amount of tokens to mint or redeem
uint64 dest_chain_id1284Chain ID of Moonbeam
bytes memory receivera valid Moonbeam addressAsset receiver address on the destination chain, 20 bytes address for EVM
string memory remarkstring of less than 32 bytesA string used to identify the order
uint32 channel_iduint32Channel ID of the order. Used for the Bifrost Protocol Revenue Sharing Program (RSP). You can set it if you have one. Check here to learn more

Token address list

TokenAddress
xcDOT0xFfFFfFff1FcaCBd218EDc0EbA20Fc2308C778080
xcASTR0xFfFFFfffA893AD19e540E172C10d78D4d479B5Cf
GLMR0x0000000000000000000000000000000000000802

Asset Info List

TokencurrencyIdoperationalMin
xcDOT0x080010000000000 (10_000_000_000)
xcASTR0x08035000000000000000000 (5_000_000_000_000_000_000)
GLMR0x08015000000000000000000 (5_000_000_000_000_000_000)

Waiting time

Then wait for 45 to 60 seconds after transaction confirmation to receive the vAsset token in the caller address.

Example Wagmi integration

addressToAssetInfo

const { data: assetInfo } = useReadContract({
  ...wagmiContractConfig,
  address: "0xF1d4797E51a4640a76769A50b57abE7479ADd3d8",
  abi: moonbeamSLPxAbi,
  functionName: "addressToAssetInfo",
  args: ["0x0000000000000000000000000000000000000802"],
});
console.log("assetInfo", assetInfo);

// Output: assetInfo { currencyId: '0x0801', operationalMin: 5000000000000000000n }

create_order

for ERC20 token

const { 
  data: hash,
  error,
  isPending, 
  writeContract 
} = useWriteContract() 

async function approveLstContract() {
  writeContract({
    account: currentAddress, // connected address
    address: "0xFfFFfFff1FcaCBd218EDc0EbA20Fc2308C778080",
    abi: erc20Abi,
    functionName: "approve",
    args: [
      "0xF1d4797E51a4640a76769A50b57abE7479ADd3d8",
      parseUnits(1, 10), // 1 xcDOT is operationalMin and 10 is the token decimals
    ],
  })
}

async function mintLst() {
  writeContract({
    address: "0xF1d4797E51a4640a76769A50b57abE7479ADd3d8",
    abi: moonbeamSLPxAbi,
    functionName: "create_order",
    args: [
      "0xFfFFfFff1FcaCBd218EDc0EbA20Fc2308C778080", // xcDOT token address 
      parseUnits(1, 10), // amount
      1284, // Moonbeam chain id
      receiverAddress, // receiver
      "bifrost", // sample remark
      0, // sample channel_id
    ],
  })
}

const { isLoading: isConfirming, isSuccess: isConfirmed } = 
  useWaitForTransactionReceipt({ 
    hash, 
})

for GLMR token

const { 
  data: hash,
  error,
  isPending, 
  writeContract 
} = useWriteContract()

async function mintLst() {
  writeContract({
    address: "0xF1d4797E51a4640a76769A50b57abE7479ADd3d8",
    abi: moonbeamSLPxAbi,
    functionName: "create_order",
    args: [
      "0x0000000000000000000000000000000000000802", // xcDOT token address 
      parseUnits(5, 18), // amount
      1284, // Moonbeam chain id
      receiverAddress, // receiver
      "bifrost", // sample remark
      0, // sample channel_id
    ],
    value: parseUnits(5, 18) // 5 GLMR
  })
}

const { isLoading: isConfirming, isSuccess: isConfirmed } = 
  useWaitForTransactionReceipt({ 
    hash, 
})

On this page