diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-04-02 19:57:44 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-02 19:57:44 +0800 |
commit | d95b1e2db499d0264a1020be1ec453c5136b5a3b (patch) | |
tree | b26623424303ff4d5ba17080b53ef40d037a1426 /packages/metacoin/contracts | |
parent | 695b697cdf6c73bb4b5f920869ce128f9a9e7523 (diff) | |
parent | c1d6c7ff66079731df405e25c4b2aa83c86fffb9 (diff) | |
download | dexon-sol-tools-d95b1e2db499d0264a1020be1ec453c5136b5a3b.tar dexon-sol-tools-d95b1e2db499d0264a1020be1ec453c5136b5a3b.tar.gz dexon-sol-tools-d95b1e2db499d0264a1020be1ec453c5136b5a3b.tar.bz2 dexon-sol-tools-d95b1e2db499d0264a1020be1ec453c5136b5a3b.tar.lz dexon-sol-tools-d95b1e2db499d0264a1020be1ec453c5136b5a3b.tar.xz dexon-sol-tools-d95b1e2db499d0264a1020be1ec453c5136b5a3b.tar.zst dexon-sol-tools-d95b1e2db499d0264a1020be1ec453c5136b5a3b.zip |
Merge pull request #485 from 0xProject/feature/metacoin
Add metacoin example project
Diffstat (limited to 'packages/metacoin/contracts')
-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; + } +} |