JBTiered721Delegate
Inherits: JBOwnable
, JB721Delegate
, IJBTiered721Delegate
This delegate makes multiple NFT tiers with custom price floors available to a project's contributors upon payment, and allows project owners to enable NFT redemption for treasury assets based on the price floors of those NFTs.
State Variables
_firstOwnerOf
The first owner of each token ID, stored on first transfer out.
mapping(uint256 => address) internal _firstOwnerOf;
_packedPricingContext
Info that contextualizes the pricing of tiers, packed into a uint256: currency in bits 0-47 (48 bits), pricing decimals in bits 48-95 (48 bits), and prices contract in bits 96-255 (160 bits).
uint256 internal _packedPricingContext;
codeOrigin
The address of the original JBTiered721Delegate - used in initialize(...)
to check if this is the original JBTiered721Delegate, and to revert initialization if it is.
address public override codeOrigin;
store
The contract that stores and manages data for this contract's NFTs.
IJBTiered721DelegateStore public override store;
fundingCycleStore
The contract storing all funding cycle configurations.
IJBFundingCycleStore public override fundingCycleStore;
creditsOf
The amount each address has paid which did not go towards minting an NFT. These credits can be redeemed to mint NFTs.
mapping(address => uint256) public override creditsOf;
baseURI
The common base for the tokenUris.
string public override baseURI;
contractURI
Contract metadata uri.
string public override contractURI;
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
Name | Type | Description |
---|---|---|
_tokenId | uint256 | The ID of the token to get the first owner of. |
Returns
Name | Type | Description |
---|---|---|
<none> | address | The first owner of the token. |
pricingContext
Info that contextualizes the pricing of tiers.
function pricingContext() external view override returns (uint256 currency, uint256 decimals, IJBPrices prices);
Returns
Name | Type | Description |
---|---|---|
currency | uint256 | The currency being used. |
decimals | uint256 | The amount of decimals being used. |
prices | IJBPrices | The prices contract being used to resolve currency discrepancies. |
balanceOf
The total number of tokens owned by an address across all tiers.
function balanceOf(address _owner) public view override returns (uint256 balance);
Parameters
Name | Type | Description |
---|---|---|
_owner | address | The address to check the balance of. |
Returns
Name | Type | Description |
---|---|---|
balance | uint256 | The number of tokens owned by the address across all tiers. |
tokenURI
The metadata URI of the provided token ID.
Defer to the tokenUriResolver if it is set. Otherwise, use the tokenUri corresponding with the token's tier.
function tokenURI(uint256 _tokenId) public view virtual override returns (string memory);
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | The ID of the token to get the metadata URI for. |
Returns
Name | Type | Description |
---|---|---|
<none> | string | The token URI corresponding with the token's tier, or the tokenUriResolver URI if it is set. |
redemptionWeightOf
The cumulative redemption weight the given token IDs have compared to the _totalRedemptionWeight
.
function redemptionWeightOf(uint256[] memory _tokenIds, JBRedeemParamsData calldata)
public
view
virtual
override
returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
_tokenIds | uint256[] | The IDs of the tokens to get the cumulative redemption weight of. |
<none> | JBRedeemParamsData |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The redemption weight of the _tokenIds. |
totalRedemptionWeight
The cumulative redemption weight across all token IDs.
function totalRedemptionWeight(JBRedeemParamsData calldata) public view virtual override returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The cumulative redemption weight. |
supportsInterface
Indicates if this contract adheres to the specified interface.
See IERC165-supportsInterface.
function supportsInterface(bytes4 _interfaceId) public view override returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_interfaceId | bytes4 | The ID of the interface to check for adherence to. |
constructor
constructor(
IJBDirectory _directory,
IJBOperatorStore _operatorStore,
bytes4 _payMetadataDelegateId,
bytes4 _redeemMetadataDelegateId
)
JBOwnable(_directory.projects(), _operatorStore)
JB721Delegate(_directory, _payMetadataDelegateId, _redeemMetadataDelegateId);
Parameters
Name | Type | Description |
---|---|---|
_directory | IJBDirectory | A directory of terminals and controllers for projects. |
_operatorStore | IJBOperatorStore | A contract which stores operator assignments. |
_payMetadataDelegateId | bytes4 | The 4bytes ID of this delegate, used for pay metadata parsing |
_redeemMetadataDelegateId | bytes4 | The 4bytes ID of this delegate, used for redeem metadata parsing |
initialize
Initializes a cloned copy of the original JB721Delegate contract.
function initialize(
uint256 _projectId,
string memory _name,
string memory _symbol,
IJBFundingCycleStore _fundingCycleStore,
string memory _baseUri,
IJB721TokenUriResolver _tokenUriResolver,
string memory _contractUri,
JB721PricingParams memory _pricing,
IJBTiered721DelegateStore _store,
JBTiered721Flags memory _flags
) public override;
Parameters
Name | Type | Description |
---|---|---|
_projectId | uint256 | The ID of the project this contract's functionality applies to. |
_name | string | The name of the NFT collection distributed through this contract. |
_symbol | string | The symbol that the NFT collection should be represented by. |
_fundingCycleStore | IJBFundingCycleStore | A contract storing all funding cycle configurations. |
_baseUri | string | A URI to use as a base for full token URIs. |
_tokenUriResolver | IJB721TokenUriResolver | A contract responsible for resolving the token URI for each token ID. |
_contractUri | string | A URI where this contract's metadata can be found. |
_pricing | JB721PricingParams | NFT tier pricing parameters according to which token distribution will be made. Must be sorted by contribution floor (from least to greatest). |
_store | IJBTiered721DelegateStore | The contract which stores the NFT's data. |
_flags | JBTiered721Flags | A set of flags that help to define how this contract works. |
mintFor
Manually mint NFTs from the provided tiers .
function mintFor(uint16[] calldata _tierIds, address _beneficiary)
external
override
requirePermission(owner(), projectId, JB721Operations.MINT)
returns (uint256[] memory tokenIds);
Parameters
Name | Type | Description |
---|---|---|
_tierIds | uint16[] | The IDs of the tiers to mint from. |
_beneficiary | address | The address to mint to. |
Returns
Name | Type | Description |
---|---|---|
tokenIds | uint256[] | The IDs of the newly minted tokens. |
mintReservesFor
Mint reserved tokens within the tier for the provided value.
function mintReservesFor(JBTiered721MintReservesForTiersData[] calldata _mintReservesForTiersData) external override;
Parameters
Name | Type | Description |
---|---|---|
_mintReservesForTiersData | JBTiered721MintReservesForTiersData[] | Contains information about how many reserved tokens to mint for each tier. |