Skip to main content

ERC721Mintable

Functionality available for contracts that implement the IERC721 and IMintableERC721 interfaces.

Allows you to mint new NFTs on the contract.

By default, the NFT metadata is uploaded and pinned to IPFS before minting. You can override this default behavior by providing a string that points to valid metadata object instead of an object.

mint

Mint a new NFT to the connected wallet.

// Custom metadata of the NFT, note that you can fully customize this metadata with other properties.
const metadata = {
name: "Cool NFT #1",
description: "This is a cool NFT",
image: "https://example.com/image.png", // URL, IPFS URI, or File object
// ... Any other metadata you want to include
};

const txResult = await contract.erc721.mint(metadata);
Configuration

metadata

Either provide a string that points to valid metadata object or an object containing the metadata.

The image property can be an IPFS URI, a URL, or a File object.

If a file is provided for the image, it will also be uploaded and pinned to IPFS before minting.

Using a string:

// Option 1: Provide a string that points to valid metadata object
var metadata = "https://example.com/metadata.json";

Using an object:

// Option 2: Provide a metadata object, which will be uploaded and pinned to IPFS for you.
const metadata = {
name: "Cool NFT #1",
description: "This is a cool NFT",
image: "https://example.com/image.png", // URL, IPFS URI, or File object
// ... Any other metadata you want to include
};

Provide the metadata to the mint function:

// Either the string or the object can be provided to the mint function
const txResult = await contract.erc721.mint(metadata);

mintTo

The same as mint, but allows you to specify the address of the wallet that will receive the NFT rather than using the connected wallet address.

// Address of the wallet you want to mint the NFT to
const walletAddress = "{{wallet_address}}";

// Custom metadata of the NFT, note that you can fully customize this metadata with other properties.
const metadata = {
name: "Cool NFT",
description: "This is a cool NFT",
};

const txResult = await contract.erc721.mintTo(walletAddress, metadata);
Configuration

walletAddress

The address of the wallet you want to mint the NFT to.

const walletAddress = "{{wallet_address}}";

const metadata = {
// ...
};

const txResult = await contract.erc721.mintTo(walletAddress, metadata);

metadata

See metadata configuration above.

mintBatch

Mint multiple NFTs in a single transaction to the connected wallet.

const txResult = await contract.erc721.mintBatch([
{
name: "Cool NFT #1",
description: "This is a cool NFT",
image: "https://example.com/image.png", // URL, IPFS URI, or File object
},
{
name: "Cool NFT #2",
description: "This is a cool NFT",
image: "https://example.com/image.png", // URL, IPFS URI, or File object
},
]);
Configuration

metadatas

An array of strings that point to, or objects containing valid metadata properties.

See mint for more details on the properties available.

mintBatchTo

The same as mintBatch, but allows you to specify the address of the wallet that will receive the NFTs rather than using the connected wallet address.

const txResult = contract.erc721.mintBatchTo("{{wallet_address}}", [
{
name: "Cool NFT #1",
description: "This is a cool NFT",
image: "https://example.com/image.png", // URL, IPFS URI, or File object
},
{
name: "Cool NFT #2",
description: "This is a cool NFT",
image: "https://example.com/image.png", // URL, IPFS URI, or File object
},
]);
Configuration

walletAddress

The address of the wallet you want to mint the NFTs to.

Must be a string.

metadatas

An array of strings that point to, or objects containing valid metadata properties.

See mint for more details on the properties available.

nextTokenIdToMint

Returns the token ID of the next NFT that will be minted.

const nextTokenId = await contract.erc721.nextTokenIdToMint();
Configuration

Return Value

Returns a BigNumber representing the token ID of the next NFT that will be minted.

BigNumber;

getMintTransaction

Construct a mint transaction without executing it. This is useful for estimating the gas cost of a mint transaction, overriding transaction options and having fine grained control over the transaction execution.

const txResult = await contract.erc721.getMintTransaction(
"{{wallet_address}}", // Wallet address to mint to
{
name: "Cool NFT #1",
description: "This is a cool NFT",
image: "https://example.com/image.png", // URL, IPFS URI, or File object
// ... Any other metadata you want to include
},
);
Configuration

to

The address of the wallet you want to mint the NFT to.

Must be a string.

metadata

See mint for more details on the properties available.

Return Value

TransactionTask;