PhotoDatastruct is defined to store various photo data.
_photoListtakes a uint256
tokenIdto map a specific
PhotoDatastruct. By defining PhotoUploaded event, transaction receipt will log this event whenever function containing this is called.
transferOwnership. Check out Klaystagram.sol to see the whole set of functions.
uploadPhotofunction takes 4 arguments including photo's image source. To keep things simple,
tokenIdwill start from 1 and will increase by 1.
_mintfunction is from ERC721 contract. It creates a new token and assign it to a specific address, which in this case,
msg.sender. In this application, logged in user will create transaction with their own private key. So
msg.senderwill be the user's public address.
PhotoDatastruct, locate it inside
_photoListmapping, and push the owner address into
ownerHistoryarray. And don't forget to emit the event we just created. As mentioned above, this event will be included in transaction receipt.
transferOwnershipfunction. When transferring photo ownership, we need to do two things. First, we have to reassign the owner, and then we have to push new owner address into
safeTransferFromfunction from ERC721 standard, which eventually calls
transferFromfunction. As mentioned above, right after token transfer is successfully done, we have to push new owner information into
ownerHistoryarray, and that is exactly why
transferFromis overridden as below.
getPhotofunction takes an index(token id) as an argument and returns every element in PhotoData struct.