Skip to main content

JBTiered721DelegateStore

The contract that stores and manages the NFT's data.


Git Source

Inherits: IJBTiered721DelegateStore

Adheres to -

  • IJBTiered721DelegateStore: General interface for the methods in this contract that interact with the blockchain's state according to the protocol's rules.*

State Variables

MAX_ROYALTY_RATE

uint256 public constant override MAX_ROYALTY_RATE = 200;

_ONE_BILLION

uint256 private constant _ONE_BILLION = 1_000_000_000;

_BASE_LOCK_TIMESTAMP

The timestamp to add on to tier lock timestamps.

  • Useful so the stored lock timestamp per-tier can fit in a smaller storage slot.*
uint256 private constant _BASE_LOCK_TIMESTAMP = 1672531200;

_tierIdAfter

The tier ID that should come after the given tier ID when sorting by contribution floor.

  • If empty, assume the next tier ID should come after. _nft The NFT contract to get ordered tier ID from. _tierId The tier ID to get a tier after relative to.*
mapping(address => mapping(uint256 => uint256)) internal _tierIdAfter;

_reservedTokenBeneficiaryOf

An optional beneficiary for the reserved token of a given tier. _nft The NFT contract to which the reserved token beneficiary belongs. _tierId the ID of the tier.

mapping(address => mapping(uint256 => address)) internal _reservedTokenBeneficiaryOf;

_royaltyBeneficiaryOf

An optional beneficiary for the royalty of a given tier. _nft The NFT contract to which the royalty beneficiary belongs. _tierId the ID of the tier.

mapping(address => mapping(uint256 => address)) internal _royaltyBeneficiaryOf;

_storedTierOf

The stored reward tier. _nft The NFT contract to which the tiers belong. _tierId The incremental ID of the tier, starting with 1.

mapping(address => mapping(uint256 => JBStored721Tier)) internal _storedTierOf;

_flagsOf

Flags that influence the behavior of each NFT. _nft The NFT for which the flags apply.

mapping(address => JBTiered721Flags) internal _flagsOf;

_isTierRemovedBitmapWord

For each tier ID, a bitmap containing flags indicating if the tier has been removed. _nft The NFT contract to which the tier belong. _depth The bitmap row. _word The row content bitmap.

mapping(address => mapping(uint256 => uint256)) internal _isTierRemovedBitmapWord;

_trackedLastSortTierIdOf

For each NFT, the tier ID that comes last when sorting.

  • If not set, it is assumed the maxTierIdOf is the last sorted. _nft The NFT contract to which the tier belongs.*
mapping(address => uint256) internal _trackedLastSortTierIdOf;

_startingTierIdOfCategory

The ID of the first tier in each category. _nft The NFT contract to get the tier ID of. _category The category to get the first tier ID of.

mapping(address => mapping(uint256 => uint256)) internal _startingTierIdOfCategory;

maxTierIdOf

The biggest tier ID used.

  • This may not include the last tier ID if it has been removed. _nft The NFT contract to get the number of tiers.*
mapping(address => uint256) public override maxTierIdOf;

tierBalanceOf

Each account's balance within a specific tier. _nft The NFT contract to which the tier balances belong. _owner The address to get a balance for. _tierId The ID of the tier to get a balance within.

mapping(address => mapping(address => mapping(uint256 => uint256))) public override tierBalanceOf;

numberOfReservesMintedFor

The number of reserved tokens that have been minted for each tier. _nft The NFT contract to which the reserve data belong. _tierId The ID of the tier to get a minted reserved token count for.

mapping(address => mapping(uint256 => uint256)) public override numberOfReservesMintedFor;

numberOfBurnedFor

The number of tokens that have been burned for each tier. _nft The NFT contract to which the burned data belong. _tierId The ID of the tier to get a burned token count for.

mapping(address => mapping(uint256 => uint256)) public override numberOfBurnedFor;

defaultReservedTokenBeneficiaryOf

The beneficiary of reserved tokens when the tier doesn't specify a beneficiary. _nft The NFT contract to which the reserved token beneficiary applies.

mapping(address => address) public override defaultReservedTokenBeneficiaryOf;

defaultRoyaltyBeneficiaryOf

The beneficiary of royalties when the tier doesn't specify a beneficiary. _nft The NFT contract to which the royalty beneficiary applies.

mapping(address => address) public override defaultRoyaltyBeneficiaryOf;

firstOwnerOf

The first owner of each token ID, stored on first transfer out. _nft The NFT contract to which the token belongs. _tokenId The ID of the token to get the stored first owner of.

mapping(address => mapping(uint256 => address)) public override firstOwnerOf;

baseUriOf

The common base for the tokenUri's _nft The NFT for which the base URI applies.

mapping(address => string) public override baseUriOf;

tokenUriResolverOf

Custom token URI resolver, supersedes base URI. _nft The NFT for which the token URI resolver applies.

mapping(address => IJBTokenUriResolver) public override tokenUriResolverOf;

contractUriOf

Contract metadata uri. _nft The NFT for which the contract URI resolver applies.

mapping(address => string) public override contractUriOf;

encodedIPFSUriOf

When using this contract to manage token uri's, those are stored as 32bytes, based on IPFS hashes stripped down. _nft The NFT contract to which the encoded upfs uri belongs. _tierId the ID of the tier

mapping(address => mapping(uint256 => bytes32)) public override encodedIPFSUriOf;

Functions

tiers

Gets an array of all the active tiers.

function tiers(address _nft, uint256 _category, uint256 _startingId, uint256 _size)
external
view
override
returns (JB721Tier[] memory _tiers);

Parameters

NameTypeDescription
_nftaddressThe NFT contract to get tiers for.
_categoryuint256The category of the tiers to get. Send 0 for any category.
_startingIduint256The starting tier ID of the array of tiers sorted by contribution floor. Send 0 to start at the beginning.
_sizeuint256The number of tiers to include.

Returns

NameTypeDescription
_tiersJB721Tier[]All the tiers.

tier

Return the tier for the specified ID.

function tier(address _nft, uint256 _id) external view override returns (JB721Tier memory);

Parameters

NameTypeDescription
_nftaddressThe NFT to get a tier within.
_iduint256The ID of the tier to get.

Returns

NameTypeDescription
<none>JB721TierThe tier.

tierOfTokenId

Return the tier for the specified token ID.

function tierOfTokenId(address _nft, uint256 _tokenId) external view override returns (JB721Tier memory);

Parameters

NameTypeDescription
_nftaddressThe NFT to get a tier within.
_tokenIduint256The ID of token to return the tier of.

Returns

NameTypeDescription
<none>JB721TierThe tier.

totalSupply

The total supply of issued NFTs from all tiers.

function totalSupply(address _nft) external view override returns (uint256 supply);

Parameters

NameTypeDescription
_nftaddressThe NFT to get a total supply of.

Returns

NameTypeDescription
supplyuint256The total number of NFTs between all tiers.

numberOfReservedTokensOutstandingFor

The number of reserved tokens that can currently be minted within the tier.

function numberOfReservedTokensOutstandingFor(address _nft, uint256 _tierId) external view override returns (uint256);

Parameters

NameTypeDescription
_nftaddressThe NFT to get a number of reserved tokens outstanding.
_tierIduint256The ID of the tier to get a number of reserved tokens outstanding.

Returns

NameTypeDescription
<none>uint256The outstanding number of reserved tokens within the tier.

votingUnitsOf

The voting units for an account from its NFTs across all tiers. NFTs have a tier-specific preset number of voting units.

function votingUnitsOf(address _nft, address _account) external view virtual override returns (uint256 units);

Parameters

NameTypeDescription
_nftaddressThe NFT to get voting units within.
_accountaddressThe account to get voting units for.

Returns

NameTypeDescription
unitsuint256The voting units for the account.

tierVotingUnitsOf

The voting units for an account from its NFTs across all tiers. NFTs have a tier-specific preset number of voting units.

function tierVotingUnitsOf(address _nft, address _account, uint256 _tierId)
external
view
virtual
override
returns (uint256);

Parameters

NameTypeDescription
_nftaddressThe NFT to get voting units within.
_accountaddressThe account to get voting units for.
_tierIduint256The ID of the tier to get voting units for.

Returns

NameTypeDescription
<none>uint256The voting units for the account.

encodedTierIPFSUriOf

Resolves the encoded tier IPFS URI of the tier for the given token.

function encodedTierIPFSUriOf(address _nft, uint256 _tokenId) external view override returns (bytes32);

Parameters

NameTypeDescription
_nftaddressThe NFT contract to which the encoded IPFS URI belongs.
_tokenIduint256the ID of the token.

Returns

NameTypeDescription
<none>bytes32The encoded IPFS URI.

flagsOf

Flags that influence the behavior of each NFT.

function flagsOf(address _nft) external view override returns (JBTiered721Flags memory);

Parameters

NameTypeDescription
_nftaddressThe NFT for which the flags apply.

Returns

NameTypeDescription
<none>JBTiered721FlagsThe flags.

isTierRemoved

Tier removed from the current tiering

function isTierRemoved(address _nft, uint256 _tierId) external view override returns (bool);

Parameters

NameTypeDescription
_nftaddressThe NFT for which the removed tier is being queried.
_tierIduint256The tier ID to check if removed.

Returns

NameTypeDescription
<none>boolTrue if the tier has been removed

royaltyInfo

Royalty info conforming to EIP-2981.

function royaltyInfo(address _nft, uint256 _tokenId, uint256 _salePrice)
external
view
override
returns (address receiver, uint256 royaltyAmount);

Parameters

NameTypeDescription
_nftaddressThe NFT for which the royalty applies.
_tokenIduint256The ID of the token that the royalty is for.
_salePriceuint256The price being paid for the token.

Returns

NameTypeDescription
receiveraddressThe address of the royalty's receiver.
royaltyAmountuint256The amount of the royalty.

balanceOf

The total number of tokens owned by the given owner.

function balanceOf(address _nft, address _owner) public view override returns (uint256 balance);

Parameters

NameTypeDescription
_nftaddressThe NFT to get a balance from.
_owneraddressThe address to check the balance of.

Returns

NameTypeDescription
balanceuint256The number of tokens owners by the owner across all tiers.

redemptionWeightOf

The cumulative weight the given token IDs have in redemptions compared to the totalRedemptionWeight.

function redemptionWeightOf(address _nft, uint256[] calldata _tokenIds) public view override returns (uint256 weight);

Parameters

NameTypeDescription
_nftaddressThe NFT for which the redemption weight is being calculated.
_tokenIdsuint256[]The IDs of the tokens to get the cumulative redemption weight of.

Returns

NameTypeDescription
weightuint256The weight.

totalRedemptionWeight

The cumulative weight that all token IDs have in redemptions.

function totalRedemptionWeight(address _nft) public view override returns (uint256 weight);

Parameters

NameTypeDescription
_nftaddressThe NFT for which the redemption weight is being calculated.

Returns

NameTypeDescription
weightuint256The total weight.

tierIdOfToken

The tier number of the provided token ID.

  • Tier's are 1 indexed from the tiers array, meaning the 0th element of the array is tier 1.*
function tierIdOfToken(uint256 _tokenId) public pure override returns (uint256);

Parameters

NameTypeDescription
_tokenIduint256The ID of the token to get the tier number of.

Returns

NameTypeDescription
<none>uint256The tier number of the specified token ID.

reservedTokenBeneficiaryOf

The reserved token beneficiary for each tier.

function reservedTokenBeneficiaryOf(address _nft, uint256 _tierId) public view override returns (address);

Parameters

NameTypeDescription
_nftaddressThe NFT to get the reserved token beneficiary within.
_tierIduint256The ID of the tier to get a reserved token beneficiary of.

Returns

NameTypeDescription
<none>addressThe reserved token beneficiary.

recordAddTiers

Adds tiers.

function recordAddTiers(JB721TierParams[] calldata _tiersToAdd) external override returns (uint256[] memory tierIds);

