Decentraland: How Reddit Got In on the ICO

in ico •  7 years ago  (edited)

If you are a regular on /r/ethtrader, you probably have heard about buying contracts. If not, then you probably are wondering who the heck is sending a massive amount of eth in the first block, for a reasonable gas price.

/u/cintex has been posting smart contracts with open source which enable ethtraders to pool their money together and have it sent all at once. The ability to get in at the first block doesn't really have much to do with "smart" code either but rather financial incentives.

Check out the code here: code

In particular, look at this function:

function claim_bounty(){
// Short circuit to save gas if the contract has already bought tokens.
if (bought_tokens) return;
// Short circuit to save gas if the earliest buy time hasn't been reached.
if (block.number < earliest_buy_block) return;
// Short circuit to save gas if kill switch is active.
if (kill_switch) return;
// Record that the contract has bought the tokens.
bought_tokens = true;
// Record the time the contract bought the tokens.
time_bought = now;
// Store the claimed bounty in a temporary variable.
uint256 claimed_bounty = bounty;
// Update bounty prior to sending to prevent recursive call.
bounty = 0;
// Record the amount of ETH sent as the contract's current value.
contract_eth_value = this.balance - claimed_bounty;
// Transfer all the funds (less the bounty) to the crowdsale address
// to buy tokens. Throws if the crowdsale hasn't started yet or has
// already completed, preventing loss of funds.
if(!sale.call.value(contract_eth_value)()) throw;
// Send the caller their bounty for buying tokens for the contract.
msg.sender.transfer(claimed_bounty);
}

This function is called by users in order to attempt to send the entire pot to the crowd sale. The transaction pops off to the mempool and then is processed by a miner. If the miner is sticking it in the appropriate block number then it allows the transaction to finish rather than return with a bad jump. Lastly, it gives the person who got us into the crowdsale with 1 eth.

This 1 eth is important, as it is the carrot which dangles in front of the masses to keep sending that function to the mempool. And if enough get sent, 100 may come back with bad jumps but at least 1 will probably get into the first block.

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!