Series
NFT drop utilizing the gas-optimized ERC1155, a minimalist and gas efficient standard ERC1155 implementation. This contract allows you to release 1 or many semi-fungible tokens. Nearly all of the features of Edition are present, and are configurable as a default for all tokens, or customizable for either individual tokens or a series of tokens. This enables unique features like rolling release schedules, configurably rarity per token, different tiers of access with allowlists and token gating, and much more.
Getting Started
Module Methods
Smart Contract Methods
Getting Started
To begin we'll import the DecentSDK, chain configurations, and the Series module.
Then we'll setup our signer (via wagmi/ethers) and create a new instance of the DecentSDK.
// Import SDK, chain configurations, and the Edition module
import { DecentSDK, chain, series } from "@decent.xyz/sdk";
// Get the signer via wagmi or configure using ethers
// Setup the SDK with the desired chain and signer
const sdk = new DecentSDK(chain.goerli, signer);
Module Methods
deploy
Deploy a minimal proxy clone of the Series implementation contract.
getContract
Get an ethers contract instance of a previously deployed Series contract.
deploy
Deploy a minimal proxy clone of the Series implementation contract.
const myNFT = await series.deploy(
sdk,
name,
symbol,
hasAdjustableCaps,
isSoulbound,
startTokenId,
endTokenId,
royaltyBPS,
feeManager,
payoutAddress,
currencyOracle,
contractURI,
metadataURI,
defaultDrop,
dropOverrides,
onTxPending,
onTxReceipt
);
console.log("Series deployed to: ", myNFT.address);
sdk (SDK)
An instance of the DecentSDK, configured with a chain and signer.
name (string)
The name of the NFT collection.
symbol (string)
The symbol of the NFT collection.
hasAdjustableCaps (boolean)
Include the ability to change maxTokens at a date after deployment.
isSoulBound (boolean)
Implementation of Soulbound NFTs so that tokens in this collection are non-transferrable. We recommend setting to false
for most use cases. Set to true
if NFTs are intended to be used as a credential or another purely non-financial use case.
startTokenId (number)
The start range of token Ids for your deployment. Can use to add a new collection on a new token Id and attach distinct metadata and drop parameters to unique token Ids.
endTokenId (number)
The end range of token Ids for your deployment (inclusive).
royaltyBPS (number)
Percentage of secondary sales for the contract creator.
feeManager (string)
The address of a deployed FeeManager (IFeeManager). Use zero address if your implementation does not require a fee structure.
payoutAddress (string)
An alternate address for withdrawals and royalty payments may be used. Use zero address as the default setting for owner payouts.
currencyOracle (string)
The address of a ChainLink pricefeed used to lock pricing to an alternate currency, e.g. the address of the ETH / USD pair on Mainnet, or MATIC / USD on Polygon. Leave empty to price asset in the chain's native currency (e.g., ETH on Ethereum, Optimism, and Arbitrum or MATIC on Polygon).
contractURI (string)
The URI for contract level metadata.
metadataURI (string)
The base URI for the collection metadata.
defaultDrop (DropConfig)
The default drop configuration for all tokens within the series.
type DropConfig = {
maxTokens: number | BigNumber,
tokenPrice: BigNumber,
maxTokensPerOwner: number,
presaleMerkleRoot: string | null,
presaleStart: number,
presaleEnd: number | BigNumber,
saleStart: number,
saleEnd: number | BigNumber,
tokenGate: TokenGateConfig | null,
}
dropOverrides (DropMap)
An optional mapping of tokens to drop configurations. By mapping token ids to drop ids, and drop ids to configurations, we can create arbitrary groupings of 1 or many tokens per drop.
export type DropMap = {
tokenIds: number[];
tokenIdDropIds: number[];
dropIds: number[];
drops: DropConfig[];
}
onTxPending (Function) - optional
A callback function executed upon submission of the deploy transaction.
onTxReceipt (Function) - optional
A callback function executed upon receipt of the deploy transaction.
getContract
Get an ethers contract instance of a previously deployed Series contract.
const myNFT = await edition.getContract(sdk, address);
sdk (SDK)
An instance of the DecentSDK, configured with a chain and signer.
address (string)
The contract address of a previously deployed Series contract.
Smart Contract Methods
name
Returns the name of the contract.
symbol
Returns the symbol of the contract.
uri
Returns the URI for a given token ID.
setURI
Set the URI for all token IDs.
contractURI
Returns the URI of the contract metadata.
setContractURI
Sets the URI of the contract metadata.
tokenRange
Returns the range of token IDs that are valid for this contract.
tokenDrop
Returns the drop configuration for the specified token ID.
setTokenDrops
Creates new tokens and updates drop configurations for specified token IDs.
tokenPrice
Gets the current price for the specified token.
mintFee
Gets the current minting fee for the specified token.
mint
Mints a specified number of tokens to a specified address.
mintBatch
Mints a batch of tokens to a specified address.
burn
Burns a specified quantity of tokens from the caller's account.
mintAirdrop
Mints a specified token to multiple recipients as part of an airdrop.
mintPresale
Mints a specified number of tokens to the presale buyer address.
pause
Pauses public minting.
unpause
Unpauses public minting.
setPayoutAddress
Sets the payout address to the specified address.
withdraw
Withdraws the balance of the contract to the payout address or the contract owner.
setRoyaltyBPS
Sets the royalty fee.
royaltyInfo
Returns the royalty recipient and amount for a given sale price.
updateOperatorFilter
Updates the operator filter registry with the specified subscription.
name
Returns the name of the contract.
function name() external view returns (string)
symbol
Returns the symbol of the contract.
function symbol() external view returns (string)
uri
Returns the URI for a given token ID.
A single URI is returned for all token types as defined in EIP-1155's token type ID substitution mechanism.
Clients should replace {id}
with the actual token type ID when calling the function.
unused @param tokenId ID of the token to retrieve the URI for.
function uri(uint256) public view returns (string)
setURI
Set the URI for all token IDs.
function setURI(string uri_) external
Parameters
Name | Type | Description |
---|---|---|
uri_ | string | The URI for token all token IDs. |
contractURI
Returns the URI of the contract metadata.
function contractURI() external view returns (string)
setContractURI
Sets the URI of the contract metadata.
function setContractURI(string contractURI_) external
Parameters
Name | Type | Description |
---|---|---|
contractURI_ | string | The URI of the contract metadata. |
tokenRange
Returns the range of token IDs that are valid for this contract.
function tokenRange() external view returns (uint128 startTokenId, uint128 endTokenId)
Return Values
Name | Type | Description |
---|---|---|
startTokenId | uint128 | The starting token ID for this contract. |
endTokenId | uint128 | The ending token ID for this contract. |
tokenDrop
Returns the drop configuration for the specified token ID.
function tokenDrop(uint128 tokenId) external view returns (struct IDCNTSeries.Drop)
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint128 | The ID of the token to retrieve the drop configuration for. |
Return Values
Name | Type | Description |
---|---|---|
[0] | struct IDCNTSeries.Drop | drop The drop configuration mapped to the specified token ID. |
setTokenDrops
Creates new tokens and updates drop configurations for specified token IDs.
function setTokenDrops(uint128 newTokens, struct IDCNTSeries.DropMap dropMap) external
Parameters
Name | Type | Description |
---|---|---|
newTokens | uint128 | Optional number of new token IDs to add to the existing token range. |
dropMap | struct IDCNTSeries.DropMap | Optional parameter object mapping token IDs, drop IDs, and drops. |
tokenPrice
Gets the current price for the specified token. If a currency oracle is set,
the price is calculated in native currency using the oracle exchange rate.
function tokenPrice(uint256 tokenId) public view returns (uint256)
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | The ID of the token to get the price for. |
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The current price of the specified token. |
mintFee
Gets the current minting fee for the specified token.
function mintFee(uint256 tokenId, uint256 quantity) external view returns (uint256 fee)
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | The ID of the token to get the minting fee for. |
quantity | uint256 | The quantity of tokens used to calculate the minting fee. |
Return Values
Name | Type | Description |
---|---|---|
fee | uint256 | The current fee for minting the specified token. |
mint
Mints a specified number of tokens to a specified address.
function mint(uint256 tokenId, address to, uint256 quantity) external payable
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | The ID of the token to mint. |
to | address | The address to which the minted tokens will be sent. |
quantity | uint256 | The quantity of tokens to mint. |
mintBatch
Mints a batch of tokens to a specified address.
function mintBatch(address to, uint256[] tokenIds, uint256[] quantities) external payable
Parameters
Name | Type | Description |
---|---|---|
to | address | The address to which the minted tokens will be sent. |
tokenIds | uint256[] | The IDs of the tokens to mint. |
quantities | uint256[] | The quantities to mint of each token. |
burn
Burns a specified quantity of tokens from the caller's account.
function burn(uint256 tokenId, uint256 quantity) external
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | The ID of the token to burn. |
quantity | uint256 | The quantity of tokens to burn. |
mintAirdrop
Mints a specified token to multiple recipients as part of an airdrop.
function mintAirdrop(uint256 tokenId, address[] recipients) external
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | The ID of the token to mint. |
recipients | address[] | The list of addresses to receive the minted tokens. |
mintPresale
Mints a specified number of tokens to the presale buyer address.
function mintPresale(uint256 tokenId, uint256 quantity, uint256 maxQuantity, uint256 pricePerToken, bytes32[] merkleProof) external payable
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | The ID of the token to mint. |
quantity | uint256 | The quantity of tokens to mint. |
maxQuantity | uint256 | The maximum quantity of tokens that can be minted. |
pricePerToken | uint256 | The price per token in wei. |
merkleProof | bytes32[] | The Merkle proof verifying that the presale buyer is eligible to mint tokens. |
pause
Pauses public minting.
function pause() external
unpause
Unpauses public minting.
function unpause() external
setPayoutAddress
Sets the payout address to the specified address.
Use 0x0 to default to the contract owner.
function setPayoutAddress(address _payoutAddress) external
Parameters
Name | Type | Description |
---|---|---|
_payoutAddress | address | The address to set as the payout address. |
withdraw
Withdraws the balance of the contract to the payout address or the contract owner.
function withdraw() external
setRoyaltyBPS
Sets the royalty fee (ERC-2981: NFT Royalty Standard).
function setRoyaltyBPS(uint16 _royaltyBPS) public
Parameters
Name | Type | Description |
---|---|---|
_royaltyBPS | uint16 | The royalty fee in basis points. (1/100th of a percent) |
royaltyInfo
Returns the royalty recipient and amount for a given sale price.
function royaltyInfo(uint256 tokenId, uint256 salePrice) external view returns (address receiver, uint256 royaltyAmount)
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | The ID of the token being sold. |
salePrice | uint256 | The sale price of the token. |
Return Values
Name | Type | Description |
---|---|---|
receiver | address | The address of the royalty recipient. |
royaltyAmount | uint256 | The amount to be paid to the royalty recipient. |
updateOperatorFilter
Updates the operator filter registry with the specified subscription.
function updateOperatorFilter(bool enable, address operatorFilter) external
Parameters
Name | Type | Description |
---|---|---|
enable | bool | If true, enables the operator filter, if false, disables it. |
operatorFilter | address | The address of the operator filter subscription. |
Updated 7 months ago