after truffle init & empty contract splitter

This commit is contained in:
oho 2019-05-19 13:50:03 +02:00
commit 1d64613d7b
4 changed files with 81 additions and 0 deletions

23
contracts/Migrations.sol Normal file
View file

@ -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);
}
}

27
contracts/Splitter.sol Normal file
View file

@ -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];
}
}

View file

@ -0,0 +1,5 @@
const Migrations = artifacts.require("Migrations");
module.exports = function(deployer) {
deployer.deploy(Migrations);
};

26
truffle-config.js Normal file
View file

@ -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"
}
}
*/
};