Book a free call

NFT Smart Contract: What It Is and How It Works

An NFT smart contract is the code that creates, owns and moves a non-fungible token. Learn how it works, what standards it uses, and what to check before you buy.

Hertiv engineering teamReviewed by a senior engineer
6 min read
NFT Smart Contract: What It Is and How It Works
On this page

Short answer

An NFT smart contract is a program on a blockchain that creates a unique token, records who owns it, and runs the rules for moving it, such as transfers, royalties and access. Unlike a fungible token, each NFT has its own ID, so the contract can tell one token apart from every other token in the same collection.

What is an NFT smart contract?

An NFT smart contract is a program stored on a blockchain that creates and manages non-fungible tokens. It defines what the token is, who owns it, and what happens when it changes hands. The contract, not a company database, is the record of ownership.

When an artist or a studio mints an NFT, the contract writes a new entry with a unique token ID and links it to the owner's wallet address. Anyone can read that entry on a block explorer, which is why ownership of an NFT is public and hard to fake.

The contract also holds the rules. It can say who may mint new tokens, whether a token can be transferred, what royalty the creator earns on a resale, and whether the token opens a door, such as entry to an event or a game item. If you are new to the tokens themselves, what an NFT is explains the basics before the code.

How does an NFT smart contract work?

An NFT smart contract works by running small functions whenever someone interacts with it. A mint function creates a token, a transfer function moves it to a new owner, and a burn function destroys it. Each function changes the contract's stored state, and the blockchain records that change.

A typical mint follows a fixed sequence:

  1. A buyer sends payment to the contract, or the creator calls the mint function directly.
  2. The contract checks the rules: is the sale open, is the buyer allowed, is the supply left?
  3. The contract creates a token with the next free ID and assigns it to the buyer's wallet.
  4. The token's metadata link, usually a picture and its traits, is stored or pointed to.
  5. The transfer is written to the chain, and the token appears in the buyer's wallet.

Most NFT artwork and metadata live off the chain, on storage such as IPFS or a server, while the contract holds a link to them. That split matters: if the link breaks or the server goes down, the token still exists but its picture can vanish. Serious buyers check where the metadata lives before paying.

What are the main NFT smart contract standards?

The main NFT smart contract standards are ERC-721 and ERC-1155 on Ethereum-compatible chains, with similar standards on other chains. ERC-721 gives each token its own contract entry, while ERC-1155 can hold many token types in one contract.

Standard Best for How it stores tokens Typical gas cost
ERC-721 One-off art and collectibles One contract entry per token Higher per mint
ERC-1155 Game items and editions Many token types in one contract Lower per batch mint
ERC-721A Large mint batches One entry per batch, optimised Lower per batch mint
SPL tokens Solana NFTs Token accounts per holder Very low

The choice shapes cost and behaviour. A 10,000-piece collection minted one by one on ERC-721 costs far more in network fees than the same collection minted in batches on ERC-721A or ERC-1155. For a closer look at where these tokens trade, see the guide to the best NFT marketplaces for startups.

What does an NFT smart contract do for creators?

For creators, an NFT smart contract automates the parts of selling art that used to need a gallery or a platform: it proves the work is theirs, pays them on resale, and controls who can mint more.

The most useful features for creators are:

  • Provenance. The mint transaction names the creator's wallet, so the origin of the work is on the public record.
  • Royalties. The contract can send a share of each resale to the creator, usually between 2.5% and 10% of the sale price.
  • Supply control. The contract fixes the total number of tokens, so no one can quietly print more.
  • Access. Holding the token can open a chat, a game item or a ticket, because other software can read the contract.

Royalties have one catch: they are a request, not a rule the chain enforces. Marketplaces choose whether to pay them, and some now pay nothing. Creators who count on royalty income should check which marketplaces honour them before choosing where to list. The reasons NFT artists choose Solana include low fees, which matter when royalties are small.

How do you read an NFT smart contract before you buy?

You read an NFT smart contract before you buy by checking five things on a block explorer: who deployed it, whether it is verified, what the mint rules say, where the metadata lives, and whether the owner can change the rules later.

Start with verification. A verified contract shows its source code on the explorer, so anyone can read it. An unverified contract hides its code, which is a reason to pause. Next, look for owner-only functions: if the deployer can pause transfers, change the metadata link or mint unlimited tokens, the buyer is trusting that person, not the code.

Also check the metadata link. If it points to a plain web server run by the seller, the image can change or disappear. If it points to IPFS or to data stored on the chain, it is harder to alter. An audit of a smart contract covers the same checks in more depth and is worth reading before a large purchase.

Example: a 1,000-piece NFT collection

Example (hypothetical): a digital artist plans a collection of 1,000 pieces priced at 0.08 ETH each. If every piece sells, the primary sale brings in 1,000 x 0.08 = 80 ETH. The artist sets a 7.5% royalty in the contract.

In the first year, 200 pieces resell at an average of 0.2 ETH each. Total resale volume is 200 x 0.2 = 40 ETH, and the royalty is 40 x 0.075 = 3 ETH paid to the artist across those sales. The marketplace also takes its own fee, so the artist's royalty is separate from what the platform keeps.

The numbers show why supply and royalty rate matter more than the headline price. Cutting the collection to 500 pieces at the same price halves primary revenue to 40 ETH, while raising the royalty to 10% would lift the same resale volume to 4 ETH. Both choices belong in the contract before the first mint, because changing them later needs a new contract.

What are the common mistakes?

The most common NFT smart contract mistakes are trusting unverified contracts, assuming royalties are guaranteed, ignoring where metadata lives, and minting on the wrong standard for the collection size.

  • Buying from an unverified contract. If the code is hidden, you cannot check what it does.
  • Counting on royalties. Marketplaces may not pay them, so treat royalty income as uncertain.
  • Ignoring metadata storage. A token whose image sits on a seller's server can lose its picture.
  • Picking the wrong standard. Minting 10,000 tokens one by one on ERC-721 wastes fees that batch standards avoid.
  • Skipping the owner check. A deployer who can mint more tokens or change the metadata holds real power over the collection.

Key takeaways

  • An NFT smart contract is the code that creates, owns and moves a token
  • ERC-721 suits one-off pieces; ERC-1155 and ERC-721A suit batches and game items
  • Royalties are a marketplace choice, not a rule the chain enforces
  • Check verification, owner powers and metadata storage before buying
  • Supply, royalty rate and standard belong in the contract before the first mint

Frequently asked questions

What is the difference between an NFT and its smart contract?

The NFT is the token itself, a unique entry with an ID and an owner. The smart contract is the program that creates the token, records ownership and runs the rules for transfers and royalties. You own the token; the contract is the code that manages it.

Do I need to write code to mint an NFT?

No. Marketplaces and no-code tools deploy a standard contract for you and handle the mint. Writing your own contract gives you control over supply, royalties and access rules, but it also means you are responsible for bugs in the code.

What is ERC-721?

ERC-721 is the Ethereum standard for non-fungible tokens. It gives each token a unique ID inside a contract, so one token can be told apart from every other token in the same collection. Most one-off art NFTs use ERC-721 or its batch variant ERC-721A.

Can an NFT smart contract be changed after deployment?

Usually not. A deployed contract is fixed, unless it was built with an upgrade pattern that lets an owner swap its code. That is why buyers check for owner powers before buying, and why creators should settle supply and royalties before minting.

How do NFT royalties work?

The contract records a royalty rate, and a marketplace that honours it sends that share to the creator on each resale. The chain itself does not force the payment, so a marketplace can choose to pay nothing. Royalty income is therefore uncertain and varies by marketplace.

Is an NFT smart contract safe?

A standard, audited contract from a known template is generally safe to use, but a custom contract can hide bugs or owner powers. Check that the code is verified, read the owner functions, and prefer contracts that have been audited before you put money in.

Found this useful? Share it.
Hertiv engineering team

Written from projects we build for clients: blockchain systems in production. Every post is reviewed by a senior engineer before publishing and updated when practice changes.

About HertivHow we work

Planning an NFT collection and need the contract built right?

A senior engineer replies within one business day. Or see our Smart Contract Development service.

Book a free call

Keep reading

All posts

Tell us what you want to build

A senior engineer reads every request and replies within one business day with questions, a rough range, or a call link.

  • NDA on request before any details
  • You own all code, models and IP
  • US, UK and EU time-zone overlap

Your email app should open with your message ready to send. If it does not, write to [email protected].

Prefer email? Write to [email protected]
Estimate costBook a call