Parameters

NameTypeDescription
_tiersToAddJB721TierParams[]The tiers to add.

Returns

NameTypeDescription
tierIdsuint256[]The IDs of the tiers added.

recordMintReservesFor

Mint a token within the tier for the provided value.

  • Only a project owner can mint tokens.*
function recordMintReservesFor(uint256 _tierId, uint256 _count) external override returns (uint256[] memory tokenIds);

Parameters

NameTypeDescription
_tierIduint256The ID of the tier to mint within.
_countuint256The number of reserved tokens to mint.

Returns

NameTypeDescription
tokenIdsuint256[]The IDs of the tokens being minted as reserves.

recordSetDefaultReservedTokenBeneficiary

Sets the reserved token beneficiary.

function recordSetDefaultReservedTokenBeneficiary(address _beneficiary) external override;

Parameters

NameTypeDescription
_beneficiaryaddressThe reserved token beneficiary.

recordTransferForTier

Record a token transfer.

function recordTransferForTier(uint256 _tierId, address _from, address _to) external override;

Parameters

NameTypeDescription
_tierIduint256The ID the tier being transferred.
_fromaddressThe sender of the token.
_toaddressThe recipient of the token.

recordRemoveTierIds

Remove tiers.

function recordRemoveTierIds(uint256[] calldata _tierIds) external override;

Parameters

NameTypeDescription
_tierIdsuint256[]The tiers IDs to remove.

recordMint

Mints a token in all provided tiers.

function recordMint(uint256 _amount, uint16[] calldata _tierIds, bool _isManualMint)
external
override
returns (uint256[] memory tokenIds, uint256 leftoverAmount);

Parameters

NameTypeDescription
_amountuint256The amount to base the mints on. All mints' price floors must fit in this amount.
_tierIdsuint16[]The IDs of the tier to mint from.
_isManualMintboolA flag indicating if the mint is being made manually by the NFT's owner.

Returns

NameTypeDescription
tokenIdsuint256[]The IDs of the tokens minted.
leftoverAmountuint256The amount leftover after the mint.

recordBurn

Records burned tokens.

function recordBurn(uint256[] calldata _tokenIds) external override;

Parameters

NameTypeDescription
_tokenIdsuint256[]The IDs of the tokens burned.

recordSetFirstOwnerOf

Sets the first owner of a token.

function recordSetFirstOwnerOf(uint256 _tokenId, address _owner) external override;

Parameters

NameTypeDescription
_tokenIduint256The ID of the token having the first owner set.
_owneraddressThe owner to set as the first owner.

recordSetBaseUri

Sets the base URI.

function recordSetBaseUri(string calldata _uri) external override;

Parameters

NameTypeDescription
_uristringThe base URI to set.

recordSetContractUri

Sets the contract URI.

function recordSetContractUri(string calldata _uri) external override;

Parameters

NameTypeDescription
_uristringThe contract URI to set.

recordSetTokenUriResolver

Sets the token URI resolver.

function recordSetTokenUriResolver(IJBTokenUriResolver _resolver) external override;

Parameters

NameTypeDescription
_resolverIJBTokenUriResolverThe resolver to set.

recordSetEncodedIPFSUriOf

Sets the encoded IPFS URI of a tier.

function recordSetEncodedIPFSUriOf(uint256 _tierId, bytes32 _encodedIPFSUri) external override;

Parameters

NameTypeDescription
_tierIduint256The ID of the tier to set the encoded IPFS uri of.
_encodedIPFSUribytes32The encoded IPFS uri to set.

recordFlags

Sets flags.

function recordFlags(JBTiered721Flags calldata _flags) external override;

Parameters

NameTypeDescription
_flagsJBTiered721FlagsThe flag to sets.

cleanTiers

Removes removed tiers from sequencing.

function cleanTiers(address _nft) external override;

Parameters

NameTypeDescription
_nftaddressThe NFT contract to clean tiers for.

_resolvedRoyaltyBeneficiaryOf

The royalty beneficiary for each tier.

