Created
June 19, 2018 15:14
-
-
Save jigar23/9f9d3f88a18b231b87d54af5f749a36a to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.4.23+commit.124ca40d.js&optimize=false&gist=
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.0; | |
contract EtherTransferTo { | |
// fallback function no argument no return value | |
function() public payable { | |
} | |
function getBalance() public view returns (uint) { | |
return address(this).balance; | |
} | |
} | |
// Sending Ether from one contract to another | |
contract EtherTransferFrom { | |
EtherTransferTo private _instance; | |
constructor() public { | |
_instance = new EtherTransferTo(); | |
} | |
function getBalance() public view returns (uint) { | |
return address(this).balance; | |
} | |
function getBalanceOfInstance() public view returns (uint) { | |
//return address(_instance).balance; | |
return _instance.getBalance(); | |
} | |
// Transfer all money to EtherTransferTo contract | |
function() public payable { | |
address(_instance).transfer(msg.value); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.23; | |
contract TimeBasedWill { | |
address private _beneficiaries; | |
uint private _startTime; | |
uint private _expiryTime; | |
address private owner; | |
modifier onlyOwner { | |
require(msg.sender == owner); | |
_; | |
} | |
modifier checkExpiry { | |
require(now >= _expiryTime); | |
_; | |
} | |
function TimeBasedWill() public payable | |
{ | |
owner = msg.sender; | |
} | |
function approveAddresses(address beneficiaries, uint expiryTime) onlyOwner public | |
{ | |
_startTime = now; | |
_expiryTime = now + expiryTime; | |
_beneficiaries = beneficiaries; | |
} | |
function getBalanceOf() public view returns (uint) { | |
return _beneficiaries.balance; | |
} | |
function sendMoney() public payable | |
{ | |
require(now >= _expiryTime); | |
_beneficiaries.send(msg.value); | |
// uint numberOfBeneficiaries = _beneficiaries.length; | |
// uint shareOfBalance = owner.balance/numberOfBeneficiaries; | |
// for (uint i = 0; i < numberOfBeneficiaries; i++) { | |
// address beneficiary = _beneficiaries[i]; | |
// beneficiary.send(shareOfBalance); | |
// } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment