Are the smart contracts used to manage NFTs stateless or stateful?

Ethereum as a protocol seems to be stateful, but the smart contracts for NFT marketplaces seem to be stateless.

They don't save any data between executions of the smart contract, which is my current (and possibly mistaken) understanding of what makes a smart contract stateful.


You are correct in thinking what is stateful and what is not. A contract is stateless if it doesn't do any state changes, such as changing storage variable values.

But NFT contracts aren't stateless. They don't store much, but they store enough. Most importantly, they store information about the token owners in a mapping. Furthermore, they contain other helper data (such as who owns a token ID) and may store various metadata about tokens.


I think there's a distinction to be made.

As Lauri Peltonen pointed out ERC-721 contracts usually store ownership info in a mapping (tokenId -> ownerAddress), so they surely have state.

But you specifically mention NFT marketplace contracts. Those are used to auction and facilitate exchanges between parties. To achieve this goal they may have to store info about bids, offers, sales, escrow services and interact with the NFT contracts to enforce transfers after a deal is made, so in most cases they are stateful too.

  • Thanks for adding the context around marketplaces, if you don't mind I have a follow up question. Like you mentioned, NFT marketplace contracts have lots of stuff built in. But there's plenty of things we can't put in the contracts yet - most notably, the actual art. Why don't marketplaces limit NFT smart contracts to the bare minimum of who owns what tokens, and handle all the other logic in their off-chain front end? – tjr226 Apr 7 at 14:18
  • 1
    1. Because most of the time the NFT smart contract creator and the marketplace stuff are from different entities. The marketplace wraps around existing contracts. 2. As much stuff as possibile is built on-chain, but not all. This is a matter of architecture. Every marketplace has different choices. Part of the process can/will be off-chain (like most metadata as you noticed); this is especially true where blockchain storage is scarce/expensive. – Diego Ferri Apr 7 at 21:04
  • 1
    Thanks for explaining. I was first exposed to SuperRare, and it seems like they control both the smart contract and the front end. But today I learned about OpenSea, and that was my first exposure to something where the marketplace and contract are separate orgs. – tjr226 Apr 7 at 21:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.