aboutsummaryrefslogtreecommitdiff
path: root/contracts/nativeAssets.sol
blob: 836c4d81ba5c741d414fce69ed3d34d9be088ae5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

library NativeAssets {
    address constant balanceAddr = 0x0100000000000000000000000000000000000001;
    address constant transferAddr = 0x0100000000000000000000000000000000000002;

    function assetBalance(address addr, uint256 assetID) public returns (uint256) {
        (bool success, bytes memory data) = balanceAddr.call(abi.encodePacked(addr, assetID));
        require(success, "assetBalance failed");
        return abi.decode(data, (uint256));
    }
    
    function assetCall(address addr, uint256 assetID, uint256 assetAmount, bytes memory callData) public returns (bytes memory) {
        (bool success, bytes memory data) = transferAddr.call(abi.encodePacked(addr, assetID, assetAmount, callData));
        require(success, "assetCall failed");
        return data;
    }
}