commit 1d64613d7bc685f09ef2d2ee6f379c3b46ff336f Author: oho Date: Sun May 19 13:50:03 2019 +0200 after truffle init & empty contract splitter diff --git a/contracts/Migrations.sol b/contracts/Migrations.sol new file mode 100644 index 0000000..c378ffb --- /dev/null +++ b/contracts/Migrations.sol @@ -0,0 +1,23 @@ +pragma solidity >=0.4.21 <0.6.0; + +contract Migrations { + address public owner; + uint public last_completed_migration; + + constructor() public { + owner = msg.sender; + } + + modifier restricted() { + if (msg.sender == owner) _; + } + + function setCompleted(uint completed) public restricted { + last_completed_migration = completed; + } + + function upgrade(address new_address) public restricted { + Migrations upgraded = Migrations(new_address); + upgraded.setCompleted(last_completed_migration); + } +} diff --git a/contracts/Splitter.sol b/contracts/Splitter.sol new file mode 100644 index 0000000..abf6cf6 --- /dev/null +++ b/contracts/Splitter.sol @@ -0,0 +1,27 @@ +pragma solidity >=0.4.25 <0.6.0; + +contract MetaCoin { + mapping (address => uint) balances; + + event Transfer(address indexed _from, address indexed _to, uint256 _value); + + constructor() public { + balances[tx.origin] = 10000; + } + + function sendCoin(address receiver, uint amount) public returns(bool sufficient) { + if (balances[msg.sender] < amount) return false; + balances[msg.sender] -= amount; + balances[receiver] += amount; + emit Transfer(msg.sender, receiver, amount); + return true; + } + + function getBalanceInEth(address addr) public view returns(uint){ + return ConvertLib.convert(getBalance(addr),2); + } + + function getBalance(address addr) public view returns(uint) { + return balances[addr]; + } +} diff --git a/migrations/1_initial_migration.js b/migrations/1_initial_migration.js new file mode 100644 index 0000000..ee2135d --- /dev/null +++ b/migrations/1_initial_migration.js @@ -0,0 +1,5 @@ +const Migrations = artifacts.require("Migrations"); + +module.exports = function(deployer) { + deployer.deploy(Migrations); +}; diff --git a/truffle-config.js b/truffle-config.js new file mode 100644 index 0000000..dfe3b8d --- /dev/null +++ b/truffle-config.js @@ -0,0 +1,26 @@ +module.exports = { + /* + networks: { + development: { // this one is optional and reduces "failing fast" dummerweise + host: "127.0.0.1", + port: 8545, + network_id: "*" + }, + test: { + host: "127.0.0.1", + port: 8545, + network_id: "*" + }, + net42:{ + host: "127.0.0.1", + port: 8545, + network_id: "42" + }, + ropsten: { + host: "127.0.0.1", + port: 8545, + network_id: "3" + } + } +*/ +};