HolographMoeERC721DropV2
The HolographMoeERC721DropV2 class facilitates the management of holographable Multichain Open Edition (MOE) contracts, empowering users to seamlessly deploy contracts across multiple networks and tailor the sales configuration of their NFTs.
1. Constructor Parameters
holographConfig
- Type:HolographConfigrequired
The HolographConfig object that the contract will use to deploy contracts.
import { HolographAccountFactory, HolographConfig } from "@holographxyz/sdk";
import { Environment } from "@holographxyz/environment";
export const defaultAccount =
HolographAccountFactory.createAccountUsingPrivateKey(process.env.PRIVATE_KEY);
export const holographConfig: HolographConfig = {
networks: {
ethereum: "https://your-ethereum-rpc-url.com",
polygon: "https://your-polygon-rpc-url.com",
avalanche: "https://your-avalanche-rpc-url.com",
},
environment: Environment.mainnet,
accounts: {
default: defaultAccount,
},
};
createMoeCollectionInput
- Type:CreateMoeCollectionrequired
The input object that the contract will use to deploy contracts.
enum TokenType {
ERC721 = "ERC721",
ERC1155 = "ERC1155",
}
type CreateMoeCollection = {
primaryChainId: number;
collectionInfo: {
name: string;
symbol: string;
description?: string;
tokenType?: TokenType;
royaltiesBps?: number;
salt?: string;
};
nftInfo: {
ipfsUrl: string;
ipfsImageCid: string;
};
salesConfig: {
publicSalePrice: number;
maxSalePurchasePerAddress: number;
publicSaleStart: string;
publicSaleEnd: string;
presaleStart?: string?;
presaleEnd?: string?;
presaleMerkleRoot?: string?;
};
};
import { HolographMoeERC721DropV2 } from "@holographxyz/sdk";
import { networks } from "@holographxyz/networks";
import { holographConfig } from "./config";
const myMOEContract = new HolographMoeERC721DropV2(holographConfig, {
primaryChainId: networks.polygon.chain,
collectionInfo: {
name: "NFTs Without Boundaries",
description: "Possibly the most innovative NFT collection yet.",
symbol: "HOLO",
royaltiesBps: 2000, // 20%
salt: "0x0000000000000000000000000000000000000000000000000000018e7cc167e2",
},
nftInfo: {
ipfsImageCid: "QmQJNvXvNqfDAV4srQ8dRr8s4FYBKB67RnWhvWLvE72osu",
ipfsUrl: "https://fileurl.com/",
},
salesConfig: {
maxSalePurchasePerAddress: 10,
publicSaleStart: "2025-01-01T00:00:00Z",
publicSaleEnd: "2025-01-07T00:00:00Z",
publicSalePrice: 25, // USD unit
},
});
- Validation:
- primaryChainId: numberrequired- must be a valid chain ID.
- collectionInfo:
- name: stringrequired
- symbol: stringrequired
- description: stringdefault: ""
- tokenType: ERC721 | ERC1155default: ERC721
- royaltiesBps: numberdefault: 0- must be a number between 0 and 10000.
- salt: stringdefault: generateRandomSalt()- must be at least a 32-character hexadecimal string. The default is a random generated salt.
- name:
- nftInfo:
- ipfsImageCid: stringrequired- must be a valid 46-character IPFS CID.
- ipfsUrl: stringrequired- must be a valid URL.
- ipfsImageCid:
- salesConfig:
- publicSalePrice: numberrequired- must be greater than or equal 0. It is in the USD unit format, so publicSalePrice = 5 means 5 USD.
- maxSalePurchasePerAddress: numberrequired- must be greater than or equal 1.
- publicSaleStart: stringrequired- must be a future datetime ISO string, e.g: 2024-04-05T13:30:00Z.
- publicSaleEnd: stringrequired- must be a datetime ISO string after the publicSaleStart.
- presaleStart: stringdefault: ""- must be a datetime ISO string.
- presaleEnd: stringdefault: ""- must be a datetime ISO string.
- presaleMerkleRoot: stringdefault: 0x0
- publicSalePrice:
- primaryChainId:
-
Setters:
HolographMoeERC721DropV2
has a couple of setters and they need to follow the above validation. Here's the full list:- setName()
- setDescription()
- setSymbol()
- setTokenType()
- setRoyaltiesBps()
- setSalt()
- setIpfsUrl()
- setIpfsImageCid()
- setPublicSalePrice()
- setMaxSalePurchasePerAddress()
- setPublicSaleStart()
- setPublicSaleEnd()
- setPresaleStart()
- setPresaleEnd()
- setPresaleMerkleRoot()
⚠️ The collection must be deployed before the setters can be envoked.
2. Properties
name
- Type: string
The name of the contract.
description
- Type: string
The description of the contract.
symbol
- Type: string
The symbol of the contract.
tokenType
- Type: TokenType
The type of token that the contract will deploy.
royaltiesBps
- Type: number
The royalties percentage of the contract. It is a number between 0 and 10000.
salt
- Type: 0x${string}
The salt used to generate the contract's address.
nftIpfsImageCid
- Type: string
The NFT IPFS CID 46-character string.
nftIpfsUrl
- Type: string
The IPFS URL of the NFT file.
publicSalePrice
- Type: number
The USD unit price of the NFT.
maxSalePurchasePerAddress
- Type: number
The max amount of NFTs that an unique wallet can mint from.
publicSaleStart
- Type: string
The datetime when the public sale begins.
publicSaleEnd
- Type: string
The datetime when the public sale ends.
presaleStart
- Type: string
The datetime when the presale begins.
presaleEnd
- Type: string
The datetime when the presale ends.
presaleMerkleRoot
- Type: string
The hex string for the NFT presale merkle root. It is utilized to manage the permissible addresses whitelisted for presale.
primaryChainId
- Type: number
The chain ID of the first network where the contract will be deployed. This is the primary network of the contract.
account
- Type: 0x${string}
The account/signer who is interacting with the contract.
chainIds
- Type: number[]
The deployed chain IDs of the contract.
collectionAddress
- Type: 0x${string}
The address that the contract was deployed to.
erc721ConfigHash
- Type: 0x${string}
The ERC721 config hash of the contract.
signature
- Type: Signature
The signature of the last contract deployment.
txHash
- Type: 0x${string}
The transaction hash of the last deployment.
3. Methods
signDeploy()
Gets the signature data necessary for deploying an holographable contract.
Params:
- holographWallet:HolographWalletrequired
- chainId:numberdefault: {primaryChainId}- The chain ID of the network where the contract will be deployed. It defaults to the class's primaryChainId property.
Returns:
Check out the SignDeploy type reference:
Example:
import { HolographWallet } from "@holographxyz/sdk";
import { networks } from "@holographxyz/networks";
import { defaultAccount, holographConfig } from "./config";
const wallet = new HolographWallet({
account: defaultAccount,
chainsRpc: holographConfig.networks,
});
const signatureData = await myMOEContract.signDeploy(wallet); // Primary chain ID.
// const signatureData = await myMOEContract .signDeploy(wallet, networks.avalanche.chain); // Passing a different chain ID.
deploy()
Deploys an omnichain contract.
Params:
- signatureData:SignDeployrequired- The signature data returned by the signDeploy() method.
- options:WriteContractOptionsdefault: {}- The option overrides object for the transaction.
Returns:
import { HolographWallet } from "@holographxyz/sdk";
import { networks } from "@holographxyz/networks";
import { defaultAccount, holographConfig } from "./config";
const wallet = new HolographWallet({
account: defaultAccount,
chainsRpc: holographConfig.networks,
});
const signatureData = await myMOEContract.signDeploy(wallet); // Primary chain ID.
const { collectionAddress, txHash } = await myMOEContract.deploy(
signatureData
);
// Deploying to a different chain.
const binanceSmartChainSignatureData = await myMOEContract.signDeploy(
wallet,
networks.chain.binanceSmartChain
);
await myMOEContract.deploy(binanceSmartChainSignatureData);
How to override the default options:
const { collectionAddress, txHash } = await myMOEContract.deploy(
signatureData,
{
gasLimit: BigInt(1000000),
gasPrice: BigInt(1000000000),
}
);
Here's the full list of override options:
- accessList
- account
- chain
- dataSuffix
- gas
- gasPrice
- maxFeePerBlobGas
- maxFeePerGas
- maxPriorityFeePerGas
- nonce
- type
- value
hydrateFrom() static
Hydrates the MOE contract from a previous deployment.
Params:
- hydrateCollectionConfig:HydrateCollectionConfigrequired- The configuration object for hydrating the MOE contract. See below for the type reference.
Returns:
HydrateCollectionConfig type reference:
import { HolographConfig } from "@holographxyz/sdk";
type HydrateCollectionConfig = {
chainId: number;
collectionAddress: 0x${string};
holographConfig: HolographConfig;
}
Example:
import { HolographMoeERC721DropV2 } from "@holographxyz/sdk";
import { networks } from "@holographxyz/networks";
import { holographConfig } from "./config";
const myMOEContract = await HolographMoeERC721DropV2.hydrateFrom({
chainId: networks.polygon.chain,
collectionAddress: "0xaaaB48817189C5768887Ed7809ebF6E88e629bD5",
holographConfig,
});
console.log(myMOEContract.name); // NFTs Without Boundaries
console.log(myMOEContract.symbol); // HOLO
console.log(myMOEContract.chainIds); // [137, 56]
console.log(myMOEContract.nftIpfsImageCid); // QmQJNvXvNqfDAV4srQ8dRr8s4FYBKB67RnWhvWLvE72osu
getCollectionInfo()
Retrieves the contract information, essentially the initial data passed to the constructor, along with any potential modifications made by the setters, prior to deployment.
Returns:
MoeCollectionInfo type reference:
type MoeCollectionInfo = {
name: string;
symbol: string;
royaltiesBps: number;
salt: `0x${string}`;
tokenType: TokenType;
description?: string;
ipfsUrl: string;
ipfsImageCid: string;
publicSalePrice: number;
maxSalePurchasePerAddress: number;
publicSaleStart: string;
publicSaleEnd: string;
presaleStart?: string;
presaleEnd?: string;
presaleMerkleRoot?: string;
};
Example:
const collectionInfo = await myMOEContract.getCollectionInfo();
console.log(collectionInfo.name); // NFTs Without Boundaries