Skip to content

Instantly share code, notes, and snippets.

@NicolasMassart
Last active June 7, 2016 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NicolasMassart/64e4be53123183fca599f8394aeb129c to your computer and use it in GitHub Desktop.
Save NicolasMassart/64e4be53123183fca599f8394aeb129c to your computer and use it in GitHub Desktop.
//deployed address is 0xdf315f7485c3a86eb692487588735f224482abe3
contract Parent{
function fallback() internal {
log0("Parent fallback function");
address myAddress = this;
log0(bytes32(myAddress));
}
function (){
fallback();
}
}
//deployed address is 0x17956ba5f4291844bc25aedb27e69bc11b5bda39
contract Child is Parent {
function (){
log0("child fallback function");
address myAddress = this;
log0(bytes32(myAddress));
super.fallback();
}
}
//deployed address is 0xdf315f7485c3a86eb692487588735f224482abe3
contract Parent{
function fallback() internal {
log1("Parent fallback",bytes32(msg.value));
address myAddress = this;
log0(bytes32(myAddress));
}
function (){
fallback();
}
}
//deployed address is 0x17956ba5f4291844bc25aedb27e69bc11b5bda39
contract Child is Parent {
function (){
log0("child fallback");
// send zero ether to parent to call parent fallback
address parentAddress = 0xdf315f7485c3a86eb692487588735f224482abe3;
parentAddress.send(msg.value/2);
super.fallback();
}
}
// then send a transaction with 42 ETH to 0x17956ba5f4291844bc25aedb27e69bc11b5bda39
// log it then
/*
Ethereum Console
Sandbox LOG (Child): child fallback
Sandbox LOG (Parent): Parent fallback 21
Sandbox LOG (Parent): 0xdf315f7485c3a86eb692487588735f224482abe3
Sandbox LOG (Child): Parent fallback 42
Sandbox LOG (Child): 0x17956ba5f4291844bc25aedb27e69bc11b5bda39
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment