πŸ–ΌοΈ Tronsell Wiki

TRC721 NFT Standard β€” TRON NFT Development Guide

Complete guide to the TRC721 NFT standard on TRON. Learn about NFT development, metadata, marketplace integration, and how to build TRC721 NFTs.

πŸ–ΌοΈ TRC721 at a Glance
Standard TypeNon-Fungible Token (NFT)
Based OnERC721 (Ethereum)
ImplementationSmart Contract (Solidity)
Key FeatureUnique tokenId per NFT
MetadataOff-chain (URI)
WalletsTronLink, Trust Wallet, etc.

πŸ–ΌοΈWhat is TRC721?

TRC721 is the NFT (Non-Fungible Token) standard on the TRON blockchain. It defines a set of rules and functions that all TRC721-compliant NFTs must implement to ensure compatibility with wallets, marketplaces, and decentralized applications.

TRC721 is similar to Ethereum's ERC721 standard β€” both define interfaces for non-fungible tokens. However, TRC721 is optimized for TRON's architecture and uses the TRON Virtual Machine (TVM) for execution.

πŸ’‘ What Makes NFTs "Non-Fungible"?

Unlike TRC20 tokens (like USDT), where every token is identical and interchangeable, TRC721 tokens are unique. Each NFT has a distinct tokenId and can have individual properties, metadata, and ownership history.

βš–οΈTRC721 vs TRC20

Feature TRC721 (NFT) TRC20 (Token)
Fungibility Non-fungible (unique) Fungible (interchangeable)
Token Identity Each token has unique ID All tokens identical
Metadata Per-token (URI) Global (name, symbol, decimals)
Transfer Function transferFrom() with tokenId transfer() with amount
Balance balanceOf() = number of NFTs owned balanceOf() = token amount
Use Cases Art, collectibles, gaming, real estate Currency, utility tokens, stablecoins
πŸ’‘ Key Difference

TRC20 tokens are like currency β€” every dollar is the same. TRC721 NFTs are like collectibles β€” each baseball card is unique and has different value.

πŸ“‹TRC721 Technical Specification

A TRC721 contract must implement the following functions:

Function Description Return Type
balanceOf(address) Returns the number of NFTs owned by an address uint256
ownerOf(uint256 tokenId) Returns the owner of a specific NFT address
transferFrom(address from, address to, uint256 tokenId) Transfers an NFT from one address to another void
safeTransferFrom(address from, address to, uint256 tokenId) Safe transfer with recipient check void
approve(address to, uint256 tokenId) Grants permission to transfer a specific NFT void
setApprovalForAll(address operator, bool approved) Grants/revokes permission for all NFTs void
getApproved(uint256 tokenId) Returns the approved address for an NFT address
isApprovedForAll(address owner, address operator) Checks if an operator is approved for all NFTs bool
πŸ“ Optional Extensions

TRC721 also supports optional extensions like TRC721Metadata (name(), symbol(), tokenURI()) and TRC721Enumerable (for enumeration of NFTs).

πŸ“TRC721 Metadata

Each TRC721 NFT can have associated metadata β€” information that describes the NFT. The metadata is typically stored off-chain and referenced by a URI.

  • tokenURI(tokenId): Returns the URI where the NFT's metadata is stored
  • Metadata structure: Usually a JSON object with fields like name, description, image, attributes, etc.
  • Storage options: IPFS (decentralized), Arweave (permanent), centralized servers, or on-chain
  • Best practice: Use IPFS for decentralized, censorship-resistant storage
// Example TRC721 Metadata JSON
{
  "name": "TRON Art #001",
  "description": "A unique digital artwork on TRON",
  "image": "ipfs://QmX...",
  "attributes": [
    { "trait_type": "Background", "value": "Blue" },
    { "trait_type": "Rarity", "value": "Legendary" }
  ]
}
πŸ’‘ Metadata Storage

IPFS is the most popular choice for NFT metadata because it's decentralized and content-addressed. Once uploaded, the content is permanent and can't be changed. Some projects also use Arweave for permanent storage.

πŸ“TRC721 Contract Example

Here's a minimal TRC721 contract using OpenZeppelin's implementation:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/utils/Counters.sol";

contract MyTRC721 is ERC721 {
  using Counters for Counters.Counter;
  Counters.Counter private _tokenIdCounter;

  constructor() ERC721("MyNFT", "MNFT") {}

  function mint(address to, string memory uri) public {
    uint256 tokenId = _tokenIdCounter.current();
    _tokenIdCounter.increment();
    _safeMint(to, tokenId);
    _setTokenURI(tokenId, uri);
  }
}
πŸ’‘ OpenZeppelin Implementation

OpenZeppelin's ERC721 implementation is the most widely used and tested. It includes all required functions, security features, and optional extensions. Use it as a base for your NFT projects.

πŸ“±Wallets Supporting TRC721 NFTs

Most major TRON wallets support TRC721 NFTs:

πŸ”΄
TronLink

Dedicated NFT gallery. Supports viewing, sending, and receiving TRC721 NFTs. Browser extension and mobile app.

πŸ”΅
Trust Wallet

NFT tab displays TRC721 collectibles. Supports sending and receiving NFTs. Mobile app only.

🟠
SafePal

Hardware wallet with NFT gallery. Supports TRC721 NFTs with cold storage security.

🟣
TokenPocket

Supports TRC721 NFTs with gallery view and transfer capabilities. Mobile and desktop versions.

πŸ’‘ Viewing NFTs

If your NFT doesn't appear in your wallet, it may be a display issue. Check TronScan to confirm ownership, and try adding the contract address manually if needed.

πŸͺTRC721 Marketplace Integration

TRC721 NFTs can be traded on NFT marketplaces. Here's what you need to know:

  • Approvals: To sell an NFT, you must approve the marketplace contract using approve() or setApprovalForAll()
  • Listing: Marketplaces create a listing that tracks the NFT and its price
  • Sale: When a buyer purchases, the marketplace executes a transfer
  • Royalties: TRC721 supports royalties via the royaltyInfo() extension (EIP-2981)
  • Popular marketplaces: APENFT, TronNFT, and other TRON-based NFT platforms
πŸ’‘ Royalties

TRC721 supports EIP-2981 for royalties. Creators can set a royalty percentage that is automatically paid to them on secondary sales. This is implemented in the royaltyInfo() function.

πŸ›‘οΈSecurity Best Practices

  • Audit your contract: Always have your NFT contract audited by a professional security firm.
  • Use OpenZeppelin: Use battle-tested implementations from OpenZeppelin to avoid common vulnerabilities.
  • Reentrancy protection: Use nonReentrant modifiers for functions that transfer NFTs.
  • Ownership controls: Implement access control (Ownable) for minting and administrative functions.
  • Metadata immutability: Consider whether metadata should be immutable or upgradeable. Upgradeable adds flexibility but increases risk.
  • Test thoroughly: Test on Shasta testnet before mainnet deployment.
⚠️ Common Vulnerabilities

Common issues include reentrancy attacks, front-running, unchecked external calls, and logic errors in ownership transfer. Always follow security best practices and use established patterns.

❓Frequently Asked Questions

What is TRC721?

TRC721 is the NFT (Non-Fungible Token) standard on the TRON blockchain. It defines a set of functions that all TRC721 tokens must implement to ensure compatibility with wallets, marketplaces, and dApps. It's similar to Ethereum's ERC721 standard.

What is the difference between TRC20 and TRC721?

TRC20 is for fungible tokens (identical and interchangeable, like USDT). TRC721 is for non-fungible tokens (unique and non-interchangeable, like digital art or collectibles). Each TRC721 token has a unique tokenId and can have individual metadata.

How does TRC721 metadata work?

TRC721 uses a metadata system where each token has a unique tokenId that maps to metadata (name, description, image URL, attributes, etc.). The metadata is typically stored off-chain (IPFS, Arweave, or a centralized server) with the URI stored on-chain in the tokenURI() function.

Which wallets support TRC721 NFTs?

Most major TRON wallets support TRC721 NFTs, including TronLink (browser extension and mobile), Trust Wallet, TokenPocket, and SafePal. These wallets display NFTs in a dedicated gallery section and support sending and receiving NFTs.

How do I create a TRC721 NFT?

You create a TRC721 NFT by writing a smart contract that implements the TRC721 standard (using OpenZeppelin's ERC721 is recommended), deploying it to the TRON network, and calling the mint function to create new NFTs with unique tokenIds and metadata URIs.

⚑ Build with Tronsell Energy

Integrate Tronsell Energy into your NFT marketplace for zero-fee USDT transfers. Simple API, instant delivery.