编译器
0.8.23+commit.f704f362
文件 1 的 29:Base64.sol
pragma solidity ^0.8.20;
library Base64 {
string internal constant _TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
function encode(bytes memory data) internal pure returns (string memory) {
if (data.length == 0) return "";
string memory table = _TABLE;
string memory result = new string(4 * ((data.length + 2) / 3));
assembly {
let tablePtr := add(table, 1)
let resultPtr := add(result, 32)
for {
let dataPtr := data
let endPtr := add(data, mload(data))
} lt(dataPtr, endPtr) {
} {
dataPtr := add(dataPtr, 3)
let input := mload(dataPtr)
mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F))))
resultPtr := add(resultPtr, 1)
mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F))))
resultPtr := add(resultPtr, 1)
mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F))))
resultPtr := add(resultPtr, 1)
mstore8(resultPtr, mload(add(tablePtr, and(input, 0x3F))))
resultPtr := add(resultPtr, 1)
}
switch mod(mload(data), 3)
case 1 {
mstore8(sub(resultPtr, 1), 0x3d)
mstore8(sub(resultPtr, 2), 0x3d)
}
case 2 {
mstore8(sub(resultPtr, 1), 0x3d)
}
}
return result;
}
}
文件 2 的 29:Boolean.sol
pragma solidity 0.8.23;
library Boolean {
uint8 public constant TRUE = 2;
uint8 public constant FALSE = 1;
}
文件 3 的 29:Configuration.sol
pragma solidity 0.8.23;
import { IERC20 } from "@openzeppelin/contracts/interfaces/IERC20.sol";
import { IVestMembership } from "src/IVestMembership.sol";
import { IVestMembershipDescriptor } from "src/VestMembershipDescriptor.sol";
library Presale {
struct Fees {
uint16 tokenANumerator;
uint16 tokenADenominator;
uint16 tokenBNumerator;
uint16 tokenBDenominator;
}
struct Configuration {
Fees fees;
IERC20 tokenA;
IERC20 tokenB;
address manager;
address beneficiary;
uint256 tgeTimestamp;
uint256 listingTimestamp;
uint256 claimbackPeriod;
}
}
library Membership {
struct Fees {
uint16 numerator;
uint16 denominator;
}
struct Configuration {
Fees fees;
IVestMembership.Metadata metadata;
IVestMembershipDescriptor descriptor;
}
}
文件 4 的 29:Context.sol
pragma solidity ^0.8.20;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
文件 5 的 29:DynamicIds.sol
pragma solidity 0.8.23;
library DynamicIds {
function createPublicId(uint256 id, bytes memory payload) internal pure returns (uint256) {
return uint256(bytes32(abi.encodePacked(getFirst16Bytes(id), getFirst16Bytes(keccak256(payload)))));
}
function createMintId(bytes memory mintPreimage) internal pure returns (uint256) {
return uint256(zeroLast16Bytes(keccak256(mintPreimage)));
}
function getFirst16Bytes(uint256 value) internal pure returns (bytes16) {
return getFirst16Bytes(bytes32(value));
}
function getFirst16Bytes(bytes32 value) internal pure returns (bytes16) {
return bytes16(value);
}
function getLast16Bytes(uint256 value) internal pure returns (bytes16) {
return getLast16Bytes(bytes32(value));
}
function getLast16Bytes(bytes32 value) internal pure returns (bytes16) {
return bytes16(value << 128);
}
function zeroLast16Bytes(uint256 value) internal pure returns (uint256) {
return uint256(zeroLast16Bytes(bytes32(value)));
}
function zeroLast16Bytes(bytes32 value) internal pure returns (bytes32) {
return value >> 128 << 128;
}
}
文件 6 的 29:ERC165.sol
pragma solidity ^0.8.20;
import {IERC165} from "./IERC165.sol";
abstract contract ERC165 is IERC165 {
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
文件 7 的 29:ERC721.sol
pragma solidity ^0.8.20;
import {IERC721} from "./IERC721.sol";
import {IERC721Receiver} from "./IERC721Receiver.sol";
import {IERC721Metadata} from "./extensions/IERC721Metadata.sol";
import {Context} from "../../utils/Context.sol";
import {Strings} from "../../utils/Strings.sol";
import {IERC165, ERC165} from "../../utils/introspection/ERC165.sol";
import {IERC721Errors} from "../../interfaces/draft-IERC6093.sol";
abstract contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Errors {
using Strings for uint256;
string private _name;
string private _symbol;
mapping(uint256 tokenId => address) private _owners;
mapping(address owner => uint256) private _balances;
mapping(uint256 tokenId => address) private _tokenApprovals;
mapping(address owner => mapping(address operator => bool)) private _operatorApprovals;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
function balanceOf(address owner) public view virtual returns (uint256) {
if (owner == address(0)) {
revert ERC721InvalidOwner(address(0));
}
return _balances[owner];
}
function ownerOf(uint256 tokenId) public view virtual returns (address) {
return _requireOwned(tokenId);
}
function name() public view virtual returns (string memory) {
return _name;
}
function symbol() public view virtual returns (string memory) {
return _symbol;
}
function tokenURI(uint256 tokenId) public view virtual returns (string memory) {
_requireOwned(tokenId);
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string.concat(baseURI, tokenId.toString()) : "";
}
function _baseURI() internal view virtual returns (string memory) {
return "";
}
function approve(address to, uint256 tokenId) public virtual {
_approve(to, tokenId, _msgSender());
}
function getApproved(uint256 tokenId) public view virtual returns (address) {
_requireOwned(tokenId);
return _getApproved(tokenId);
}
function setApprovalForAll(address operator, bool approved) public virtual {
_setApprovalForAll(_msgSender(), operator, approved);
}
function isApprovedForAll(address owner, address operator) public view virtual returns (bool) {
return _operatorApprovals[owner][operator];
}
function transferFrom(address from, address to, uint256 tokenId) public virtual {
if (to == address(0)) {
revert ERC721InvalidReceiver(address(0));
}
address previousOwner = _update(to, tokenId, _msgSender());
if (previousOwner != from) {
revert ERC721IncorrectOwner(from, tokenId, previousOwner);
}
}
function safeTransferFrom(address from, address to, uint256 tokenId) public {
safeTransferFrom(from, to, tokenId, "");
}
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public virtual {
transferFrom(from, to, tokenId);
_checkOnERC721Received(from, to, tokenId, data);
}
function _ownerOf(uint256 tokenId) internal view virtual returns (address) {
return _owners[tokenId];
}
function _getApproved(uint256 tokenId) internal view virtual returns (address) {
return _tokenApprovals[tokenId];
}
function _isAuthorized(address owner, address spender, uint256 tokenId) internal view virtual returns (bool) {
return
spender != address(0) &&
(owner == spender || isApprovedForAll(owner, spender) || _getApproved(tokenId) == spender);
}
function _checkAuthorized(address owner, address spender, uint256 tokenId) internal view virtual {
if (!_isAuthorized(owner, spender, tokenId)) {
if (owner == address(0)) {
revert ERC721NonexistentToken(tokenId);
} else {
revert ERC721InsufficientApproval(spender, tokenId);
}
}
}
function _increaseBalance(address account, uint128 value) internal virtual {
unchecked {
_balances[account] += value;
}
}
function _update(address to, uint256 tokenId, address auth) internal virtual returns (address) {
address from = _ownerOf(tokenId);
if (auth != address(0)) {
_checkAuthorized(from, auth, tokenId);
}
if (from != address(0)) {
_approve(address(0), tokenId, address(0), false);
unchecked {
_balances[from] -= 1;
}
}
if (to != address(0)) {
unchecked {
_balances[to] += 1;
}
}
_owners[tokenId] = to;
return from;
}
function _mint(address to, uint256 tokenId) internal {
if (to == address(0)) {
revert ERC721InvalidReceiver(address(0));
}
address previousOwner = _update(to, tokenId, address(0));
if (previousOwner != address(0)) {
revert ERC721InvalidSender(address(0));
}
}
function _safeMint(address to, uint256 tokenId) internal {
_safeMint(to, tokenId, "");
}
function _safeMint(address to, uint256 tokenId, bytes memory data) internal virtual {
_mint(to, tokenId);
_checkOnERC721Received(address(0), to, tokenId, data);
}
function _burn(uint256 tokenId) internal {
address previousOwner = _update(address(0), tokenId, address(0));
if (previousOwner == address(0)) {
revert ERC721NonexistentToken(tokenId);
}
}
function _transfer(address from, address to, uint256 tokenId) internal {
if (to == address(0)) {
revert ERC721InvalidReceiver(address(0));
}
address previousOwner = _update(to, tokenId, address(0));
if (previousOwner == address(0)) {
revert ERC721NonexistentToken(tokenId);
} else if (previousOwner != from) {
revert ERC721IncorrectOwner(from, tokenId, previousOwner);
}
}
function _safeTransfer(address from, address to, uint256 tokenId) internal {
_safeTransfer(from, to, tokenId, "");
}
function _safeTransfer(address from, address to, uint256 tokenId, bytes memory data) internal virtual {
_transfer(from, to, tokenId);
_checkOnERC721Received(from, to, tokenId, data);
}
function _approve(address to, uint256 tokenId, address auth) internal {
_approve(to, tokenId, auth, true);
}
function _approve(address to, uint256 tokenId, address auth, bool emitEvent) internal virtual {
if (emitEvent || auth != address(0)) {
address owner = _requireOwned(tokenId);
if (auth != address(0) && owner != auth && !isApprovedForAll(owner, auth)) {
revert ERC721InvalidApprover(auth);
}
}
_tokenApprovals[tokenId] = to;
}
function _setApprovalForAll(address owner, address operator, bool approved) internal virtual {
if (operator == address(0)) {
revert ERC721InvalidOperator(operator);
}
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
function _requireOwned(uint256 tokenId) internal view returns (address) {
address owner = _ownerOf(tokenId);
if (owner == address(0)) {
revert ERC721NonexistentToken(tokenId);
}
return owner;
}
function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory data) internal {
if (to.code.length > 0) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {
if (retval != IERC721Receiver.onERC721Received.selector) {
revert ERC721InvalidReceiver(to);
}
} catch (bytes memory reason) {
if (reason.length == 0) {
revert ERC721InvalidReceiver(to);
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
}
}
}
文件 8 的 29:ERC721DynamicIds.sol
pragma solidity 0.8.23;
import { ERC721 } from "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import { IERC721 } from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import { ERC721Enumerable } from "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import { DynamicIds } from "src/libraries/DynamicIds.sol";
abstract contract ERC721DynamicIds is ERC721Enumerable {
event DynamicIdNFTMinted(uint256 indexed mintId, address indexed owner, bytes data);
event DynamicIdNFTUpdated(uint256 indexed mintId, uint256 indexed newPublicId, bytes payload);
error InvalidMintId(uint256 mintId);
function _mintDynamicIdNFT(address to, uint256 mintId, bytes memory data) internal returns (uint256) {
bytes memory payload = _getPayload(mintId);
uint256 publicId = DynamicIds.createPublicId(mintId, payload);
_safeMint(to, publicId, data);
emit DynamicIdNFTMinted(mintId, to, data);
emit DynamicIdNFTUpdated(mintId, publicId, payload);
return publicId;
}
function _requireValidPublicId(uint256 publicId) internal view returns (uint256 mintId) {
mintId = DynamicIds.zeroLast16Bytes(publicId);
bytes16 publicIdLast16Bytes = DynamicIds.getLast16Bytes(publicId);
if (DynamicIds.getFirst16Bytes(keccak256(_getPayload(mintId))) != publicIdLast16Bytes) {
revert ERC721NonexistentToken(publicId);
}
}
function _updatePublicId(uint256 prevPublicId, uint256 mintId) internal returns (uint256 newId) {
bytes memory payload = _getPayload(mintId);
newId = _getPublicId(mintId, payload);
address owner = _ownerOf(mintId);
_checkOnERC721Received(address(0), owner, newId, "");
emit IERC721.Transfer(owner, address(0), prevPublicId);
emit IERC721.Transfer(address(0), owner, newId);
emit DynamicIdNFTUpdated(mintId, newId, payload);
}
function _getPayload(uint256 mintId) internal view virtual returns (bytes memory payload);
function _getPublicId(uint256 mintId, bytes memory payload) private pure returns (uint256 publicId) {
return DynamicIds.createPublicId(mintId, payload);
}
function ownerOf(uint256 publicId) public view override(ERC721, IERC721) returns (address) {
uint256 mintId = _requireValidPublicId(publicId);
return super.ownerOf(mintId);
}
function tokenURI(uint256 publicId) public view virtual override returns (string memory) {
uint256 mintId = _requireValidPublicId(publicId);
return super.tokenURI(mintId);
}
function approve(address to, uint256 publicId) public override(ERC721, IERC721) {
uint256 mintId = _requireValidPublicId(publicId);
super.approve(to, mintId);
emit IERC721.Approval(_msgSender(), to, publicId);
}
function getApproved(uint256 publicId) public view override(ERC721, IERC721) returns (address) {
uint256 mintId = _requireValidPublicId(publicId);
return super.getApproved(mintId);
}
function transferFrom(address from, address to, uint256 publicId) public virtual override(ERC721, IERC721) {
uint256 mintId = _requireValidPublicId(publicId);
super.transferFrom(from, to, mintId);
emit IERC721.Transfer(from, to, publicId);
}
function safeTransferFrom(address from, address to, uint256 publicId, bytes memory data)
public
override(ERC721, IERC721)
{
transferFrom(from, to, publicId);
_checkOnERC721Received(from, to, publicId, data);
}
function _safeMint(address to, uint256 publicId, bytes memory data) internal override {
if (DynamicIds.getLast16Bytes(publicId) == 0) revert InvalidMintId(publicId);
uint256 mintId = _requireValidPublicId(publicId);
super._safeMint(to, mintId, data);
emit IERC721.Transfer(address(0), to, publicId);
}
function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) {
uint256 mintId = super.tokenOfOwnerByIndex(owner, index);
return _getPublicId(mintId, _getPayload(mintId));
}
function tokenByIndex(uint256 index) public view override returns (uint256) {
uint256 mintId = super.tokenByIndex(index);
return _getPublicId(mintId, _getPayload(mintId));
}
}
文件 9 的 29:ERC721Enumerable.sol
pragma solidity ^0.8.20;
import {ERC721} from "../ERC721.sol";
import {IERC721Enumerable} from "./IERC721Enumerable.sol";
import {IERC165} from "../../../utils/introspection/ERC165.sol";
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
mapping(address owner => mapping(uint256 index => uint256)) private _ownedTokens;
mapping(uint256 tokenId => uint256) private _ownedTokensIndex;
uint256[] private _allTokens;
mapping(uint256 tokenId => uint256) private _allTokensIndex;
error ERC721OutOfBoundsIndex(address owner, uint256 index);
error ERC721EnumerableForbiddenBatchMint();
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {
return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId);
}
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual returns (uint256) {
if (index >= balanceOf(owner)) {
revert ERC721OutOfBoundsIndex(owner, index);
}
return _ownedTokens[owner][index];
}
function totalSupply() public view virtual returns (uint256) {
return _allTokens.length;
}
function tokenByIndex(uint256 index) public view virtual returns (uint256) {
if (index >= totalSupply()) {
revert ERC721OutOfBoundsIndex(address(0), index);
}
return _allTokens[index];
}
function _update(address to, uint256 tokenId, address auth) internal virtual override returns (address) {
address previousOwner = super._update(to, tokenId, auth);
if (previousOwner == address(0)) {
_addTokenToAllTokensEnumeration(tokenId);
} else if (previousOwner != to) {
_removeTokenFromOwnerEnumeration(previousOwner, tokenId);
}
if (to == address(0)) {
_removeTokenFromAllTokensEnumeration(tokenId);
} else if (previousOwner != to) {
_addTokenToOwnerEnumeration(to, tokenId);
}
return previousOwner;
}
function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
uint256 length = balanceOf(to) - 1;
_ownedTokens[to][length] = tokenId;
_ownedTokensIndex[tokenId] = length;
}
function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
_allTokensIndex[tokenId] = _allTokens.length;
_allTokens.push(tokenId);
}
function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {
uint256 lastTokenIndex = balanceOf(from);
uint256 tokenIndex = _ownedTokensIndex[tokenId];
if (tokenIndex != lastTokenIndex) {
uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];
_ownedTokens[from][tokenIndex] = lastTokenId;
_ownedTokensIndex[lastTokenId] = tokenIndex;
}
delete _ownedTokensIndex[tokenId];
delete _ownedTokens[from][lastTokenIndex];
}
function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
uint256 lastTokenIndex = _allTokens.length - 1;
uint256 tokenIndex = _allTokensIndex[tokenId];
uint256 lastTokenId = _allTokens[lastTokenIndex];
_allTokens[tokenIndex] = lastTokenId;
_allTokensIndex[lastTokenId] = tokenIndex;
delete _allTokensIndex[tokenId];
_allTokens.pop();
}
function _increaseBalance(address account, uint128 amount) internal virtual override {
if (amount > 0) {
revert ERC721EnumerableForbiddenBatchMint();
}
super._increaseBalance(account, amount);
}
}
文件 10 的 29:Errors.sol
pragma solidity 0.8.23;
library Errors {
error Forbidden();
error UnacceptableValue();
error UnacceptableReference();
error Unauthorized(address account);
error AccountMismatch(address account);
error DenominatorZero();
}
文件 11 的 29:IERC165.sol
pragma solidity ^0.8.20;
interface IERC165 {
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
文件 12 的 29:IERC20.sol
pragma solidity ^0.8.20;
import {IERC20} from "../token/ERC20/IERC20.sol";
文件 13 的 29:IERC20Metadata.sol
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
interface IERC20Metadata is IERC20 {
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
}
文件 14 的 29:IERC2981.sol
pragma solidity ^0.8.20;
import {IERC165} from "../utils/introspection/IERC165.sol";
interface IERC2981 is IERC165 {
function royaltyInfo(
uint256 tokenId,
uint256 salePrice
) external view returns (address receiver, uint256 royaltyAmount);
}
文件 15 的 29:IERC721.sol
pragma solidity ^0.8.20;
import {IERC165} from "../../utils/introspection/IERC165.sol";
interface IERC721 is IERC165 {
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
function balanceOf(address owner) external view returns (uint256 balance);
function ownerOf(uint256 tokenId) external view returns (address owner);
function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;
function safeTransferFrom(address from, address to, uint256 tokenId) external;
function transferFrom(address from, address to, uint256 tokenId) external;
function approve(address to, uint256 tokenId) external;
function setApprovalForAll(address operator, bool approved) external;
function getApproved(uint256 tokenId) external view returns (address operator);
function isApprovedForAll(address owner, address operator) external view returns (bool);
}
文件 16 的 29:IERC721Enumerable.sol
pragma solidity ^0.8.20;
import {IERC721} from "../IERC721.sol";
interface IERC721Enumerable is IERC721 {
function totalSupply() external view returns (uint256);
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);
function tokenByIndex(uint256 index) external view returns (uint256);
}
文件 17 的 29:IERC721Metadata.sol
pragma solidity ^0.8.20;
import {IERC721} from "../IERC721.sol";
interface IERC721Metadata is IERC721 {
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function tokenURI(uint256 tokenId) external view returns (string memory);
}
文件 18 的 29:IERC721Receiver.sol
pragma solidity ^0.8.20;
interface IERC721Receiver {
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
文件 19 的 29:IVestFeeCollectorProvider.sol
pragma solidity 0.8.23;
interface IVestFeeCollectorProvider {
function getFeeCollector() external view returns (address);
}
文件 20 的 29:IVestMembership.sol
pragma solidity 0.8.23;
import { IERC721 } from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import { IERC2981 } from "@openzeppelin/contracts/interfaces/IERC2981.sol";
import { IERC721Enumerable } from "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol";
interface IVestMembership is IERC2981, IERC721, IERC721Enumerable {
struct Usage {
uint256 max;
uint256 current;
}
struct Metadata {
address token;
string color;
string description;
}
struct Attributes {
uint256 price;
uint256 allocation;
uint256 claimbackPeriod;
uint32 tgeNumerator;
uint32 tgeDenominator;
uint32 cliffDuration;
uint32 cliffNumerator;
uint32 cliffDenominator;
uint32 vestingPeriodCount;
uint32 vestingPeriodDuration;
uint8 tradeable;
}
function mint(address owner_, uint256 roundId, uint256 currentUsage, uint256 maxUsage, Attributes memory attributes)
external
returns (uint256);
function extend(uint256 publicId, uint256 amount) external returns (uint256 newId);
function reduce(uint256 publicId, uint256 amount) external returns (uint256 newId);
function consume(uint256 publicId, uint256 amount) external returns (uint256 newId);
function getStartTimestamp() external view returns (uint256);
function getUsage(uint256 publicId) external view returns (Usage memory);
function getRoundId(uint256 publicId) external view returns (uint256);
function getAttributes(uint256 publicId) external view returns (Attributes memory);
function unlocked(uint256 publicId) external view returns (uint256);
}
文件 21 的 29:IVestPresaleScheduler.sol
pragma solidity 0.8.23;
interface IVestPresaleScheduler {
function getTgeTimestamp() external view returns (uint256);
function getListingTimestamp() external view returns (uint256);
}
文件 22 的 29:Math.sol
pragma solidity ^0.8.20;
library Math {
error MathOverflowedMulDiv();
enum Rounding {
Floor,
Ceil,
Trunc,
Expand
}
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
function average(uint256 a, uint256 b) internal pure returns (uint256) {
return (a & b) + (a ^ b) / 2;
}
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
if (b == 0) {
return a / b;
}
return a == 0 ? 0 : (a - 1) / b + 1;
}
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
uint256 prod0 = x * y;
uint256 prod1;
assembly {
let mm := mulmod(x, y, not(0))
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
if (prod1 == 0) {
return prod0 / denominator;
}
if (denominator <= prod1) {
revert MathOverflowedMulDiv();
}
uint256 remainder;
assembly {
remainder := mulmod(x, y, denominator)
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
uint256 twos = denominator & (0 - denominator);
assembly {
denominator := div(denominator, twos)
prod0 := div(prod0, twos)
twos := add(div(sub(0, twos), twos), 1)
}
prod0 |= prod1 * twos;
uint256 inverse = (3 * denominator) ^ 2;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
result = prod0 * inverse;
return result;
}
}
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 result = 1 << (log2(a) >> 1);
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);
}
}
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);
}
}
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);
}
}
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);
}
}
function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
return uint8(rounding) % 2 == 1;
}
}
文件 23 的 29:MembershipSVG.sol
pragma solidity 0.8.23;
import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";
library MembershipSVG {
using Strings for uint256;
struct Params {
string color;
string title;
uint256 max;
uint256 current;
}
string internal constant ELEMENT_OPENING =
'<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 1500 1500" style="enable-background:new 0 0 1500 1500;" xml:space="preserve">';
string internal constant ELEMENT_CLOSING = "</svg>";
string internal constant BACKGROUND =
'<rect fill="#1c242c" width="1500" height="1500"/><path fill="#20262F" d="M479.2,371.4h-51.6v31.2l-31.2-31.2h-31.5l62.7,62.7v547.2L217.1,771v-51.2l203.3,203.3v-31.5l-182-182v-51.2l182,182V809L49.2,437.8v31.6l94.6,94.6v51.2l-94.6-94.6v31.5l94.6,94.6v51.2l-57.7-57.7v31.5l57.7,57.7v51.3L49.2,686v31.5l94.6,94.6v51.2l-94.6-94.6v31.5l323,323.1H321L49.2,851.4v31.5l94.6,94.6v51.2l94.6,94.7v31.5l-94.6-94.6v51.2l-94.6-94.6v31.5l234.4,234.4h31.5l-25.5-25.5h133.9l3.9,3.9l21.7,21.7h31.5l-41.3-41.3l25.6-25.6l66.9,66.9h31.3l-82.6-82.6l25.6-25.6L614.4,1283h31.5l-124-124V776.9l122.8,122.8l66.4-66.4V603.6L479.2,371.4z M282.6,950.8l144.9,144.9v27.5h-23.7L282.6,1002V950.8L282.6,950.8zM427.6,1013.1v51.2L238.4,875v-51.2L427.6,1013.1z M522,611.4l65.5,65.5v51.2L522,662.5V611.4z M552.2,558.8l131,130.8v51.2L552.2,610V558.8z M522,445.9l94.6,94.6v51.2L522,497.1V445.9z M232.6,1282.9L49.2,1099.5v31.5l94.6,94.6l57.3,57.3H232.6zM529.2,1114.7l168,168h14v-17.5l-182-182V1114.7z M711.2,1131.4v-31.5l-182-182v31.5L711.2,1131.4z M659,1161.8v-31.5l-129.7-129.7v31.5L659,1161.8z M529.2,866.6l182,182v-31.5l-182-182V866.6z M65.5,371.4H49.2v15.2l371.2,371.2v-31.6L65.5,371.4z M118.3,1282.9l31.6,0.1L49.2,1182.3v31.5L118.3,1282.9L118.3,1282.9z M711.2,469.7v-31.5l-66.8-66.8H613L711.2,469.7L711.2,469.7z M616.6,426.3l-55-55h-31.5l86.4,86.4l94.6,94.6v-31.5L616.6,426.3z M711.2,371.4h-15.6l15.6,15.6V371.4z M230.9,371.4h-31.5l220.9,220.9v-31.5L230.9,371.4z M313.6,371.4h-31.5l138.3,138.2v-31.5L313.6,371.4z M233.8,488.4L420.4,675v-31.5L265.3,488.4H233.8z"/>';
string internal constant LOGO =
'<circle style="fill:none;stroke-miterlimit:10;" cx="415.6" cy="856.3" r="69.4"/><path style="fill:none;stroke-miterlimit:10;" d="M374,607.5c77.6-12.9,160.1,10.6,220,70.5c37.6,37.6,60.9,84.2,69.8,132.8l-39.1,4.8l-117.6,14.3c-4.3-15-12.4-29.1-24.1-40.9c-20.2-20.2-47.2-29.4-73.6-27.7l-26.5-115.4L374,607.5z"/><path style="fill:none;stroke-miterlimit:10;" d="M265,705.7c25.5-25.5,55.9-43.2,88.1-53.1l26.6,115.4c-11.4,4.6-22.1,11.6-31.4,20.9c-9.3,9.3-16.3,20.1-20.9,31.6l-115.5-26.3C221.7,761.8,239.4,731.3,265,705.7z"/><path style="fill:none;stroke-miterlimit:10;" d="M482.9,923.6c17.6-17.6,26.9-40.5,27.8-63.6l117.6-14.3c2.8,58-17.9,116.9-62.1,161.1c-47.5,47.5-112,67.9-174,61.1l21.4-116.5C438.7,952,463.9,942.7,482.9,923.6z"/><path style="fill:none;stroke-miterlimit:10;" d="M166.7,815.1l38.4,8.8l115.5,26.4c-1.7,26.3,7.6,53.3,27.7,73.4c10.3,10.3,22.5,17.8,35.4,22.4l-21.4,116.5l-7.1,38.7c-43.2-10.6-84.2-32.8-117.9-66.6C177.5,974.9,154,892.6,166.7,815.1z"/><line style="fill:none;stroke-miterlimit:10;" x1="644.9" y1="813.1" x2="660.9" y2="797.1"/><line style="fill:none;stroke-miterlimit:10;" x1="612.1" y1="817.1" x2="654.4" y2="774.8"/><line style="fill:none;stroke-miterlimit:10;" x1="579.3" y1="821" x2="646.3" y2="754.1"/><line style="fill:none;stroke-miterlimit:10;" x1="546.5" y1="825" x2="636.7" y2="734.8"/><line style="fill:none;stroke-miterlimit:10;" x1="513.7" y1="829" x2="625.9" y2="716.8"/><line style="fill:none;stroke-miterlimit:10;" x1="500.6" y1="813.3" x2="613.7" y2="700.1"/><line style="fill:none;stroke-miterlimit:10;" x1="489.2" y1="795.9" x2="600.4" y2="684.6"/><line style="fill:none;stroke-miterlimit:10;" x1="474.6" y1="781.6" x2="586" y2="670.3"/><line style="fill:none;stroke-miterlimit:10;" x1="456.9" y1="770.5" x2="570.4" y2="657.1"/><line style="fill:none;stroke-miterlimit:10;" x1="435.4" y1="763.2" x2="553.5" y2="645.1"/><line style="fill:none;stroke-miterlimit:10;" x1="409.2" y1="760.5" x2="535.5" y2="634.3"/><line style="fill:none;stroke-miterlimit:10;" x1="403.8" y1="737.1" x2="516.1" y2="624.9"/><line style="fill:none;stroke-miterlimit:10;" x1="398.4" y1="713.7" x2="495.2" y2="616.9"/><line style="fill:none;stroke-miterlimit:10;" x1="393.1" y1="690.2" x2="472.7" y2="610.6"/><line style="fill:none;stroke-miterlimit:10;" x1="387.7" y1="666.8" x2="448.3" y2="606.2"/><line style="fill:none;stroke-miterlimit:10;" x1="382.3" y1="643.4" x2="421.5" y2="604.1"/><line style="fill:none;stroke-miterlimit:10;" x1="376.9" y1="619.9" x2="391.6" y2="605.2"/>';
string internal constant DECORATORS =
'<path style="fill:none;stroke:#383838;stroke-width:2;stroke-miterlimit:10;stroke-dasharray:4.0182,10.0455;" d="M799.2,1357c-13.1-21.2-20.8-47.4-20.8-75.6c0-20.8,4.2-40.4,11.6-57.8"/><polygon style="fill:#FFFFFF;" points="92.9,78.2 72.6,97.5 72.6,139.5 81.4,148.2 135.1,148.2 144.8,158 144.8,254.2 138.5,247.8 138.5,173.8 133,179.3 133,246.1 133,261.5 212.7,341.3 267.8,341.3 338,411.7 262.6,411.7 297.7,446.8 278.9,446.8 233.2,401.1 196.1,401.1 62.8,267.8 62.8,211.9 73.4,201.5 115.6,201.5 102,187.9 63.4,187.9 63.4,94.3 81,78.2 "/><polyline style="fill:none;stroke:#FFFFFF;stroke-miterlimit:10;" points="280.3,446.3 716.9,446.3 755.4,407.8 973.2,407.8 "/><circle style="fill:none;stroke:#FFFFFF;stroke-miterlimit:10;" cx="978" cy="407.8" r="4.8"/><circle style="fill:none;stroke:#FFFFFF;stroke-miterlimit:10;" cx="674.8" cy="65.7" r="4.8"/><polyline style="fill:none;stroke:#FFFFFF;stroke-miterlimit:10;" points="69.8,100.3 105.2,66.4 280.3,66.4 305.4,91.5 649,91.5 671.6,69 "/><path style="fill:#FFFFFF;" d="M1408.7,290.1L1209.4,90.8l-28.5-0.2L1380.3,290h28.4L1408.7,290.1L1408.7,290.1z M1387.1,299.7h-12.2l-186.8-186.8h-34.7L1110.5,70h-17.7l32.9,32.9h-70.5l65.7,66h51.5l74.7,74.7V258l135.1,135.1h55.5l13.6-13.6V364L1387.1,299.7z"/>';
function generate(Params memory params) internal pure returns (string memory) {
uint256 percentage = params.max > 0 ? params.current * 100 / params.max : 0;
uint256 progress = 10000 - (percentage * 100);
return string.concat(
ELEMENT_OPENING,
BACKGROUND,
cards(params.color, 100 - percentage),
elements(params.color, progress),
DECORATORS,
labels(params.title, params.max, params.current),
ELEMENT_CLOSING
);
}
function cards(string memory color, uint256 percentage) internal pure returns (string memory) {
return string.concat(
string.concat('<g fill="', color, '">'),
'<path d="M1343.7,522.3v-10.9l-24.9-24.9h-13.6l-3.3,3.1h-195.7l-18.6,18.6h-12.8l-3.5,3.1h-87.6l-2.9-2.9h-35.9l-2.9,2.9H829l-3.1-3.1h-9.1l-24.2,24.2v11.2l3,3v64.3l-3.1-2.5v4.9l3.1,2.6v6.4l-3.1-2.5v4.9l3.1,2.6v6.4l-3.1-2.5v4.9l3.1,2.6v61l-3.1-5.6V715l24.3,24.3h24.9l-3.3-3.1h175.8l-3.1,3.1h11.1l22.5,22.5h6.5l-3.3-3.1h248.4l9.8-9.8h4.4l13.1-13.1v-78.6l20.2-20.2v-23.9l-3.1-3.3v-84L1343.7,522.3z M1295.2,756.3H1047l-22.5-22.5H819.2l-21-21v-178l21-21h270.7l21.7-21.7h204.7l21.6,21.6v121.1l-20.2,20.2v78.6L1295.2,756.3z"/>',
'<path d="M1343.7,848.9V838l-24.9-24.9h-13.6l-3.3,3.1h-195.7l-18.6,18.6h-12.8l-3.5,3.1h-87.6l-2.9-2.9h-35.9l-2.9,2.9H829l-3.1-3.1h-9.1L792.6,859v11.2l3,3v64.3l-3.1-2.5v4.9l3.1,2.6v6.4l-3.1-2.5v4.9l3.1,2.6v6.4l-3.1-2.5v4.9l3.1,2.6v61l-3.1-5.6v20.9l24.3,24.3h24.9l-3.3-3.1h175.8l-3.1,3.1h11.1l22.5,22.5h6.5l-3.3-3.1h248.4l9.8-9.8h4.4l13.1-13.1v-78.6l20.2-20.2v-23.9l-3.1-3.3v-84L1343.7,848.9z M1295.2,1082.9H1047l-22.5-22.5H819.2l-21-21v-178l21-21h270.7l21.7-21.7h204.7l21.6,21.6v121.1l-20.2,20.2v78.6L1295.2,1082.9z"/>',
'<path d="M1337.8,1279.1L1337.8,1279.1c-2,0-3.7-1.6-3.7-3.7l0,0c0-2,1.6-3.7,3.7-3.7l0,0c2,0,3.7,1.6,3.7,3.7l0,0C1341.5,1277.5,1339.8,1279.1,1337.8,1279.1z"/>',
'<text transform="matrix(1 0 0 1 1066.4193 1071.1001)" style="font-size:28px; text-transform:uppercase; font-family:Futura,Arial,monospace; font-weight: 900">claimed</text>',
'<text transform="matrix(1 0 0 1 1057.7942 744.2)" style="font-size:28px; text-transform:uppercase; font-family:Futura,Arial,monospace; font-weight: 900">purchased</text>',
string.concat(
'<text transform="matrix(1 0 0 1 1066.1456 1290.5452)" style="font-size:28px; text-transform:uppercase; font-family:Futura,Arial,monospace; font-weight: 900">',
percentage.toString(),
"% left</text>"
),
"</g>"
);
}
function elements(string memory color, uint256 progress) internal pure returns (string memory) {
return string.concat(
string.concat('<g stroke="', color, '">'),
'<path style="fill:none;stroke-width:2;stroke-miterlimit:10;" d="M999.4,1354.6c-21.1,25.2-52.8,41.1-88.2,41.1c-63.5,0-115.1-51.6-115.1-115.1s51.6-115.1,115.1-115.1c8,0,15.7,0.8,23.2,2.4"/>',
'<path style="fill:none;stroke-width:2;stroke-miterlimit:10;" d="M954.2,1396.8c-57.4,21.3-123.2-2.8-152.5-58.4c-4-7.6-7.1-15.3-9.4-23.2"/>',
'<path style="fill:none;stroke-width:2;stroke-miterlimit:10;" d="M991,1186c11.9,10,22,22.4,29.8,36.9c14.7,28,17.7,59.1,10.6,87.7"/>',
'<path style="fill:none;stroke-width:2;stroke-miterlimit:10;" d="M1337.8,1285.2L1337.8,1285.2c-5.4,0-9.8-4.4-9.8-9.8l0,0c0-5.4,4.4-9.8,9.8-9.8l0,0c5.4,0,9.8,4.4,9.8,9.8l0,0C1347.6,1280.8,1343.2,1285.2,1337.8,1285.2z"/>',
'<polyline style="fill:none;stroke-width:2;stroke-miterlimit:10;" points="991,1363.6 1022.7,1395.2 1305.8,1395.2 1337.8,1363.2 1337.8,1275.4 "/>',
'<path style="fill:none;stroke-width:2;stroke-miterlimit:10;stroke-dasharray:6.1193,6.1193;" d="M943.5,1170.1c47.9,13.9,82.9,58.1,82.9,110.5c0,26-8.6,49.9-23.1,69.2"/>',
'<path style="fill:none;stroke-width:2;stroke-miterlimit:10;stroke-dasharray:6.0368,6.0368;" d="M861.9,1167.2c22.5-9.8,46.7-12.4,69.6-8.6"/>',
'<circle cx="911.3" cy="1280.6" r="84.8" style="fill:none;stroke:#393E4A;stroke-width:28;stroke-miterlimit:10;"/>',
string.concat(
'<circle cx="911.3" cy="1280.6" r="84.8" style="fill:none;stroke-width:28;stroke-miterlimit:10;" pathLength="10000" stroke-dasharray="10000" stroke-dashoffset="',
progress.toString(),
'" transform="rotate(-90)" transform-origin="911.3 1280.6"/>'
),
LOGO,
"</g>"
);
}
function labels(string memory title, uint256 max, uint256 current) internal pure returns (string memory) {
return string.concat(
string.concat(
'<text transform="matrix(1 0 0 1 209.3455 270.9893)" style="fill:#FFFFFF; font-family:Futura,Arial,monospace; font-weight: 900;" font-size="55px">',
title,
"</text>"
),
string.concat(
'<text transform="matrix(1 0 0 1 872.9004 644.1)" style="fill:#FFFFFF; font-family:Futura,Arial,monospace; font-weight: 900;" font-size="50px">',
max.toString(),
"</text>"
),
string.concat(
'<text transform="matrix(1 0 0 1 872.9005 966.0894)" style="fill:#FFFFFF; font-family:Futura,Arial,monospace; font-weight: 900;" font-size="50px">',
current.toString(),
"</text>"
)
);
}
}
文件 24 的 29:Ownable.sol
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
abstract contract Ownable is Context {
address private _owner;
error OwnableUnauthorizedAccount(address account);
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
modifier onlyOwner() {
_checkOwner();
_;
}
function owner() public view virtual returns (address) {
return _owner;
}
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
文件 25 的 29:SignedMath.sol
pragma solidity ^0.8.20;
library SignedMath {
function max(int256 a, int256 b) internal pure returns (int256) {
return a > b ? a : b;
}
function min(int256 a, int256 b) internal pure returns (int256) {
return a < b ? a : b;
}
function average(int256 a, int256 b) internal pure returns (int256) {
int256 x = (a & b) + ((a ^ b) >> 1);
return x + (int256(uint256(x) >> 255) & (a ^ b));
}
function abs(int256 n) internal pure returns (uint256) {
unchecked {
return uint256(n >= 0 ? n : -n);
}
}
}
文件 26 的 29:Strings.sol
pragma solidity ^0.8.20;
import {Math} from "./math/Math.sol";
import {SignedMath} from "./math/SignedMath.sol";
library Strings {
bytes16 private constant HEX_DIGITS = "0123456789abcdef";
uint8 private constant ADDRESS_LENGTH = 20;
error StringsInsufficientHexLength(uint256 value, uint256 length);
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = Math.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
assembly {
mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
function toStringSigned(int256 value) internal pure returns (string memory) {
return string.concat(value < 0 ? "-" : "", toString(SignedMath.abs(value)));
}
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, Math.log256(value) + 1);
}
}
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
uint256 localValue = value;
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = HEX_DIGITS[localValue & 0xf];
localValue >>= 4;
}
if (localValue != 0) {
revert StringsInsufficientHexLength(value, length);
}
return string(buffer);
}
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH);
}
function equal(string memory a, string memory b) internal pure returns (bool) {
return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));
}
}
文件 27 的 29:VestMembership.sol
pragma solidity 0.8.23;
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
import { ERC721 } from "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import { IERC721 } from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import { IERC721Metadata } from "@openzeppelin/contracts/interfaces/IERC721Metadata.sol";
import { IERC2981 } from "@openzeppelin/contracts/interfaces/IERC2981.sol";
import { Errors } from "src/libraries/Errors.sol";
import { Boolean } from "src/libraries/Boolean.sol";
import { Membership } from "src/types/Configuration.sol";
import { DynamicIds } from "src/libraries/DynamicIds.sol";
import { ERC721DynamicIds } from "src/utils/ERC721DynamicIds.sol";
import { IVestMembership } from "src/IVestMembership.sol";
import { IVestMembershipDescriptor } from "src/VestMembershipDescriptor.sol";
import { IVestPresaleScheduler } from "src/IVestPresaleScheduler.sol";
import { IVestFeeCollectorProvider } from "./IVestFeeCollectorProvider.sol";
contract VestMembership is IERC2981, ERC721DynamicIds, IVestMembership, Ownable {
Metadata internal _metadata;
Membership.Fees internal _fees;
IVestPresaleScheduler internal immutable _scheduler;
IVestMembershipDescriptor internal immutable _descriptor;
IVestFeeCollectorProvider internal immutable _feeCollectorProvider;
mapping(uint256 mintId => Usage) internal _usages;
mapping(uint256 mintId => uint256) internal _rounds;
mapping(uint256 mintId => Attributes) internal _attributes;
error TransferNotAllowed(uint256 publicId);
constructor(
address owner_,
IVestPresaleScheduler scheduler,
IVestFeeCollectorProvider feeCollectorProvider,
Membership.Configuration memory configuration
)
Ownable(owner_)
ERC721(
configuration.descriptor.name(configuration.metadata),
configuration.descriptor.symbol(configuration.metadata)
)
{
if (address(scheduler) == address(0)) revert Errors.UnacceptableReference();
if (address(feeCollectorProvider) == address(0)) revert Errors.UnacceptableReference();
_fees = configuration.fees;
_scheduler = scheduler;
_metadata = configuration.metadata;
_descriptor = configuration.descriptor;
_feeCollectorProvider = feeCollectorProvider;
}
function consume(uint256 publicId, uint256 amount) public onlyOwner returns (uint256) {
uint256 mintId = _requireValidPublicId(publicId);
_usages[mintId].current += amount;
return _updatePublicId(publicId, mintId);
}
function extend(uint256 publicId, uint256 amount) public onlyOwner returns (uint256) {
uint256 mintId = _requireValidPublicId(publicId);
_usages[mintId].max += amount;
return _updatePublicId(publicId, mintId);
}
function reduce(uint256 publicId, uint256 amount) public onlyOwner returns (uint256) {
uint256 mintId = _requireValidPublicId(publicId);
_usages[mintId].max -= amount;
return _updatePublicId(publicId, mintId);
}
function getRoundId(uint256 publicId) external view returns (uint256) {
uint256 mintId = _requireValidPublicId(publicId);
return _rounds[mintId];
}
function unlocked(uint256 publicId) external view returns (uint256) {
uint256 mintId = _requireValidPublicId(publicId);
uint256 timestamp = block.timestamp;
uint256 tgeTimestamp = _scheduler.getTgeTimestamp();
uint256 startTimestamp = _scheduler.getListingTimestamp();
if (tgeTimestamp == 0 || timestamp < tgeTimestamp) return 0;
uint256 allocation = _usages[mintId].max;
IVestMembership.Attributes memory attributes = _attributes[mintId];
uint256 duration = attributes.vestingPeriodCount * attributes.vestingPeriodDuration + attributes.cliffDuration;
if (startTimestamp != 0 && timestamp >= startTimestamp + duration) return allocation;
uint256 tge = (allocation * attributes.tgeNumerator) / attributes.tgeDenominator;
if (startTimestamp == 0 || timestamp < startTimestamp + attributes.cliffDuration) return tge;
uint256 cliffUnlock = (allocation * attributes.cliffNumerator) / attributes.cliffDenominator;
uint256 elapsedTime = timestamp - (startTimestamp + attributes.cliffDuration);
uint256 elapsedPeriods = elapsedTime / attributes.vestingPeriodDuration;
if (attributes.cliffDuration != 0 && attributes.cliffNumerator == 0) elapsedPeriods = elapsedPeriods + 1;
return tge + cliffUnlock + ((allocation - tge - cliffUnlock) * elapsedPeriods) / attributes.vestingPeriodCount;
}
function getStartTimestamp() public view returns (uint256) {
return _scheduler.getListingTimestamp();
}
function mint(address owner_, uint256 roundId, uint256 currentUsage, uint256 maxUsage, Attributes memory attributes)
public
virtual
onlyOwner
returns (uint256 publicId)
{
uint256 mintId = DynamicIds.createMintId(abi.encodePacked(owner_, roundId, maxUsage, block.timestamp));
Usage memory usage = Usage({ current: currentUsage, max: maxUsage });
_rounds[mintId] = roundId;
_usages[mintId] = usage;
_attributes[mintId] = attributes;
bytes memory data = abi.encode(usage, roundId, attributes);
publicId = _mintDynamicIdNFT(owner_, mintId, data);
}
function transferFrom(address from, address to, uint256 publicId) public override(ERC721DynamicIds, IERC721) {
if (_msgSender() != ownerOf(publicId)) {
IVestMembership.Attributes memory attributes = getAttributes(publicId);
if (attributes.tradeable == Boolean.FALSE) revert TransferNotAllowed(publicId);
if (_scheduler.getListingTimestamp() == 0 || block.timestamp < _scheduler.getListingTimestamp()) {
revert TransferNotAllowed(publicId);
}
}
super.transferFrom(from, to, publicId);
}
function getUsage(uint256 publicId) public view returns (Usage memory) {
uint256 mintId = _requireValidPublicId(publicId);
return _usages[mintId];
}
function getAttributes(uint256 publicId) public view returns (Attributes memory) {
uint256 mintId = _requireValidPublicId(publicId);
return _attributes[mintId];
}
function tokenURI(uint256 publicId) public view override returns (string memory) {
uint256 mintId = _requireValidPublicId(publicId);
_requireOwned(mintId);
return _descriptor.tokenURI(getStartTimestamp(), _usages[mintId], _metadata, _attributes[mintId]);
}
function royaltyInfo(uint256, uint256 salePrice) public view virtual returns (address, uint256) {
uint256 royaltyAmount = (salePrice * _fees.numerator) / _fees.denominator;
return (_feeCollectorProvider.getFeeCollector(), royaltyAmount);
}
function _getPayload(uint256 mintId) internal view override returns (bytes memory payload) {
return abi.encode(_usages[mintId]);
}
}
文件 28 的 29:VestMembershipDescriptor.sol
pragma solidity 0.8.23;
import { Base64 } from "@openzeppelin/contracts/utils/Base64.sol";
import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";
import { IERC20Metadata } from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import { IVestMembership } from "src/IVestMembership.sol";
import { MembershipSVG } from "src/libraries/MembershipSVG.sol";
interface IVestMembershipDescriptor {
function name(IVestMembership.Metadata memory metadata) external view returns (string memory);
function symbol(IVestMembership.Metadata memory metadata) external view returns (string memory);
function tokenURI(
uint256 start,
IVestMembership.Usage memory usage,
IVestMembership.Metadata memory metadata,
IVestMembership.Attributes memory attributes
) external view returns (string memory);
}
contract VestMembershipDescriptor is IVestMembershipDescriptor {
using Strings for address;
using Strings for uint32;
using Strings for uint256;
function name(IVestMembership.Metadata memory metadata) public view returns (string memory) {
string memory name_ = IERC20Metadata(address(metadata.token)).name();
return string.concat(name_, " Vesting");
}
function symbol(IVestMembership.Metadata memory metadata) public view returns (string memory) {
string memory symbol_ = IERC20Metadata(address(metadata.token)).symbol();
return string.concat("v", symbol_);
}
function tokenURI(
uint256 start,
IVestMembership.Usage memory usage,
IVestMembership.Metadata memory metadata,
IVestMembership.Attributes memory attributes
) public view virtual returns (string memory) {
string memory json = string.concat(
'{"attributes":',
_traits(start, usage, metadata, attributes),
',"description":"',
metadata.description,
'","name":"',
_title(metadata),
'","image":"',
_image(usage, metadata),
'"}'
);
return string.concat("data:application/json;base64,", Base64.encode(bytes(json)));
}
function _title(IVestMembership.Metadata memory metadata) internal view returns (string memory) {
string memory symbol_ = IERC20Metadata(address(metadata.token)).symbol();
return string.concat("Vesting of ", symbol_);
}
function _image(IVestMembership.Usage memory usage, IVestMembership.Metadata memory metadata)
internal
view
returns (string memory)
{
uint256 denominator = 10 ** IERC20Metadata(address(metadata.token)).decimals();
string memory svg = MembershipSVG.generate(
MembershipSVG.Params({
color: metadata.color,
title: name(metadata),
max: usage.max / denominator,
current: usage.current / denominator
})
);
return string.concat("data:image/svg+xml;base64,", Base64.encode(bytes(svg)));
}
function _traits(
uint256 start,
IVestMembership.Usage memory usage,
IVestMembership.Metadata memory metadata,
IVestMembership.Attributes memory attributes
) internal view returns (string memory) {
uint256 denominator = 10 ** IERC20Metadata(address(metadata.token)).decimals();
string memory traits0 = string.concat(
'[{"trait_type":"Usage","display_type":"boost_percentage","value":',
(usage.max > 0 ? usage.current * 100 / usage.max : 0).toString(),
'},{"trait_type":"Vested tokens","display_type":"number","value":',
Strings.toString(usage.max / denominator),
'},{"trait_type":"Claimed tokens","display_type":"number","value":',
Strings.toString(usage.current / denominator),
'},{"trait_type":"TGE","display_type":"boost_percentage","value":',
(attributes.tgeDenominator > 0 ? attributes.tgeNumerator * 100 / attributes.tgeDenominator : 0).toString(),
'},{"trait_type":"Vesting start","display_type":"date","value":',
start.toString(),
'},{"trait_type":"Vesting end","display_type":"date","value":',
(start + attributes.cliffDuration + (attributes.vestingPeriodCount * attributes.vestingPeriodDuration))
.toString()
);
string memory traits1 = string.concat(
'},{"trait_type":"Cliff duration","value":"',
_getCliffDurationText(attributes.cliffDuration),
'"},{"trait_type":"Cliff unlock","display_type":"boost_percentage","value":',
(attributes.cliffDenominator > 0 ? attributes.cliffNumerator * 100 / attributes.cliffDenominator : 0)
.toString(),
'},{"trait_type":"Unlock frequency","value":"',
_getUnlockFrequencyText(attributes.vestingPeriodDuration),
'"},{"trait_type":"Vested token name","value":"',
IERC20Metadata(address(metadata.token)).name(),
'"},{"trait_type":"Vested token symbol","value":"',
IERC20Metadata(address(metadata.token)).symbol(),
'"},{"trait_type":"Vested token address","value":"',
Strings.toHexString(uint160(metadata.token), 20),
'"}]'
);
return string.concat(traits0, traits1);
}
function _getCliffDurationText(uint256 value) internal pure virtual returns (string memory) {
if (value == 0) return "no cliff";
(uint256 period, string memory label) = _humanize(value);
return string.concat(period.toString(), " ", label);
}
function _getUnlockFrequencyText(uint256 value) internal pure virtual returns (string memory) {
if (value == 0) return "none";
(uint256 period, string memory label) = _humanize(value);
if (period == 1) return string.concat("every ", label);
return string.concat("every ", period.toString(), " ", label);
}
function _humanize(uint256 value) internal pure virtual returns (uint256, string memory) {
if (value < 1 hours) return _pluralize(value / 1 minutes, "minute", "minutes");
if (value < 1 days) return _pluralize(value / 1 hours, "hour", "hours");
return _pluralize(value / 1 days, "day", "days");
}
function _pluralize(uint256 value, string memory singular, string memory plural)
internal
pure
virtual
returns (uint256, string memory)
{
return (value, value == 1 ? singular : plural);
}
}
文件 29 的 29:draft-IERC6093.sol
pragma solidity ^0.8.20;
interface IERC20Errors {
error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);
error ERC20InvalidSender(address sender);
error ERC20InvalidReceiver(address receiver);
error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);
error ERC20InvalidApprover(address approver);
error ERC20InvalidSpender(address spender);
}
interface IERC721Errors {
error ERC721InvalidOwner(address owner);
error ERC721NonexistentToken(uint256 tokenId);
error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);
error ERC721InvalidSender(address sender);
error ERC721InvalidReceiver(address receiver);
error ERC721InsufficientApproval(address operator, uint256 tokenId);
error ERC721InvalidApprover(address approver);
error ERC721InvalidOperator(address operator);
}
interface IERC1155Errors {
error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);
error ERC1155InvalidSender(address sender);
error ERC1155InvalidReceiver(address receiver);
error ERC1155MissingApprovalForAll(address operator, address owner);
error ERC1155InvalidApprover(address approver);
error ERC1155InvalidOperator(address operator);
error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}
{
"compilationTarget": {
"src/VestMembership.sol": "VestMembership"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": [
":@openzeppelin/=node_modules/@openzeppelin/",
":delegatecall/=lib/delegatecall/contracts/",
":ds-test/=lib/forge-std/lib/ds-test/src/",
":forge-std/=lib/forge-std/src/",
":murky/=lib/murky/src/",
":openzeppelin-contracts/=lib/murky/lib/openzeppelin-contracts/",
":solady/=lib/solady/src/",
":solidity-stringutils/=lib/solidity-stringutils/src/"
]
}
[{"inputs":[{"internalType":"address","name":"owner_","type":"address"},{"internalType":"contract IVestPresaleScheduler","name":"scheduler","type":"address"},{"internalType":"contract IVestFeeCollectorProvider","name":"feeCollectorProvider","type":"address"},{"components":[{"components":[{"internalType":"uint16","name":"numerator","type":"uint16"},{"internalType":"uint16","name":"denominator","type":"uint16"}],"internalType":"struct Membership.Fees","name":"fees","type":"tuple"},{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"string","name":"color","type":"string"},{"internalType":"string","name":"description","type":"string"}],"internalType":"struct IVestMembership.Metadata","name":"metadata","type":"tuple"},{"internalType":"contract IVestMembershipDescriptor","name":"descriptor","type":"address"}],"internalType":"struct Membership.Configuration","name":"configuration","type":"tuple"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ERC721EnumerableForbiddenBatchMint","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"owner","type":"address"}],"name":"ERC721IncorrectOwner","type":"error"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ERC721InsufficientApproval","type":"error"},{"inputs":[{"internalType":"address","name":"approver","type":"address"}],"name":"ERC721InvalidApprover","type":"error"},{"inputs":[{"internalType":"address","name":"operator","type":"address"}],"name":"ERC721InvalidOperator","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"ERC721InvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC721InvalidReceiver","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"ERC721InvalidSender","type":"error"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ERC721NonexistentToken","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"ERC721OutOfBoundsIndex","type":"error"},{"inputs":[{"internalType":"uint256","name":"mintId","type":"uint256"}],"name":"InvalidMintId","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"uint256","name":"publicId","type":"uint256"}],"name":"TransferNotAllowed","type":"error"},{"inputs":[],"name":"UnacceptableReference","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"mintId","type":"uint256"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"DynamicIdNFTMinted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"mintId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"newPublicId","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"payload","type":"bytes"}],"name":"DynamicIdNFTUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"publicId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"publicId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"consume","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"publicId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"extend","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"publicId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"publicId","type":"uint256"}],"name":"getAttributes","outputs":[{"components":[{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"allocation","type":"uint256"},{"internalType":"uint256","name":"claimbackPeriod","type":"uint256"},{"internalType":"uint32","name":"tgeNumerator","type":"uint32"},{"internalType":"uint32","name":"tgeDenominator","type":"uint32"},{"internalType":"uint32","name":"cliffDuration","type":"uint32"},{"internalType":"uint32","name":"cliffNumerator","type":"uint32"},{"internalType":"uint32","name":"cliffDenominator","type":"uint32"},{"internalType":"uint32","name":"vestingPeriodCount","type":"uint32"},{"internalType":"uint32","name":"vestingPeriodDuration","type":"uint32"},{"internalType":"uint8","name":"tradeable","type":"uint8"}],"internalType":"struct IVestMembership.Attributes","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"publicId","type":"uint256"}],"name":"getRoundId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getStartTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"publicId","type":"uint256"}],"name":"getUsage","outputs":[{"components":[{"internalType":"uint256","name":"max","type":"uint256"},{"internalType":"uint256","name":"current","type":"uint256"}],"internalType":"struct IVestMembership.Usage","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner_","type":"address"},{"internalType":"uint256","name":"roundId","type":"uint256"},{"internalType":"uint256","name":"currentUsage","type":"uint256"},{"internalType":"uint256","name":"maxUsage","type":"uint256"},{"components":[{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"allocation","type":"uint256"},{"internalType":"uint256","name":"claimbackPeriod","type":"uint256"},{"internalType":"uint32","name":"tgeNumerator","type":"uint32"},{"internalType":"uint32","name":"tgeDenominator","type":"uint32"},{"internalType":"uint32","name":"cliffDuration","type":"uint32"},{"internalType":"uint32","name":"cliffNumerator","type":"uint32"},{"internalType":"uint32","name":"cliffDenominator","type":"uint32"},{"internalType":"uint32","name":"vestingPeriodCount","type":"uint32"},{"internalType":"uint32","name":"vestingPeriodDuration","type":"uint32"},{"internalType":"uint8","name":"tradeable","type":"uint8"}],"internalType":"struct IVestMembership.Attributes","name":"attributes","type":"tuple"}],"name":"mint","outputs":[{"internalType":"uint256","name":"publicId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"publicId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"publicId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"reduce","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"salePrice","type":"uint256"}],"name":"royaltyInfo","outputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"publicId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"publicId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"publicId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"publicId","type":"uint256"}],"name":"unlocked","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]