Search
⌃K
Links

Create your NFT (ERC-1155 MultiToken) Collection

MetaMask is a widely used Ethereum wallet that allows users to manage their Ether and ERC-20 tokens. It also provides an interface for interacting with decentralized applications (dApps) and smart contracts. With the growing popularity of non-fungible tokens (NFTs), you can now leverage MetaMask to create your very own NFT collection contract, opening up a world of opportunities and benefits.

Why create an NFT collection contract?

NFTs represent unique digital assets that can't be exchanged on a one-to-one basis, differentiating them from other cryptocurrencies. Creating an NFT collection contract allows you to mint, trade, and showcase a series of unique digital items, such as art, collectibles, virtual real estate, or game items. These contracts facilitate the management of your NFT collection, defining rules for minting, transferring, and managing the ownership of your tokens.
MetaMask is designed as a browser extension to provide a user-friendly interface and secure key management for interacting with dApps and web services. Connecting from Node.js is not supported because MetaMask focuses on end-user interactions within web browsers, while Node.js is a server-side JavaScript runtime typically used for backend development.

How to create your NFT (ERC-1155 MultiToken) collection with MetaMask from your browser-based application

Use the TatumSDK (@tatumio/tatum) to prepare, sign and broadcast the transaction using MetaMask.
You will leverage the WalletProvider submodule, which includes multiple browser-based wallet extensions. MetaMask is just one of them.
TypeScript
JavaScript
1
// yarn add @tatumio/tatum
2
import {TatumSDK, Network, Ethereum} from '@tatumio/tatum'
3
​
4
const tatum = await TatumSDK.init<Ethereum>({network: Network.ETHEREUM})
5
​
6
// We have prepared a deploy transaction of ERC-1155 contract from your default connected MetaMask account to the recipient
7
// Result is a transaction IF of a broadcasted transaction
8
const txId: string = await tatum.walletProvider.metaMask.createErc1155NftCollection()
9
​
10
console.log(txId)
11
​
12
// Once the transaction is included in a block, you can get the contract address of the newly created collection
13
const contractAddress: string | null = await tatum.rpc.getContractAddress(txId)
14
console.log(contractAddress)
1
// Install with: npm install @tatumio/tatum
2
const { TatumSDK, Network } = require("@tatumio/tatum");
3
​
4
(async () => {
5
try {
6
const tatum = await TatumSDK.init({ network: Network.ETHEREUM });
7
// We have prepared a deploy transaction of ERC-1155 contract from your default connected MetaMask account to the recipient
8
// Result is a transaction IF of a broadcasted transaction
9
const txId = await tatum.walletProvider.metaMask.createErc1155NftCollection();
10
11
console.log(txId);
12
13
// Once the transaction is included in a block, you can get the contract address of the newly created collection
14
const contractAddress: string | null = await tatum.rpc.getContractAddress(txId)
15
console.log(contractAddress)
16
} catch (error) {
17
console.error("Error signing a transaction using MetaMask:", error);
18
}
19
})();

Request parameters

1
export interface CreateErc1155NftCollection {
2
/**
3
* base URI of the collection, defaults to empty string. Base URI is prepended to the token ID in the token URI.
4
*/
5
baseURI?: string
6
/**
7
* (Optional) Address of the admin of the token. Defaults to the connected MetaMask account. Admin can add new minters and pausers.
8
*/
9
author?: string
10
/**
11
* (Optional) Address of the minter of the token. Defaults to the connected MetaMask account. Minters can mint new tokens.
12
*/
13
minter?: string
14
}
15
​

Response

  • txId - string, transaction hash of signed and broadcasted transaction
    • Example: "0xdb1e03f4cea29265f031bfc0514b07c15a5fc5e5cc2fd47f7d9a54c74f5c5637"
© Tatum Technology, LLC