Mint an NFT
Now that we have a deployed contract, we can mint an NFT.
This document assumes you have followed the deploy a contract instructions and have a contract address for minting NFTs.

Load the contract

Use the loadContract method to assign the contract to a variable.
Add the deployed contract address.
const existing = await sdk.loadContract({
template: TEMPLATES.ERC721Mintable,
contractAddress: "<CONTRACT_ADDRESS>",
});
console.log(`Contract address is: ${existing.contractAddress}`);

Mint an NFT

Create a new meta data file containing information about the NFT.
{
"name": "ConsenSys NFT Number 1",
"description": "The first NFT of all of them.",
"image": "https://infura.io/_next/image?url=%2Fimages%2Fmarketing%2Fproduct%2Feth-header.png&w=1920&q=75"
}
Include the tokenURI in the mint method.
Like contractURI, the tokenURI must resolve to a public, hosted, well-formed json file.
We added the json file to Infura IPFS as before.
Call the mint method.
const mint1 = await existing.mint({
publicAddress: process.env.WALLET_PUBLIC_ADDRESS,
tokenURI: 'https://bafybeiebu2p6locm37kt2yqybpk6cw5kih5dytnfm3mkh7h7auuksbtx5i.ipfs.infura-ipfs.io/',
}
);
const minted = await mint1.wait();
console.log(`Status: ${minted.status}\n NFT minted on ${minted.blockHash} with ${minted.confirmations} confirmation!`);
Example output:
Contract address is: 0x0300F3F929B558e84107B67e3FbBe9e897daDB5a
Status: 1
NFT minted on 0x3df8bf019a2d38f71173a1c7d94ab1f70ffa13a411b311e9054c55fd3e35c00a with 1 confirmation!

Get contract data

After deploying and minting, the contract metadata is available.
const contractMetadata = await sdk.getContractMetadata({
contractAddress: "<CONTRACT_ADDRESS>"
});
console.log('contract metadata: \n', contractMetadata);
Example output:
contract metadata:
{ symbol: 'CONS', name: 'NFT contract', tokenType: 'ERC721' }