46 lines
1.3 KiB
Solidity
46 lines
1.3 KiB
Solidity
// SPDX-License-Identifier: MIT
|
|
pragma solidity 0.8.10;
|
|
|
|
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
|
|
import "@openzeppelin/contracts/access/Ownable.sol";
|
|
import "@openzeppelin/contracts/utils/Counters.sol";
|
|
|
|
contract Soulbound is ERC721Enumerable, Ownable {
|
|
using Counters for Counters.Counter;
|
|
string private _baseTokenURI = "https://market.cebg.games/api/nft/info/";
|
|
uint256 public immutable supplyLimit;
|
|
|
|
Counters.Counter private _tokenIdCounter;
|
|
|
|
constructor(
|
|
string memory _name,
|
|
string memory _symbol,
|
|
uint256 _supplyLimt
|
|
) ERC721(_name, _symbol) {
|
|
supplyLimit = _supplyLimt;
|
|
}
|
|
|
|
function _beforeTokenTransfer(
|
|
address from,
|
|
address to,
|
|
uint256 tokenId
|
|
) internal override(ERC721Enumerable) {
|
|
require(from == address(0), "Token not transferable");
|
|
super._beforeTokenTransfer(from, to, tokenId);
|
|
}
|
|
|
|
function mint() public {
|
|
if (supplyLimit > 0) {
|
|
require((totalSupply() + 1) <= supplyLimit, "Exceed the total supply");
|
|
}
|
|
address to = msg.sender;
|
|
uint256 tokenId = _tokenIdCounter.current();
|
|
_tokenIdCounter.increment();
|
|
_safeMint(to, tokenId);
|
|
}
|
|
|
|
function _baseURI() internal view virtual override returns (string memory) {
|
|
return _baseTokenURI;
|
|
}
|
|
}
|