Challenge - 5 Problems
ERC-721 Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this ERC-721 token URI function call?
Consider the following simplified Solidity function from an ERC-721 contract. What will be the output of
tokenURI(1) if the base URI is set to "https://example.com/token/" and token 1 exists?Blockchain / Solidity
string private baseURI = "https://example.com/token/"; function tokenURI(uint256 tokenId) public view returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); return string(abi.encodePacked(baseURI, Strings.toString(tokenId))); } function _exists(uint256 tokenId) internal view returns (bool) { return tokenId == 1; }
Attempts:
2 left
💡 Hint
Think about how the base URI and token ID are combined and what the _exists function returns.
✗ Incorrect
The function checks if token 1 exists (it does), then concatenates the base URI with the token ID converted to string, resulting in "https://example.com/token/1".
🧠 Conceptual
intermediate1:30remaining
Which function is required by the ERC-721 standard to transfer ownership of a token?
In the ERC-721 standard, which function must be implemented to allow safe transfer of a token from one owner to another?
Attempts:
2 left
💡 Hint
The function should ensure the recipient can handle ERC-721 tokens safely.
✗ Incorrect
safeTransferFrom is required to safely transfer tokens and check if the recipient is a smart contract that can handle ERC-721 tokens.
🔧 Debug
advanced2:00remaining
What error does this ERC-721 mint function produce?
Given this mint function snippet, what error will occur when calling
mint(msg.sender, 0)?Blockchain / Solidity
mapping(uint256 => address) private _owners;
function mint(address to, uint256 tokenId) public {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_owners[tokenId] = to;
}
function _exists(uint256 tokenId) internal view returns (bool) {
return _owners[tokenId] != address(0);
}Attempts:
2 left
💡 Hint
Check the conditions and what _exists returns for tokenId 0 initially.
✗ Incorrect
Since _owners[0] is initially address(0), _exists(0) returns false, so the require passes and the token is minted successfully.
📝 Syntax
advanced2:00remaining
Which option correctly implements the supportsInterface function for ERC-721?
The ERC-721 standard requires implementing supportsInterface(bytes4 interfaceId). Which of the following implementations correctly returns true for the ERC-721 interface ID (0x80ac58cd) and false otherwise?
Attempts:
2 left
💡 Hint
Check which option returns true only for 0x80ac58cd and false for others.
✗ Incorrect
Option A explicitly returns true only for the ERC-721 interface ID and false otherwise, matching the requirement.
🚀 Application
expert3:00remaining
How many tokens are owned by address 0xABC after these operations?
Given the following sequence of ERC-721 operations, how many tokens does address
0xABC own at the end?
1. Mint token 1 to 0xABC
2. Mint token 2 to 0xDEF
3. Transfer token 2 from 0xDEF to 0xABC
4. Transfer token 1 from 0xABC to 0x123
5. Burn token 2
Assume all operations succeed and the burn function removes ownership.Attempts:
2 left
💡 Hint
Track ownership changes and burning carefully.
✗ Incorrect
After step 1, 0xABC owns token 1.
After step 2, 0xDEF owns token 2.
After step 3, 0xABC owns tokens 1 and 2.
After step 4, 0xABC owns token 2 only.
After step 5, token 2 is burned, so 0xABC owns no tokens.