In this assignment you will learn to program smart contracts in Solidity.
In this assignment you will learn..
In this assignment you will write a smart contract, in Solidity, for an NFT auction. The auction will be for the course NFT you minted in HW0.
Install Hardhat and create a project:
Overview of Hardhat and instructions here: https://hardhat.org/hardhat-runner/docs/getting-started#overview
Once you’re done, you should have a placeholder Lock
project with the following directory structure:
Replace the Lock
placeholder files with our HW1
files:
Auction.txt
is the test file. Place it in the test directory then run mv Auction.txt Auction.js
(Notion doesn’t allow us to upload js files)
Write your NFT auction!
The auction’s sequence of events might be as follows:
There will be two roles in this auction:
When your auction contract is deployed, it is neither open nor closed. It is in an idle state. When the auction begins, it is active. When it ends, it is closed.
Open the template code and follow the instructions to implement each function.
Run npx hardhat test
to test your Auction.
Auction
Payout Winner
The winner's balance should go to 0:
Error: Transaction reverted: function call to a non-contract account
This error is coming from a test of our payoutWinner
function. This function, which we’ve implemented, transfers the HW0 NFT to the winner.
function payoutWinner() public /* MODIFIER(S) */ {
fundsPerBidder[highestBidder] = 0;
nft.enterAddressIntoBook("auction");
nft.mintNFT();
nft.transferFrom(address(this), highestBidder, 2);
}