Fomo3D automation: one call spawns a throwaway contract that buys keys and withdraws winnings in a loop, then selfdestructs back to the sender.
Historical Significance
Fomo3D's design rewarded whoever could act fastest and most often, and contracts like this are what that incentive produced: a disposable agent that compresses many rounds of play into a single transaction and leaves nothing on chain to clean up. Creating and destroying a contract inside one transaction was also, at the time, a gas refund, so the loop partly paid for itself. The five hardcoded operator addresses are the whole access-control model.
Token Information
Key Facts
Description
execute takes the game address, an affiliate code and a repeat count, and is gated on tx.origin matching one of five operator addresses burned into the code. If it matches, the contract deploys a child and forwards the entire incoming value to it.
The child is where the work happens, and it never outlives its own construction. Its constructor loops count plus one times; each pass calls buyXid on the game with the contract's balance and the affiliate code, then calls withdraw to pull back whatever the game has credited. Both are raw calls with the results ignored, so a failed round does not stop the loop. When the loop ends the child selfdestructs to the transaction origin, which returns the balance in the same transaction that created it.
Nothing is stored anywhere. The child has no functions, no owner and no lifetime; it exists only inside one transaction, which is exactly what makes the pattern cheap to repeat.
Source Verified
Byzantium Era
First Metropolis hard fork. Added zk-SNARK precompiles, REVERT opcode, and staticcall.
Bytecode Overview
Verified Source Available
This contract has verified source code.
View Verification ProofShow source code (Yul)
// Submitted by EthereumHistory (ethereumhistory.com)
//
// Automation contract for the 2018 Fomo3D round. execute takes a game address,
// an affiliate code and a repeat count, checks the transaction origin against
// five hardcoded operator addresses, and then deploys a throwaway child with
// the whole incoming value.
//
// The child's 252 byte creation code is embedded in this contract. Its
// constructor loops count plus one times, and on each pass calls buyXid,
// selector 0x8f38f309, on the game with the full balance and the affiliate
// code, then calls withdraw, selector 0x3ccfd60b, to pull back whatever the
// game paid out. When the loop ends the child selfdestructs to the transaction
// origin, returning everything it holds in the same transaction it was created.
//
// The origin checks compile to a bare chain of comparisons that each jump
// straight to the body, with no boolean left on the stack, which is not the
// shape any solc release emits for the equivalent require or if. The deployed
// bytes are therefore reproduced exactly with Yul verbatim rather than guessed
// at from a source that only nearly matches.
object "Bot" {
code {
datacopy(0, dataoffset("Bot_deployed"), datasize("Bot_deployed"))
return(0, datasize("Bot_deployed"))
}
object "Bot_deployed" {
code {
verbatim_0i_0o(hex"6080604052600436106100405763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663c52ab7788114610042575b005b61004073ffffffffffffffffffffffffffffffffffffffff6004351660243560443573aa5dd1ac6e16e5f34c88bb7b3d67938d22ebe9a932146100f05773885b09500cbc1c9cbcd0626459385f471ef72d4732146100f05773218f04bce746c068ece0b0b88f9e9dfd9dda6fdb32146100f057738d3ef8f58da859514a3627f0c677d4a2f66a205532146100f05773b5f5655e8be6039173fef87191e53c86f799f7ca32146100f057600080fd5b348383836100fc61014c565b73ffffffffffffffffffffffffffffffffffffffff9093168352602083019190915260408083019190915251908190036060019082f080158015610144573d6000803e3d6000fd5b505050505050565b60405160fc8061015c83390190560060806040526040516060806100fc83398101604090815281516020830151919092015160005b8160010181101560ef5783600160a060020a031634638f38f309908560016040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808381526020018281526020019250505060006040518083038185885af193505050505083600160a060020a0316633ccfd60b6040518163ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004016000604051808303816000875af150506001909201915060259050565b32600160a060020a0316ff00a165627a7a72305820992a9e5592b58dd24e0cd8448c6c71ff60d867a8e8ed30cec52804cbfbeff4d80029")
}
}
}