From 4d9029bb0e3b215efdf165704c80d3bacef0e85a Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Wed, 28 Mar 2018 11:05:36 +0200 Subject: Add metacoin example project --- packages/metacoin/contracts/Metacoin.sol | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 packages/metacoin/contracts/Metacoin.sol (limited to 'packages/metacoin/contracts') 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; + } +} -- cgit v1.2.3