Skip to content

Instantly share code, notes, and snippets.

@jigar23
Created June 13, 2018 15:48
Show Gist options
  • Save jigar23/befcd6af8495854693912f578b6bfc18 to your computer and use it in GitHub Desktop.
Save jigar23/befcd6af8495854693912f578b6bfc18 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=
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);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment