Skip to main content

JBTiered721Delegate

Delegate that offers project contributors NFTs with tiered price floors upon payment and the ability to redeem NFTs for treasury assets based based on price floor.


Git Source

Inherits: JB721Delegate, Ownable, IJBTiered721Delegate, IERC2981

Adheres to -

  • IJBTiered721Delegate: General interface for the methods in this contract that interact with the blockchain's state according to the protocol's rules.
  • IERC2981: Royalty standard.

Inherits from -

  • JB721Delegate: A generic NFT delegate.
  • Votes: A helper for voting balance snapshots.
  • Ownable: Includes convenience functionality for checking a message sender's permissions before executing certain transactions.

State Variables

codeOrigin

The address of the origin 'JBTiered721Delegate', used to check in the init if the contract is the original or not

address public override codeOrigin;

store

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

IJBTiered721DelegateStore public override store;

fundingCycleStore

The contract storing all funding cycle configurations.

IJBFundingCycleStore public override fundingCycleStore;

prices

The contract that exposes price feeds.

IJBPrices public override prices;

pricingCurrency

The currency that is accepted when minting tier NFTs.

uint256 public override pricingCurrency;

pricingDecimals

The currency that is accepted when minting tier NFTs.

uint256 public override pricingDecimals;

creditsOf

The amount that each address has paid that has not yet contribute to the minting of an NFT. _address The address to which the credits belong.

mapping(address => uint256) public override creditsOf;

Functions

firstOwnerOf

The first owner of each token ID, which corresponds to the address that originally contributed to the project to receive the NFT.

function firstOwnerOf(uint256 _tokenId) external view override returns (address);

Parameters

NameTypeDescription
_tokenIduint256The ID of the token to get the first owner of.

Returns

NameTypeDescription
<none>addressThe first owner of the token.

royaltyInfo

Royalty info conforming to EIP-2981.

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

Parameters

NameTypeDescription
_tokenIduint256The ID of the token that the royalty is for.
_salePriceuint256The price being paid for the token.

Returns

NameTypeDescription
<none>addressThe address of the royalty's receiver.
<none>uint256The amount of the royalty.

balanceOf

The total number of tokens owned by the given owner across all tiers.

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

Parameters

NameTypeDescription
_owneraddressThe address to check the balance of.

Returns

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

tokenURI

The metadata URI of the provided token ID.

  • Defer to the tokenUriResolver if set, otherwise, use the tokenUri set with the token's tier.*
function tokenURI(uint256 _tokenId) public view virtual override returns (string memory);

Parameters

NameTypeDescription
_tokenIduint256The ID of the token to get the tier URI for.

Returns

NameTypeDescription
<none>stringThe token URI corresponding with the tier or the tokenUriResolver URI.

contractURI

Returns the URI where contract metadata can be found.

function contractURI() external view virtual override returns (string memory);

Returns

NameTypeDescription
<none>stringThe contract's metadata URI.

redemptionWeightOf

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

function redemptionWeightOf(uint256[] memory _tokenIds, JBRedeemParamsData calldata)
public
view
virtual
override
returns (uint256);

Parameters

NameTypeDescription
_tokenIdsuint256[]The IDs of the tokens to get the cumulative redemption weight of.
<none>JBRedeemParamsData

Returns

NameTypeDescription
<none>uint256The weight.

totalRedemptionWeight

The cumulative weight that all token IDs have in redemptions.

function totalRedemptionWeight(JBRedeemParamsData calldata) public view virtual override returns (uint256);

Returns

NameTypeDescription
<none>uint256The total weight.

supportsInterface

Indicates if this contract adheres to the specified interface.

  • See {IERC165-supportsInterface}.*
function supportsInterface(bytes4 _interfaceId) public view override(JB721Delegate, IERC165) returns (bool);

Parameters

NameTypeDescription
_interfaceIdbytes4The ID of the interface to check for adherence to.

constructor

constructor();

initialize

function initialize(
uint256 _projectId,
IJBDirectory _directory,
string memory _name,
string memory _symbol,
IJBFundingCycleStore _fundingCycleStore,
string memory _baseUri,
IJBTokenUriResolver _tokenUriResolver,
string memory _contractUri,
JB721PricingParams memory _pricing,
IJBTiered721DelegateStore _store,
JBTiered721Flags memory _flags
) public override;

Parameters

NameTypeDescription
_projectIduint256The ID of the project this contract's functionality applies to.
_directoryIJBDirectoryThe directory of terminals and controllers for projects.
_namestringThe name of the token.
_symbolstringThe symbol that the token should be represented by.
_fundingCycleStoreIJBFundingCycleStoreA contract storing all funding cycle configurations.
_baseUristringA URI to use as a base for full token URIs.
_tokenUriResolverIJBTokenUriResolverA contract responsible for resolving the token URI for each token ID.
_contractUristringA URI where contract metadata can be found.
_pricingJB721PricingParamsThe tier pricing according to which token distribution will be made. Must be passed in order of contribution floor, with implied increasing value.
_storeIJBTiered721DelegateStoreA contract that stores the NFT's data.
_flagsJBTiered721FlagsA set of flags that help define how this contract works.

mintReservesFor

Mint reserved tokens within the tier for the provided value.

function mintReservesFor(JBTiered721MintReservesForTiersData[] calldata _mintReservesForTiersData) external override;

Parameters

NameTypeDescription
_mintReservesForTiersDataJBTiered721MintReservesForTiersData[]Contains information about how many reserved tokens to mint for each tier.

mintFor

Mint tokens within the tier for the provided beneficiaries.

function mintFor(JBTiered721MintForTiersData[] calldata _mintForTiersData) external override onlyOwner;

Parameters

NameTypeDescription
_mintForTiersDataJBTiered721MintForTiersData[]Contains information about how who to mint tokens for from each tier.

adjustTiers

Adjust the tiers mintable through this contract, adhering to any locked tier constraints.

  • Only the contract's owner can adjust the tiers.*
function adjustTiers(JB721TierParams[] calldata _tiersToAdd, uint256[] calldata _tierIdsToRemove)
external
override
onlyOwner;

Parameters

NameTypeDescription
_tiersToAddJB721TierParams[]An array of tier data to add.
_tierIdsToRemoveuint256[]An array of tier IDs to remove.

setDefaultReservedTokenBeneficiary

Sets the beneficiary of the reserved tokens for tiers where a specific beneficiary isn't set.

  • Only the contract's owner can set the default reserved token beneficiary.*
function setDefaultReservedTokenBeneficiary(address _beneficiary) external override onlyOwner;

Parameters

NameTypeDescription
_beneficiaryaddressThe default beneficiary of the reserved tokens.

setBaseUri

Set a base token URI.

  • Only the contract's owner can set the base URI.*
function setBaseUri(string calldata _baseUri) external override onlyOwner;

Parameters

NameTypeDescription
_baseUristringThe new base URI.

setContractUri

Set a contract metadata URI to contain opensea-style metadata.

  • Only the contract's owner can set the contract URI.*
function setContractUri(string calldata _contractUri) external override onlyOwner;

Parameters

NameTypeDescription
_contractUristringThe new contract URI.

setTokenUriResolver

Set a token URI resolver.

  • Only the contract's owner can set the token URI resolver.*
function setTokenUriResolver(IJBTokenUriResolver _tokenUriResolver) external override onlyOwner;

Parameters

NameTypeDescription
_tokenUriResolverIJBTokenUriResolverThe new URI resolver.

setEncodedIPFSUriOf

Set an encoded IPFS uri of a tier.

  • Only the contract's owner can set the encoded IPFS uri.*
function setEncodedIPFSUriOf(uint256 _tierId, bytes32 _encodedIPFSUri) external override onlyOwner;

Parameters

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

mintReservesFor

Mint reserved tokens within the tier for the provided value.

function mintReservesFor(uint256 _tierId, uint256 _count) public override;

Parameters

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

mintFor

Manually mint NFTs from tiers.

function mintFor(uint16[] calldata _tierIds, address _beneficiary)
public
override
onlyOwner
returns (uint256[] memory tokenIds);

Parameters

NameTypeDescription
_tierIdsuint16[]The IDs of the tiers to mint from.
_beneficiaryaddressThe address to mint to.

Returns

NameTypeDescription
tokenIdsuint256[]The IDs of the newly minted tokens.

_processPayment

Mints for a given contribution to the beneficiary.

function _processPayment(JBDidPayData calldata _data) internal override;

Parameters

NameTypeDescription
_dataJBDidPayDataThe Juicebox standard project contribution data.

_didBurn

A function that will run when tokens are burned via redemption.

function _didBurn(uint256[] memory _tokenIds) internal virtual override;

Parameters

NameTypeDescription
_tokenIdsuint256[]The IDs of the tokens that were burned.

_mintAll

Mints a token in all provided tiers.

function _mintAll(uint256 _amount, uint16[] memory _mintTierIds, address _beneficiary)
internal
returns (uint256 leftoverAmount);

Parameters

NameTypeDescription
_amountuint256The amount to base the mints on. All mints' price floors must fit in this amount.
_mintTierIdsuint16[]An array of tier IDs that are intended to be minted.
_beneficiaryaddressThe address to mint for.

Returns

NameTypeDescription
leftoverAmountuint256The amount leftover after the mint.

_beforeTokenTransfer

User the hook to register the first owner if it's not yet registered.

function _beforeTokenTransfer(address _from, address _to, uint256 _tokenId) internal virtual override;

Parameters

NameTypeDescription
_fromaddressThe address where the transfer is originating.
_toaddressThe address to which the transfer is being made.
_tokenIduint256The ID of the token being transferred.

_afterTokenTransfer

Transfer voting units after the transfer of a token.

function _afterTokenTransfer(address _from, address _to, uint256 _tokenId) internal virtual override;

Parameters

NameTypeDescription
_fromaddressThe address where the transfer is originating.
_toaddressThe address to which the transfer is being made.
_tokenIduint256The ID of the token being transferred.

_afterTokenTransferAccounting

Custom hook to handle token/tier accounting, this way we can reuse the '_tier' instead of fetching it again.

function _afterTokenTransferAccounting(address _from, address _to, uint256 _tokenId, JB721Tier memory _tier)
internal
virtual;

Parameters

NameTypeDescription
_fromaddressThe account to transfer voting units from.
_toaddressThe account to transfer voting units to.
_tokenIduint256The ID of the token for which voting units are being transferred.
_tierJB721TierThe tier the token ID is part of.

Errors

NOT_AVAILABLE

error NOT_AVAILABLE();

OVERSPENDING

error OVERSPENDING();

PRICING_RESOLVER_CHANGES_PAUSED

error PRICING_RESOLVER_CHANGES_PAUSED();

RESERVED_TOKEN_MINTING_PAUSED

error RESERVED_TOKEN_MINTING_PAUSED();

TRANSFERS_PAUSED

error TRANSFERS_PAUSED();