0
0
Blockchain / Solidityprogramming~10 mins

ERC-721 NFT standard in Blockchain / Solidity - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - ERC-721 NFT standard
Start: Deploy ERC-721 Contract
Mint NFT Token
Assign Token ID to Owner
Check Ownership & Metadata
Transfer Token to Another Owner
Update Ownership Records
Query Token Info or Owner
End
This flow shows how an ERC-721 contract is deployed, NFTs are minted and assigned unique IDs, ownership is tracked, tokens can be transferred, and metadata can be queried.
Execution Sample
Blockchain / Solidity
contract SimpleNFT is ERC721 {
    uint256 public nextTokenId;
    constructor() ERC721("SimpleNFT", "SNFT") {}
    function mint() external {
        _safeMint(msg.sender, nextTokenId);
        nextTokenId++;
    }
}
This contract lets users mint unique NFTs with increasing token IDs assigned to their address.
Execution Table
StepActionToken IDOwnernextTokenIdOutput
1Deploy contract--0Contract ready
2User calls mint()0UserAddress0Mint token 0 to UserAddress
3Increment nextTokenId--1nextTokenId updated to 1
4User calls mint() again1UserAddress1Mint token 1 to UserAddress
5Increment nextTokenId--2nextTokenId updated to 2
6Transfer token 0 to AnotherAddress0AnotherAddress2Ownership of token 0 updated
7Query owner of token 11UserAddress2Returns UserAddress
8Query owner of token 00AnotherAddress2Returns AnotherAddress
9No more actions--2End of execution
💡 No more mint or transfer calls, execution ends.
Variable Tracker
VariableStartAfter Step 2After Step 3After Step 4After Step 5After Step 6Final
nextTokenId0112222
Owner of token 0NoneUserAddressUserAddressUserAddressUserAddressAnotherAddressAnotherAddress
Owner of token 1NoneNoneNoneUserAddressUserAddressUserAddressUserAddress
Key Moments - 3 Insights
Why does nextTokenId increment after minting?
Because each NFT must have a unique token ID, nextTokenId increments after minting to prepare the next unique ID (see steps 2 and 3 in execution_table).
What happens to ownership when a token is transferred?
Ownership changes from the current owner to the new owner, updating the record (see step 6 in execution_table where token 0 ownership changes).
Can two tokens have the same ID?
No, ERC-721 requires unique token IDs. The contract ensures this by incrementing nextTokenId after each mint (see variable_tracker for nextTokenId).
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table at step 4, who owns token 1?
AAnotherAddress
BUserAddress
CNo owner yet
DContract itself
💡 Hint
Check the 'Owner' column at step 4 in the execution_table.
At which step does nextTokenId become 2?
AStep 5
BStep 6
CStep 3
DStep 2
💡 Hint
Look at the 'nextTokenId' column in execution_table and variable_tracker.
If the transfer in step 6 did not happen, who would own token 0 at the end?
AAnotherAddress
BNo owner
CUserAddress
DContract owner
💡 Hint
Refer to the ownership changes in variable_tracker and execution_table steps 6 and 8.
Concept Snapshot
ERC-721 is a standard for unique NFTs.
Each token has a unique ID.
Tokens are minted to owners with _safeMint.
Ownership can be transferred.
Metadata and ownership can be queried.
nextTokenId tracks new token IDs.
Full Transcript
This visual execution traces the ERC-721 NFT standard contract. It starts with deploying the contract, then minting tokens with unique IDs assigned to the caller's address. After each mint, the nextTokenId increments to ensure uniqueness. Ownership of tokens is tracked and can be transferred to others. Queries return the current owner of each token. The execution table shows each step's action, token ID, owner, and nextTokenId value. Variable tracking highlights how ownership and nextTokenId change over time. Key moments clarify why IDs increment and how ownership updates. The quiz tests understanding of ownership and token ID changes during execution.