function _resolvedRoyaltyBeneficiaryOf(address _nft, uint256 _tierId) internal view returns (address);

Parameters

NameTypeDescription
_nftaddressThe NFT to get the royalty beneficiary within.
_tierIduint256The ID of the tier to get a royalty beneficiary of.

Returns

NameTypeDescription
<none>addressThe reserved token beneficiary.

_numberOfReservedTokensOutstandingFor

The number of reserved tokens that can currently be minted within the tier.

function _numberOfReservedTokensOutstandingFor(address _nft, uint256 _tierId, JBStored721Tier memory _storedTier)
internal
view
returns (uint256);

Parameters

NameTypeDescription
_nftaddressThe NFT to get reserved tokens outstanding.
_tierIduint256The ID of the tier to get a number of reserved tokens outstanding.
_storedTierJBStored721TierThe tier to get a number of reserved tokens outstanding.

Returns

NameTypeDescription
<none>uint256numberReservedTokensOutstanding The outstanding number of reserved tokens within the tier.

_generateTokenId

Finds the token ID and tier given a contribution amount.

function _generateTokenId(uint256 _tierId, uint256 _tokenNumber) internal pure returns (uint256);

Parameters

NameTypeDescription
_tierIduint256The ID of the tier to generate an ID for.
_tokenNumberuint256The number of the token in the tier.

Returns

NameTypeDescription
<none>uint256The ID of the token.

_nextSortedTierIdOf

The next sorted tier ID.

function _nextSortedTierIdOf(address _nft, uint256 _id, uint256 _max) internal view returns (uint256);

Parameters

NameTypeDescription
_nftaddressThe NFT for which the sorted tier ID applies.
_iduint256The ID relative to which the next sorted ID will be returned.
_maxuint256The maximum possible ID.

Returns

NameTypeDescription
<none>uint256The ID.

_firstSortedTierIdOf

The first sorted tier ID of an NFT.

function _firstSortedTierIdOf(address _nft, uint256 _category) internal view returns (uint256 id);

Parameters

NameTypeDescription
_nftaddressThe NFT to get the first sorted tier ID of.
_categoryuint256The category to get the first sorted tier ID of. Send 0 for the first overall sorted ID.

Returns

NameTypeDescription
iduint256The first sorted tier ID.

_lastSortedTierIdOf

The last sorted tier ID of an NFT.

function _lastSortedTierIdOf(address _nft) internal view returns (uint256 id);

Parameters

NameTypeDescription
_nftaddressThe NFT to get the last sorted tier ID of.

Returns

NameTypeDescription
iduint256The last sorted tier ID.

Errors

CANT_MINT_MANUALLY

error CANT_MINT_MANUALLY();

INSUFFICIENT_AMOUNT

error INSUFFICIENT_AMOUNT();

INSUFFICIENT_RESERVES

error INSUFFICIENT_RESERVES();

INVALID_CATEGORY_SORT_ORDER

error INVALID_CATEGORY_SORT_ORDER();

INVALID_CATEGORY

error INVALID_CATEGORY();

INVALID_LOCKED_UNTIL

error INVALID_LOCKED_UNTIL();

INVALID_ROYALTY_RATE

error INVALID_ROYALTY_RATE();

INVALID_QUANTITY

error INVALID_QUANTITY();

INVALID_TIER

error INVALID_TIER();

MAX_TIERS_EXCEEDED

error MAX_TIERS_EXCEEDED();

NO_QUANTITY

error NO_QUANTITY();

OUT

error OUT();

RESERVED_RATE_NOT_ALLOWED

error RESERVED_RATE_NOT_ALLOWED();

MANUAL_MINTING_NOT_ALLOWED

error MANUAL_MINTING_NOT_ALLOWED();

PRICING_RESOLVER_CHANGES_LOCKED

error PRICING_RESOLVER_CHANGES_LOCKED();

TIER_LOCKED

error TIER_LOCKED();

TIER_REMOVED

error TIER_REMOVED();

VOTING_UNITS_NOT_ALLOWED

error VOTING_UNITS_NOT_ALLOWED();