DevStation / LaunchKit / Templates / SoulboundNFT

SoulboundNFT

A non-transferable token. Once minted, it permanently belongs to the recipient.

Deploy This Template
SoulboundNFT.sol
solidity
1// SPDX-License-Identifier: MIT
2pragma solidity ^0.8.20;
3 
4contract SoulboundNFT {
5 string public name;
6 string public symbol;
7 address public owner;
8 uint256 public nextTokenId;
9 
10 mapping(uint256 => address) public ownerOf;
11 mapping(address => uint256) public balanceOf;
12 
13 event Mint(address indexed to, uint256 indexed tokenId);
14 
15 constructor(string memory name_, string memory symbol_) {
16 name = name_;
17 symbol = symbol_;
18 owner = msg.sender;
19 }
20 
21 function mint(address to) external returns (uint256) {
22 require(msg.sender == owner, "NOT_OWNER");
23 require(to != address(0), "ZERO_ADDR");
24 uint256 id = nextTokenId++;
25 ownerOf[id] = to;
26 balanceOf[to] += 1;
27 emit Mint(to, id);
28 return id;
29 }
30 
31 // Soulbound: tokens can never be transferred or approved once minted.
32 function transferFrom(address, address, uint256) external pure {
33 revert("SOULBOUND");
34 }
35 
36 function approve(address, uint256) external pure {
37 revert("SOULBOUND");
38 }
39}
DevStation
Loading console…