diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-03-28 17:05:36 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-04-02 17:34:29 +0800 |
commit | 4d9029bb0e3b215efdf165704c80d3bacef0e85a (patch) | |
tree | 8f699dcd0a7b5fba3c31c065a62d640407bba8c3 /packages/metacoin/contracts/Metacoin.sol | |
parent | bc49dde4d5d24b9a8b01459bde061f9b23fb5898 (diff) | |
download | dexon-sol-tools-4d9029bb0e3b215efdf165704c80d3bacef0e85a.tar dexon-sol-tools-4d9029bb0e3b215efdf165704c80d3bacef0e85a.tar.gz dexon-sol-tools-4d9029bb0e3b215efdf165704c80d3bacef0e85a.tar.bz2 dexon-sol-tools-4d9029bb0e3b215efdf165704c80d3bacef0e85a.tar.lz dexon-sol-tools-4d9029bb0e3b215efdf165704c80d3bacef0e85a.tar.xz dexon-sol-tools-4d9029bb0e3b215efdf165704c80d3bacef0e85a.tar.zst dexon-sol-tools-4d9029bb0e3b215efdf165704c80d3bacef0e85a.zip |
Add metacoin example project
Diffstat (limited to 'packages/metacoin/contracts/Metacoin.sol')
-rw-r--r-- | packages/metacoin/contracts/Metacoin.sol | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/packages/metacoin/contracts/Metacoin.sol b/packages/metacoin/contracts/Metacoin.sol new file mode 100644 index 000000000..6b6814b21 --- /dev/null +++ b/packages/metacoin/contracts/Metacoin.sol @@ -0,0 +1,25 @@ +pragma solidity ^0.4.21; +pragma experimental ABIEncoderV2; + +contract Metacoin { + mapping (address => uint) public balances; + + event Transfer(address indexed _from, address indexed _to, uint256 _value); + + struct TransferData { + address to; + uint256 amount; + } + + function Metacoin() public { + balances[msg.sender] = 10000; + } + + function transfer(TransferData transferData) public returns (bool success) { + if (balances[msg.sender] < transferData.amount) return false; + balances[msg.sender] -= transferData.amount; + balances[transferData.to] += transferData.amount; + Transfer(msg.sender, transferData.to, transferData.amount); + return true; + } +} |