It’s possible to create an ERC-712 collection by calling initializeCollection() method exposed by the nft precompile.
import { Contract, utils } from "ethers";import { NFT_PRECOMPILE_ABI, NFT_PRECOMPILE_ADDRESS } from "@therootnetwork/evm";const wallet = new Wallet(...);const contract = new Contract(NFT_PRECOMPILE_ADDRESS, NFT_PRECOMPILE_ABI);const tx = await contract.connect(wallet).initializeCollection( wallet.address, // owner address utils.toUtf8Bytes("My Collection"), // collection name BigNumber.from(0), // no max issuance utils.toUtf8Bytes("https://example.com/nft/metadata/"), // metadataPath [wallet.address], // royaltyAddresses [100_000], // royaltyEntitlements);const receipt = await tx.wait();const collectionAddress = (receipt?.events as any)[0].args.precompileAddress;
Caution:
The royaltyEntitlements is in permill (parts per million) scaling, so if you want a 10% royalty, that would be 100,000 (as (100_000 / 1_000_000) * 100 = 10%).
Once the collection is created, use the same owner wallet to mint the NFT:
import { Contract, utils } from "ethers";import { ERC721_PRECOMPILE_ABI } from "@therootnetwork/evm";const wallet = new Wallet(...);const contract = new Contract(collectionAddress, ERC721_PRECOMPILE_ABI);// Mint 1 NFT for Aliceawait contract.connect(wallet).mint("0xE04CC55ebEE1cBCE552f250e85c57B70B2E2625b", 1);
Was this page helpful?
Assistant
Responses are generated using AI and may contain mistakes.