November 2018
Intermediate to advanced
528 pages
13h 21m
English
The only remaining part of our contract is the functionality to end the sale. We previously stated that our sale will be a fixed-price, fixed-period sale. In this sale, the owner will be able to end the sale at any time. In the real world, this would not be ideal, and would be a red flag to any potential investors. The code is defined as follows:
function endSale() public { require(msg.sender == owner); require(tokenContract.transfer(owner, tokenContract.balanceOf(this))); msg.sender.transfer(address(this).balance);}The endSale() function first transfers all remaining tokens from the address of our ERC-20 contract to the address of the contract owner. It then transfers the ether held by the sale contract to the same address. ...
Read now
Unlock full access