How to create a non-transferable NFT or Soulbound NFT. (2024)

A Souldbound or non-transferable NFTs are a special type of digital asset that can’t be freely bought, sold, or traded like most other NFTs. Instead, these tokens come with strict rules that limit who can own them and prevent them from changing hands.

A great example of usage would the Buildspace’s NFT collection where they incentivise NFTs to people who registered and finished their series of tutorials/challenges online about blockchain and use it as a badge in the community. GTFOL!

I assume you are aware on how to write, deploy and are already familiar with smart contracts so lets head on to it.

First of, we’ll choose ERC-721 as our standard for the Soulbound NFT collection and create a basic NFT smart contract.

// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract SoulboundNFT is ERC721, Ownable {

constructor() ERC721("SoulboundNFT", "SBNFT") {}

function mint(address to, uint256 tokenId) external onlyOwner {
_mint(to, tokenId);
}
}

Now that we have our smart contract which has a simple mint function we can now add in our secret ingredient to make the NFTs not transferable

 function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId,
uint256 batchSize
) internal override virtual {

// Custom logic here, e.g., checking special conditions
require(from == address(0), "Err: token transfer is BLOCKED");
super._beforeTokenTransfer(from, to, tokenId, batchSize);
}

The _beforeTokenTransfer function is a hook provided by the OpenZeppelin library for ERC-20 and ERC-721 tokens. It allows you to add custom logic that will be executed before a token transfer occurs. This hook is often used to implement additional checks or actions before tokens are moved from one address to another.

// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract SoulboundNFT is ERC721, Ownable {

constructor() ERC721("SoulboundNFT", "SBNFT") {}

function mint(address to, uint256 tokenId) external onlyOwner {
_mint(to, tokenId);
}

function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId,
uint256 batchSize
) internal override virtual {
require(from == address(0), "Err: token transfer is BLOCKED");
super._beforeTokenTransfer(from, to, tokenId, batchSize);
}
}

The final smart contract should look like this.

In summary, non-transferable NFTs enforce their non-transferable nature through smart contract code that overrides standard transfer functions. Any attempt to transfer the NFT results in a failed transaction, ensuring that the token remains with its current owner.

How to create a non-transferable NFT or Soulbound NFT. (2024)
Top Articles
4 Things to Know About Scandinavian Values
What It Feels Like to Be Shot by a Rubber Bullet
Cpmc Mission Bernal Campus & Orthopedic Institute Photos
Spn 1816 Fmi 9
Brady Hughes Justified
O'reilly's Auto Parts Closest To My Location
Doublelist Paducah Ky
Whiskeytown Camera
Qhc Learning
Detroit Lions 50 50
Socket Exception Dunkin
Identogo Brunswick Ga
6001 Canadian Ct Orlando Fl
Hood County Buy Sell And Trade
Learn2Serve Tabc Answers
Uktulut Pier Ritual Site
How Much Is Tay Ks Bail
Decosmo Industrial Auctions
Cincinnati Adult Search
Teen Vogue Video Series
R. Kelly Net Worth 2024: The King Of R&B's Rise And Fall
Magic Seaweed Daytona
Ecampus Scps Login
The Procurement Acronyms And Abbreviations That You Need To Know Short Forms Used In Procurement
897 W Valley Blvd
Our Leadership
Allegheny Clinic Primary Care North
Mark Ronchetti Daughters
R/Orangetheory
Best New England Boarding Schools
Mumu Player Pokemon Go
NIST Special Publication (SP) 800-37 Rev. 2 (Withdrawn), Risk Management Framework for Information Systems and Organizations: A System Life Cycle Approach for Security and Privacy
How to Draw a Bubble Letter M in 5 Easy Steps
Skroch Funeral Home
Rogers Centre is getting a $300M reno. Here's what the Blue Jays ballpark will look like | CBC News
Dr. John Mathews Jr., MD – Fairfax, VA | Internal Medicine on Doximity
Emerge Ortho Kronos
Koninklijk Theater Tuschinski
Myanswers Com Abc Resources
Craigslist Tulsa Ok Farm And Garden
Cranston Sewer Tax
Infinite Campus Parent Portal Hall County
968 woorden beginnen met kruis
Bcy Testing Solution Columbia Sc
2023 Fantasy Football Draft Guide: Rankings, cheat sheets and analysis
Birmingham City Schools Clever Login
Gt500 Forums
Samsung 9C8
Egg Inc Wiki
Acuity Eye Group - La Quinta Photos
Compete My Workforce
Primary Care in Nashville & Southern KY | Tristar Medical Group
Latest Posts
Article information

Author: Nathanial Hackett

Last Updated:

Views: 5883

Rating: 4.1 / 5 (52 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Nathanial Hackett

Birthday: 1997-10-09

Address: Apt. 935 264 Abshire Canyon, South Nerissachester, NM 01800

Phone: +9752624861224

Job: Forward Technology Assistant

Hobby: Listening to music, Shopping, Vacation, Baton twirling, Flower arranging, Blacksmithing, Do it yourself

Introduction: My name is Nathanial Hackett, I am a lovely, curious, smiling, lively, thoughtful, courageous, lively person who loves writing and wants to share my knowledge and understanding with you.