How to Create MultiToken Collections (SDK)
This guide covers how to create MultiToken NFT Collection (ERC-1155 type) on the Ethereum network
Use the TatumSDK (@tatumio/tatum
) to get a transaction history of the wallet.
// yarn add @tatumio/tatum
import {TatumSDK, Network, Ethereum, ResponseDto} from '@tatumio/tatum'
const tatum = await TatumSDK.init<Ethereum>({network: Network.ETHEREUM})
const tx: ResponseDto<{txId: string}> = await tatum.nft.createMultiTokenNftCollection({
owner: '0x727ea45b2eb6abb2badd3dc7106d146e0dc0450d', // replace with your address
})
console.log(tx.data.txId)
// 0x8e564406701caab6258501c794f5c1eece380f673be99b561d626c3d8d81b202
// you can get created collection address using this RPC call
const collectionAddress = await tatum.rpc.getContractAddress(tx.data.txId)
console.log(collectionAddress)
// 0x876977006988ce590e219f576077459a49c7318a
// Install with: npm install @tatumio/tatum
const { TatumSDK, Network } = require("@tatumio/tatum");
(async () => {
try {
const tatum = await TatumSDK.init({ network: Network.ETHEREUM });
const txs = await tatum.nft.createMultiTokenNftCollection({
owner: '0x727ea45b2eb6abb2badd3dc7106d146e0dc0450d', // replace with your address
});
console.log(txs.data.txId);
// 0x8e564406701caab6258501c794f5c1eece380f673be99b561d626c3d8d81b202
const collectionAddress = await tatum.rpc.getContractAddress(tx.data.txId);
console.log(collectionAddress);
// 0x876977006988ce590e219f576077459a49c7318a
} catch (error) {
console.error("Error creating NFT collection:", error);
}
})();
curl --location --request POST 'https://api.tatum.io/v4/contract/deploy' \
--header 'Content-Type: application/json' \
--data-raw '{
"contractType": "multitoken",
"chain": "ethereum-sepolia",
"owner": "0x727ea45b2eb6abb2badd3dc7106d146e0dc0450d"
}'
Request interface
export interface CreateMultiTokenNftCollection {
/**
* Address of the NFT collection owner
*/
owner: string
/**
* Address of the NFT collection minter, this is optional and defaults to the owner address
*/
minter?: string
/**
* Optional base URI, which will be prepended to the token URI. If not specified, the token should be minted with the URI
*/
baseURI?: string
}
Response interface
interface ResponseDto<{txId: string}> {
/**
* Actual payload of the response
*/
data: {txId: string}
/**
* Status of the response
*/
status: Status
/**
* In case of ERROR status, this field contains the error message and detailed description
*/
error?: ErrorWithMessage
}
Updated 5 months ago