Astar zkEVM

Environment

Network Name

Astar zkEVM

Network URL

Chain ID

3776

Currency Symbol

ETH

Block Explorer URL

Solidity Contract Integration

https://github.com/bifrost-finance/slpx-contracts/tree/main/contracts

If you want to integrate SLPx in your contract, please see a sample code.

Among them are calls to the mintVNativeAsset and mintVAsset methods

Because of the use of XCM technology, the result of the call is not real-time, you'd better put the SLPx call at the end of your contract logic.

// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

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

contract Test {

    address public constant SLPX = 0x2fD8bbF5dc8b342C09ABF34f211b3488e2d9d691;

    function test_native_mint (address to) public payable   {
        // your contract logic.
        // ...
        
        // call mint
        ISlpx(SLPX).mintVNativeAsset{value: msg.value}(to);
    }

    function test_mint (address assetAddress, uint256 amount, address to) public  {
        IERC20(assetAddress).transferFrom(msg.sender,address(this),amount);
        IERC20(assetAddress).approve(address(SLPX), amount);
        
        // your contract logic.
        // ...
        
        // call mint
        ISlpx(SLPX).mintVAsset(assetAddress,amount,to);
    }

    function test_redeem (address assetAddress, uint256 amount, address to) public  {
        IERC20(assetAddress).transferFrom(msg.sender,address(this),amount);
        IERC20(assetAddress).approve(address(SLPX), amount);
        ISlpx(SLPX).redeemAsset(assetAddress,amount);
    }
		
    function test_swap(address assetInAddress, address assetOutAddress,uint256 amount, uint128 amountOutMin,address to) public  {
        IERC20(assetInAddress).transferFrom(msg.sender,address(this),amount);
        IERC20(assetInAddress).approve(address(SLPX), amount);
        ISlpx(SLPX).swapAssetsForExactAssets(assetInAddress,assetOutAddress,amount,amountOutMin,to);
    }
}

Last updated