"Soulbound" Tokens (SBTs) are a special type of NFT that cannot be transferred once they are minted to a wallet. They are permanently bound to that specific address.
This concept was popularized by Vitalik Buterin to represent "identity" and "reputation" on-chain rather than just financial assets.
Here is a comprehensive breakdown of how they work, use cases, and a production-ready code implementation.
What makes an NFT "Soulbound"? Standard NFTs (ERC-721) allow you to call functions like transferFrom or safeTransferFrom to move the token to another person. To make an NFT "Soulbound," you must override these transfer functions in the smart contract to simply say: "No."
However, you usually still want to allow two specific actions:
Minting: Creating the token (moving from 0x00... to User).
Burning: Destroying the token (moving from User to 0x00...) — useful if a user wants to remove a bad reputation or if a certificate is revoked.
Soulbound Smart Contract (OpenZeppelin v5) This is a robust implementation. It blocks transfers between users but allows the Admin to mint (issue) and the User to burn (destroy) their own token.
Key Code Breakdown _update Override: This is the most critical part. In older OpenZeppelin versions, we used _beforeTokenTransfer. In version 5.0+, we override _update.
The if Statement:
from != address(0): The token currently exists.
to != address(0): The token is not being destroyed.
If both are true, it means User A is trying to send to User B. We revert (cancel) the transaction.
ERC721Burnable: We include this because sometimes a user wants to get rid of an SBT (e.g., they don't want a specific badge on their profile anymore). This allows them to send it to the "graveyard" (address 0), which our logic permits.