NFT Skills 2 — Questions and Answers
Question 1: Which Solidity visibility modifier should be used for a function that must only be callable from within the same contract or derived contracts?
- public
- external
- internal (Correct answer)
- private
Correct answer: internal
The internal modifier restricts a function to the contract itself and contracts that inherit from it.
Question 2: When implementing an ERC-721 contract, which function returns the metadata URI for a specific token?
- tokenURI(uint256 tokenId) (Correct answer)
- balanceOf(address owner)
- ownerOf(uint256 tokenId)
- approve(address to, uint256 tokenId)
Correct answer: tokenURI(uint256 tokenId)
tokenURI returns a string pointing to the JSON metadata associated with a given token ID.
Question 3: What is the primary purpose of using IPFS when developing NFTs?
- To mint tokens faster
- To store metadata and assets in a decentralized, content-addressed way (Correct answer)
- To reduce gas fees during transfer
- To encrypt the smart contract code
Correct answer: To store metadata and assets in a decentralized, content-addressed way
IPFS provides decentralized, content-addressed storage so NFT assets and metadata are not tied to a single server.
Question 4: In Solidity, which keyword makes a function able to receive Ether?
- view
- pure
- payable (Correct answer)
- constant
Correct answer: payable
The payable modifier allows a function to accept Ether sent with the transaction.
Question 5: Which development framework provides a local Ethereum network, testing, and deployment scripts using JavaScript/TypeScript?
- Hardhat (Correct answer)
- MetaMask
- OpenSea
- Etherscan
Correct answer: Hardhat
Hardhat is a popular development environment for compiling, testing, and deploying Ethereum smart contracts.
Question 6: What does the OpenZeppelin library primarily provide for NFT developers?
- A blockchain explorer
- Audited, reusable smart contract implementations and standards (Correct answer)
- A crypto exchange API
- A wallet connection UI only
Correct answer: Audited, reusable smart contract implementations and standards
OpenZeppelin offers community-audited contract templates such as ERC-721 and ERC-1155 to build on safely.
Question 7: Why is it important to emit events like Transfer in an NFT contract?
- Events execute faster than functions
- Events allow off-chain applications to track on-chain state changes (Correct answer)
- Events reduce contract deployment cost
- Events are required to compile the contract
Correct answer: Events allow off-chain applications to track on-chain state changes
Events provide an indexed log that front-ends and indexers use to monitor token transfers and ownership changes.
Which Solidity visibility modifier should be used for a function that must only be callable from within the same contract or derived contracts?