Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare the token URI variable.
Blockchain / Solidity
string private [1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using tokenId as the URI variable name
Using metadata which is too generic
Using tokenURI which is usually a function, not a variable
✗ Incorrect
The token URI is usually stored in a variable named uri or similar. Here, uri is the private string holding the metadata URI.
2fill in blank
mediumComplete the function signature to return the token URI.
Blockchain / Solidity
function [1](uint256 tokenId) public view returns (string memory) { Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using getTokenURI which is not standard
Using uri which is usually a variable
Using metadataURI which is uncommon
✗ Incorrect
The standard function to get a token's metadata URI in ERC721 is tokenURI.
3fill in blank
hardFix the error in the return statement to correctly return the token URI.
Blockchain / Solidity
return [1][tokenId];
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Returning tokenURI which is a function
Returning tokenId which is a number, not a URI
Returning metadata which is undefined
✗ Incorrect
The URI is stored in a mapping or variable named uri, so we return uri[tokenId].
4fill in blank
hardFill both blanks to declare and initialize the mapping for token URIs.
Blockchain / Solidity
mapping(uint256 => [1]) private [2];
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using uint256 as the value type
Using tokenURI as the mapping name
Using uint256 as the value type instead of string
✗ Incorrect
The mapping stores a string URI for each token ID. The mapping name is uri.
5fill in blank
hardFill all three blanks to set the token URI in the function.
Blockchain / Solidity
function setTokenURI(uint256 tokenId, [1] memory [2]) public { [3][tokenId] = [2]; }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using tokenURI as parameter name
Using uint256 as parameter type
Using different names for parameter and mapping
✗ Incorrect
The function takes a string memory uri parameter and sets uri[tokenId] to that value.