Treasury-Backed
Release NFTs with a vault that enables collectors to pool & share rewards.
This module simplifies the process of launching a Vault-Backed NFT into a single transaction, allowing you to deploy either an Edition or Rentable which will be automatically backed by a shared Vault.
Getting Started
Module Methods
Getting Started
To begin we'll import the DecentSDK, chain configurations, and VaultBackedNFT module.
Then we'll setup our signer (via wagmi/ethers) and create a new instance of the DecentSDK.
// Import SDK, chain configurations, and the VaultBackedNFT module
import { DecentSDK, chain, vaultBackedNFT } 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
create
Creates deployments of minimal proxy clones of the Vault as well as Edition or Rentable implementation contracts.
create
Creates deployments of minimal proxy clones of the Vault as well as Edition or Rentable implementation contracts.
const [myNFT, myVault] = await edition.deploy(
sdk,
name,
symbol,
hasAdjustableCap,
isSoulbound,
maxTokens,
tokenPrice,
maxTokenPurchase,
presaleMerkleRoot,
presaleStart,
presaleEnd,
saleStart,
saleEnd,
royaltyBPS,
feeManager,
payoutAddress,
contractURI,
metadataURI,
metadataRendererInit,
tokenGateConfig,
vaultDistributionTokenAddress,
unlockDate,
supports4907,
onTxPending,
onTxReceipt,
parentIP
);
console.log("NFT deployed to: ", myNFT.address);
console.log("Vault deployed to: ", myVault.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.
hasAdjustableCap (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. Best set to true
if NFTs are intended to be used as a credential or another purely non-financial use case.
maxTokens (number)
The total number of tokens allowed to be minted from the collection.
tokenPrice (BigNumber)
The price (in Wei) to mint a token from the collection.
maxTokenPurchase (number)
The maximum number of tokens allowed per mint.
presaleMerkleRoot (number | BigNumber)
A merkle root representation of the allowlisted accounts, and their relative max purchase and price per token.
import { MerkleTree } from 'merkletreejs';
import { ethers } from 'ethers';
const createMerkleRoot = (allowlist: Allowed[]) => {
const leaves = allowlist.map((leaf) => {
const address = leaf[0];
const maxQuantity = leaf[1];
const pricePerToken = ethers.utils.parseEther(leaf[2].toString());
return ethers.utils.solidityKeccak256(
["address", "uint256", "uint256"],
[address, maxQuantity, pricePerToken]
);
});
const tree = new MerkleTree(leaves, ethers.utils.keccak256, { sortPairs: true });
return tree.getHexRoot();
}
const presaleMerkleRoot = createMerkleRoot([
['0xce90a7949bb78892f159f428d0dc23a8e3584d75', 1, 0.1],
['0xab5801a7d398351b8be11c439e05c5b3259aec9b', 1, 0.1],
]);
presaleStart (number | BigNumber)
Unix time presale ends.
presaleEnd (number | BigNumber)
Unix time presale ends.
saleStart (number | BigNumber)
Unix time general sale starts. General sale applies to contracts deployed with and without an allowlist.
saleEnd (number | BigNumber)
Unix time general sale ends.
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.
contractURI (string)
The URI for contract level metadata.
metadataURI (string)
The base URI for the collection metadata.
metadataRendererInit (MetadataRendererInit)
An object containing metadata to initialize with the on-chain metadata renderer.
type MetadataRendererInit = {
description: string;
imageURI: string;
animationURI: string;
}
tokenGateConfig (TokenGateConfig) optional
The configuration for a token gate, an NFT contract from wich users must have a minimum balance to mint. Think of this as a more dynamic allowlist or light anti-sybil mechanism.
type TokenGateConfig = {
tokenAddress: string;
minBalance: number;
saleType: number;
}
enum SaleType {
ALL = 0,
PRESALE = 1,
PRIMARY = 2
}
vaultDistributionTokenAddress (string)
The address of the ERC20 token that will be distributed by the vault.
unlockDate (number)
The timestamp at which the vault will unlock and allow distributions.
supports4907 (boolean)
A flag indicating whether to deploy a Rentable (true) or Edition (false) as the underlying NFT.
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.
parentIP (string) - optional
Implementation of EIP 5553 to assign token metadata to the address of another NFT with registered IP.
Updated 3 months ago