4.2. Basic exercises¶
ERC20¶
ERC20.sol contains an ERC20 implementation.
Write an invariant for ERC20 verifying that address(0)
always has zero
balance.
Run the invariant on ERC20.sol
and discover the violation in the contract.
Important
Remember to use the optimistic_loop
option, see Important: Optimistic loop.
Hints¶
English auction basic exercise¶
In EnglishAuction.sol, you will find the implementation of a simple English Auction for selling an NFT. The auction process and additional features are described in the solidity file. Here is a summary of the main details:
The seller of the NFT deploys the contract and sets the NFT and the token to be used.
A participant can bid a certain amount to become the new highest bidder.
Once the bid has ended the highest bidder gets the NFT, and the seller receives the highest bidder’s tokens.
Exercises¶
Write a spec for EnglishAuction.sol containing the following two invariants.
The
highestBid
is higher than or equal to any other bid.The bid of the
highestBidder
equals thehighestBid
. You may assume thataddress(0)
cannot place a bid.