Created
July 16, 2016 14:53
-
-
Save tjade273/acb0d443592287d4f2fc44955e126854 to your computer and use it in GitHub Desktop.
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
contract SplitFunds { | |
function split(address[] addrs){ | |
if(!addrs[uint(block.blockhash(block.number-1)) % addrs.length].send(msg.value)) throw; | |
} | |
} |
I'm planning on using this technique in a dapp that'll reference my fork oracle for the condition check.
EDIT: Ah, I see there's already a splitter that uses Timon Rapp's oracle. No biggie.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is awesome, thanks for publishing. I'm referencing it in my post here: http://vessenes.com/do-not-mess-with-eth-classic-it-will-f-you-up/. I think the odds of two slots getting the same funds are worse than you say, though -- I believe it's a 'birthday problem' -- when will n randomly chosen numbers be the same, given m possibilities? That makes the odds bad enough that I'd suggest the contract be instrumented to allow a re-send. I suppose you could just call it multiple times in this case.
As a side note, choosing the addresses may bear some thinking -- I recommended people use vanilla (not sequentially generated from the same private key) addresses for each 'slot'.