aboutsummaryrefslogtreecommitdiff
path: root/contracts/nativeAssets.sol
diff options
context:
space:
mode:
authorAaron Buchwald <[email protected]>2020-11-23 20:46:35 -0500
committerAaron Buchwald <[email protected]>2020-12-15 10:46:26 -0500
commit368844ad2a28ec07848e3c0169cf2b83b579a2e8 (patch)
tree0b3956351add28aed944824eb45ffb2723809dba /contracts/nativeAssets.sol
parent2d0a37c6490dc9a4ec36ee4ebbed01c790f0426a (diff)
Add native asset precompiled contracts for apricot release
Diffstat (limited to 'contracts/nativeAssets.sol')
-rw-r--r--contracts/nativeAssets.sol20
1 files changed, 20 insertions, 0 deletions
diff --git a/contracts/nativeAssets.sol b/contracts/nativeAssets.sol
new file mode 100644
index 0000000..0656271
--- /dev/null
+++ b/contracts/nativeAssets.sol
@@ -0,0 +1,20 @@
+// SPDX-License-Identifier: MIT
+
+pragma solidity >=0.6.0 <0.8.0;
+
+library NativeAssets {
+ address constant balanceAddr = 0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF;
+ address constant transferAddr = 0xffffFFFfFFffffffffffffffFfFFFfffFFFfFFfE;
+
+ 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;
+ }
+}