Skip to main content

HolographOpenEditionContract

The HolographOpenEditionERC721ContractV2 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

createHolographOpenEditionERC721ContractInput

  • Type:
    CreateHolographOpenEditionERC721Contractrequired

The input object that the contract will use to deploy contracts.

type CreateHolographOpenEditionERC721Contract = {
primaryChainId: number;

contractInfo: {
name: string;
symbol: string;
description?: string;
royaltiesPercentage?: number;
salt?: string;
};

nftInfo: {
ipfsUrl: string;
ipfsImageCid: string;
};

salesConfig: {
publicSalePrice: number;
maxSalePurchasePerAddress: number;
publicSaleStart: string;
publicSaleEnd: string;
presaleStart?: string?;
presaleEnd?: string?;
presaleMerkleRoot?: string?;
};
};
src/holograph/open-edition-contract.ts
import { HolographOpenEditionERC721ContractV2 } from "@holographxyz/sdk";
import { networks } from "@holographxyz/networks";

const myOpenEditionContract = new HolographOpenEditionERC721ContractV2({
primaryChainId: networks.polygon.chain,
contractInfo: {
name: "NFTs Without Boundaries",
description: "Possibly the most innovative NFT contract yet.",
symbol: "HOLO",
royaltiesPercentage: 2000, // 20%.
},
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.
    • contractInfo:
      • name:
        stringrequired
      • symbol:
        stringrequired
      • description:
        stringdefault: ""
      • royaltiesPercentage:
        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.
    • nftInfo:
      • ipfsImageCid:
        stringrequired
        - must be a valid 46-character IPFS CID.
      • ipfsUrl:
        stringrequired
        - must be a valid URL.
    • 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

  • Setters:

    HolographOpenEditionERC721ContractV2 has a couple of setters and they need to follow the above validation. Here's the full list:

    • setName()
    • setDescription()
    • setSymbol()
    • setRoyaltiesPercentage()
    • setSalt()
    • setIpfsUrl()
    • setIpfsImageCid()
    • setPublicSalePrice()
    • setMaxSalePurchasePerAddress()
    • setPublicSaleStart()
    • setPublicSaleEnd()
    • setPresaleStart()
    • setPresaleEnd()
    • setPresaleMerkleRoot()

    ⚠️ The contract 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.

royaltiesPercentage

  • 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.

contractAddress

  • 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:

Promise<SignDeploy>

Check out the SignDeploy type reference:

Example:

import { HolographWallet } from "@holographxyz/sdk";
import { networks } from "@holographxyz/networks";

import { defaultAccount } from "./config";

const wallet = new HolographWallet({
account: defaultAccount,
});

const signatureData = await myOpenEditionContract.signDeploy(wallet); // Primary chain ID.

// const signatureData = await myOpenEditionContract.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:

Promise<{ contractAddress: 0x{string}, txHash: 0x{string} }>

import { HolographWallet } from "@holographxyz/sdk";
import { networks } from "@holographxyz/networks";

import { defaultAccount } from "./config";

const wallet = new HolographWallet({
account: defaultAccount,
});

const signatureData = await myOpenEditionContract.signDeploy(wallet); // Primary chain ID.

const { contractAddress, txHash } = await myOpenEditionContract.deploy(
signatureData
);

// Deploying to a different chain.
const binanceSmartChainSignatureData = await myOpenEditionContract.signDeploy(
wallet,
networks.chain.binanceSmartChain
);

await myOpenEditionContract.deploy(binanceSmartChainSignatureData);

How to override the default options:

const { contractAddress, txHash } = await myOpenEditionContract.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

hydrate()
static

Hydrates the open edition contract from a previous deployment.

Params:

  • hydrateContract:
    HydrateHolographOpenEditionERC721Contractrequired
    - The configuration object for hydrating the open edition contract. See below for the type reference.

Returns:

Promise<HolographOpenEditionERC721ContractV2>
- The hydrated contract class instance, ready for use.

HydrateHolographOpenEditionERC721Contract type reference:

type OpenEditionSalesConfig = {
publicSalePrice: number;
maxSalePurchasePerAddress: number;
publicSaleStart: string;
publicSaleEnd: string;
presaleStart?: string?;
presaleEnd?: string?;
presaleMerkleRoot?: string?;
}

type HydrateContractConfig = {
contractInfo: {
name: string;
symbol: string;
royaltiesPercentage?: number;
salt?: string;
}
nftInfo: {
ipfsUrl: string;
ipfsImageCid: string;
}
salesConfig: OpenEditionSalesConfig;
chainId: number;
address: Address;
txHash?: 0x${string};
}

Example:

import { HolographOpenEditionERC721ContractV2 } from "@holographxyz/sdk";
import { networks } from "@holographxyz/networks";

const myOpenEditionContract =
await HolographOpenEditionERC721ContractV2.hydrate({
chainId: networks.polygon.chain,
contractAddress: "0xaaaB48817189C5768887Ed7809ebF6E88e629bD5",
contractInfo: {
name: "NFTs Without Boundaries",
description: "Possibly the most innovative NFT contract yet.",
symbol: "HOLO",
royaltiesPercentage: 2000,
},
nftInfo: {
ipfsImageCid: "QmQJNvXvNqfDAV4srQ8dRr8s4FYBKB67RnWhvWLvE72osu",
ipfsUrl: "https://fileurl.com/",
},
salesConfig: {
maxSalePurchasePerAddress: 10,
publicSaleStart: "2025-01-01T00:00:00Z",
publicSaleEnd: "2025-01-07T00:00:00Z",
publicSalePrice: 25,
},
});

console.log(myOpenEditionContract.name); // NFTs Without Boundaries
console.log(myOpenEditionContract.symbol); // HOLO
console.log(myOpenEditionContract.chainIds); // [137, 56]
console.log(myOpenEditionContract.nftIpfsImageCid); // QmQJNvXvNqfDAV4srQ8dRr8s4FYBKB67RnWhvWLvE72osu

getContractInfo()

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:

OpenEditionContractInfo

OpenEditionContractInfo type reference:

type OpenEditionContractInfo = {
name: string;
symbol: string;
royaltiesPercentage: number;
salt: `0x${string}`;
description?: string;
ipfsUrl: string;
ipfsImageCid: string;
publicSalePrice: number;
maxSalePurchasePerAddress: number;
publicSaleStart: string;
publicSaleEnd: string;
presaleStart?: string;
presaleEnd?: string;
presaleMerkleRoot?: string;
};

Example:

const contractInfo = await myOpenEditionContract.getContractInfo();

console.log(contractInfo.name); // NFTs Without Boundaries

4. Retrieving Contract Data

You can retrieve data from a deployed open edition contract and deploy it to another network using the following approach:

src/holograph/open-edition-contract.ts
import { ContractType, HolographProtocol } from "@holographxyz/sdk";
import { networks } from "@holographxyz/networks";

import { wallet } from "./config";

const protocol = new HolographProtocol();

// HolographOpenEditionERC721ContractV2 instance:
const openEditionContract = await protocol.hydrateContractFromAddress({
address: "0xaaaB48817189C5768887Ed7809ebF6E88e629bD5",
chainId: networks.polygon.chain,
type: ContractType.HolographOpenEditionERC721V2,
});

// Deploying to a different chain.
const signatureData = await openEditionContract.signDeploy(
wallet,
networks.avalanche.chain
);

await openEditionContract.deploy(signatureData);