Skip to content

Instantly share code, notes, and snippets.

@D-Nice
Last active January 11, 2020 00:54
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 D-Nice/0e08f6390499922496bc9b96cb9cd2e9 to your computer and use it in GitHub Desktop.
Save D-Nice/0e08f6390499922496bc9b96cb9cd2e9 to your computer and use it in GitHub Desktop.
contract ForkSplitterConduit {
//Tracks whether hard fork is effective on this chain. True means the fork is passed, false it hasn't.
bool forked = false;
//Identifies on which network fork this contract should do transfers. True transfers only on a hard-fork network, and false on the original network.
bool transferOnlyFork;
//Hard-fork DAO withdrawal contract
address constant C = 0xbf4ed7b27f1d666546e30d74d50d173d20bca754;
//In Constructor you set whether you want this contract to operate on hard fork or non-hard fork network
// Set to true for transfers to only complete on hard fork, and false for non-hard fork
function ForkSplitterConduit (bool _transferOnlyFork) {
transferOnlyFork = _transferOnlyFork;
}
//Needs to be called as close as possible to block 1920000, can use an alarm service to call this
function checkFork() returns (bool) {
if (msg.value != 0)
throw;
//Checks whether it is after the block that the hard-fork is supposed to take place, which is block 1920000
//Gives someone ~12 days days to call this, which checks whether the balance in the hard fork withdraw contract
//is above a certain threshhold (9m in this case) which indicates that the hard-fork is live.
if (block.number >= 1920000 && block.number <= 2000000 && C.balance >= 9000000 ether)
forked = true;
return forked;
}
//Transfers are only possible after the hard fork is supposed to take effect.
function transfer(address _recipient) returns (bool) {
if (transferOnlyFork != forked && block.number < 1920000)
throw;
if(!_recipient.send(msg.value))
throw;
return true;
}
function() {
throw;
}
}
@D-Nice
Copy link
Author

D-Nice commented Jan 6, 2020

The precursor to the AmIOnTheFork contract, which has had billions in value pass through it so far,,,

https://medium.com/@timonrapp/how-to-deal-with-the-ethereum-replay-attack-3fd44074a6d8 kudos given here, albeit just mentioning that I wrote a similar contract, when what was published was based off my code. A bit of a CSW moment there with the exact same comments 🙄 and what was unorthodox at the time, of throwing for the fallback function, which was considered an antipattern by many at the time, but eventually becoming the default behaviour by the compiler 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment