mirror of
https://github.com/saymrwulf/splitter.git
synced 2026-07-27 20:02:25 +00:00
splitter contract 1st draft; migrations changed; truffle_config.js changed
This commit is contained in:
parent
1d64613d7b
commit
f24f1d0826
4 changed files with 20 additions and 15 deletions
|
|
@ -1,26 +1,23 @@
|
|||
pragma solidity >=0.4.25 <0.6.0;
|
||||
|
||||
contract MetaCoin {
|
||||
mapping (address => uint) balances;
|
||||
contract Splitter {
|
||||
mapping (address => uint) public balances;
|
||||
|
||||
event Transfer(address indexed _from, address indexed _to, uint256 _value);
|
||||
event Transfer(address indexed _from, address indexed _to1, address indexed _to2, uint256 _value);
|
||||
|
||||
constructor() public {
|
||||
balances[tx.origin] = 10000;
|
||||
balances[msg.sender] = 10000;
|
||||
}
|
||||
|
||||
function sendCoin(address receiver, uint amount) public returns(bool sufficient) {
|
||||
function sendSplitCoin(address receiver1, address receiver2, 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);
|
||||
balances[receiver1] += amount/2;
|
||||
balances[receiver2] += amount/2;
|
||||
emit Transfer(msg.sender, receiver1, receiver2, 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];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
const Migrations = artifacts.require("Migrations");
|
||||
|
||||
module.exports = function(deployer) {
|
||||
module.exports = function(deployer, network, accounts) {
|
||||
console.log("network: ", network);
|
||||
console.log("accounts: ", accounts);
|
||||
|
||||
deployer.deploy(Migrations);
|
||||
};
|
||||
};
|
||||
5
migrations/2_deploy_contracts.js
Normal file
5
migrations/2_deploy_contracts.js
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
const Splitter = artifacts.require("Splitter");
|
||||
|
||||
module.exports = function(deployer) {
|
||||
deployer.deploy(Splitter);
|
||||
};
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
module.exports = {
|
||||
/*
|
||||
|
||||
networks: {
|
||||
development: { // this one is optional and reduces "failing fast" dummerweise
|
||||
host: "127.0.0.1",
|
||||
|
|
@ -22,5 +22,5 @@ module.exports = {
|
|||
network_id: "3"
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue