aboutsummaryrefslogtreecommitdiff
path: root/examples/multicoin/mc_test.sol
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2020-07-30 14:18:44 -0400
committerDeterminant <[email protected]>2020-07-30 14:18:44 -0400
commit0444e66f640999c15496066637841efcc0433934 (patch)
treec19aec2dced2e9129c880c19c52ca0f87b3d62f6 /examples/multicoin/mc_test.sol
parentcffa0954bbdb43821d1b71d00f99fb705cecd25b (diff)
parent1f49826de2bb8bb4f5f99f69fd2beb039b1172d9 (diff)
Merge branch 'multi-coin'
Diffstat (limited to 'examples/multicoin/mc_test.sol')
-rw-r--r--examples/multicoin/mc_test.sol27
1 files changed, 27 insertions, 0 deletions
diff --git a/examples/multicoin/mc_test.sol b/examples/multicoin/mc_test.sol
new file mode 100644
index 0000000..ec07ee6
--- /dev/null
+++ b/examples/multicoin/mc_test.sol
@@ -0,0 +1,27 @@
+pragma solidity >=0.6.0;
+
+contract MCTest {
+ address constant MultiCoin = 0x0100000000000000000000000000000000000000;
+ uint256 balance;
+ constructor() public {
+ // enable multi-coin functionality (it is disabled by default)
+ (bool success,) = MultiCoin.call(abi.encodeWithSignature("enableMultiCoin()"));
+ require(success);
+ }
+
+ function updateBalance(uint256 coinid) public {
+ (bool success, bytes memory data) = MultiCoin.call(abi.encodeWithSignature("getBalance(uint256)", coinid));
+ require(success);
+ balance = abi.decode(data, (uint256));
+ }
+
+ function withdraw(uint256 amount, uint256 coinid, uint256 amount2) public {
+ (bool success,) = MultiCoin.call(
+ abi.encodeWithSignature("transfer(address,uint256,uint256,uint256)",
+ msg.sender, amount, coinid, amount2));
+
+ require(success);
+ }
+
+ receive() external payable {}
+}