Exercise - Create your own NFT!
HaikuNFT
. Add the following to the contract:
struct
called Haiku
to store the address
of the author
and line1
, line2
, and line3
haikus
mapping
to relate sharedHaikus
from the address
of the wallet shared with, to the id of the Haiku NFT sharedcounter
to use as the id and to track and share the total number of Haikus minted
external
function called mintHaiku
that takes in the three lines of the poem. This function should mint an NFT for the minter and save their Haiku.
Haikus must be unique! If any line in the Haiku has been used as any line of a previous Haiku, revert with HaikuNotUnique()
.
You don’t have to count syllables, but it would be neat if you did! (No promises on whether or not we counted the same as you did)
public
function called shareHaiku
that allows the owner of a Haiku NFT to share that Haiku with the designated address
they are sending it _to
. Doing so should add it to that address’s entry in sharedHaikus
.
If the sender isn’t the owner of the Haiku, instead revert with an error of NotYourHaiku
. Include the id of the Haiku in the error.
public
function called getMySharedHaikus
. When called, it should return an array containing all of the haikus shared with the caller.
If there are no haikus shared with the caller’s wallet, it should revert with a custom error of NoHaikusShared
, with no arguments.