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_, address initialOwner_) {
16 require(initialOwner_ != address(0), "ZERO_OWNER");
17 name = name_;
18 symbol = symbol_;
19 owner = initialOwner_;
20 }
21 
22 function mint(address to) external returns (uint256) {
23 require(msg.sender == owner, "NOT_OWNER");
24 require(to != address(0), "ZERO_ADDR");
25 uint256 id = nextTokenId++;
26 ownerOf[id] = to;
27 balanceOf[to] += 1;
28 emit Mint(to, id);
29 return id;
30 }
31 
32 // Soulbound: tokens can never be transferred or approved once minted.
33 function transferFrom(address, address, uint256) external pure {
34 revert("SOULBOUND");
35 }
36 
37 function approve(address, uint256) external pure {
38 revert("SOULBOUND");
39 }
40}
DevStation
Loading console…