November 2018
Intermediate to advanced
528 pages
13h 21m
English
After the auction ends, you'll need to enable bidders to get their ether back. For security reasons, it's better to adopt a withdrawal pattern —this helps us to avoid security issues that could cause funds to be lost:
function withdraw() public returns (bool){ require(now > auction_end , "can't withdraw, Auction is still open"); uint amount = bids[msg.sender]; bids[msg.sender] = 0; msg.sender.transfer(amount); WithdrawalEvent(msg.sender, amount); return true;}
There is nothing new here except, as you might have noticed, the use of a new function, transfer(). Along with another function, send(), both methods enable the contract to send funds to a designated address (msg.sender). In this case, the contract sends the corresponding ...
Read now
Unlock full access