ERC1155 - Mint NFTs
You can utilize these features of the SDK if your contract implements the ERC1155Mintable interface.
Mint an NFT with a limited supply
Provide a metadata object to mint a specified quantity of a new NFT.
This function automatically uploads and pins your metadata to IPFS.
If you already have your metadata uploaded to IPFS (or any URL that points to valid metadata),
you can directly pass the URI
as the second argument; rather than a metadata object.
- React
- Javascript
- Python
- Go
- Unity
const Component = () => {
const { contract } = useContract("{{contract_address}}");
const {
mutate: mintNft,
isLoading,
error,
} = useMintNFT(contract);
if (error) {
console.error("failed to mint NFT", error);
}
return (
<button
disabled={isLoading}
onClick={() => mintNft({ name: "My awesome NFT!", to: "{{wallet_address}}" })}
>
Mint!
</button>
);
};
This snippet is for v3 of the SDK. Learn how to upgrade.
View in React SDK Documentation// Address of the wallet you want to mint the NFT to
const toAddress = "{{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",
image: fs.readFileSync("path/to/image.png"), // This can be an image url or file
}
const metadataWithSupply = {
metadata,
supply: 1000, // The number of this NFT you want to mint
}
const tx = await contract.erc1155.mint(toAddress, metadataWithSupply);
const receipt = tx.receipt; // the transaction receipt
const tokenId = tx.id; // the id of the NFT minted
const nft = await tx.data(); // (optional) fetch details of minted NFT
This snippet is for v3 of the SDK. Learn how to upgrade.
View in Javascript SDK DocumentationThis feature is missing a code snippet or might not be supported yet.
Check the Python SDK documentation for more information.
Reach out on Discord for further assistance!
View Python SDK DocumentationThis feature is missing a code snippet or might not be supported yet.
Check the Go SDK documentation for more information.
Reach out on Discord for further assistance!
View Go SDK Documentation// Custom metadata of the NFT, note that you can fully customize this metadata with other properties.
var metadata =
new NFTMetadata()
{
name = "Cool NFT",
description = "This is a cool NFT",
image = "<your-image-url>"
};
var metadataWithSupply =
new NFTMetadataWithSupply() { metadata = metadata, supply = 1 };
var tx = await contract.ERC1155.Mint(metadataWithSupply);
Mint Additional Supply of an NFT
Make additional copies of an NFT that already exists.
- React
- Javascript
- Python
- Go
- Unity
const Component = () => {
const { contract } = useContract("{{contract_address}}");
const {
mutate: mintNftSupply,
isLoading,
error,
} = useMintNFTSupply(contract);
if (error) {
console.error("failed to mint additional supply", error);
}
return (
<button
disabled={isLoading}
onClick={() => mintNftSupply({ tokenId: 0, additionalSupply: 100, to: "{{wallet_address}}"})}
>
Mint Additional Supply!
</button>
);
};
This snippet is for v3 of the SDK. Learn how to upgrade.
View in React SDK Documentationconst tokenId = 0;
const additionalSupply = 1000;
await contract.erc1155.mintAdditionalSupply(tokenId, additionalSupply);
This snippet is for v3 of the SDK. Learn how to upgrade.
View in Javascript SDK DocumentationThis feature is missing a code snippet or might not be supported yet.
Check the Python SDK documentation for more information.
Reach out on Discord for further assistance!
View Python SDK DocumentationThis feature is missing a code snippet or might not be supported yet.
Check the Go SDK documentation for more information.
Reach out on Discord for further assistance!
View Go SDK Documentationvar tokenId = "0";
var additionalSupply = 1000;
await contract.ERC1155.MintAdditionalSupply(tokenId, additionalSupply);