Create an ERC1155

A very simple example on how to deploy/access your own ERC-1155 contract aka Multi Token Contract.

In order to instantiate the ERC1155 you will need to provide a Web3Connection instance object or a Web3ConnectionOptions

import { ERC1155Standard, Web3Connection } from '@taikai/dappkit';

/* Create your web3Connection */
const web3Connection = new Web3Connection({ 
 web3Host: 'WEB3_LINK',
 /* privateKey: '' */
});

await web3Connection.start();
await web3Connection.connect(); // if a privateKey was provided, can be ignored

/* Create an ERC1155Standard Deployer */
const deployer = new ERC1155Standard(web3Connection);

/* Deploy the ERC1155 Contract */
await deployer.loadAbi();
const tx = await deployer.deployJsonAbi('http://localhost:1337/');
 
/* Instantiate and use your new ERC1155 Token Contract*/
const erc1155Contract = new ERC1155Standard(web3connection, tx.contractAddress);
await erc1155Contract.start();

erc1155Contract.mint('0xTO_ADDRESS', 0, 1000, '0x12345678');

If you prefer your contract to be ownable, you can appeal to the erc-1155 ownable version:

import { ERC1155Ownable, Web3Connection } from '@taikai/dappkit';

/* Create your web3Connection */
const web3Connection = new Web3Connection({ 
 web3Host: 'WEB3_LINK',
 /* privateKey: '' */
});

await web3Connection.start();
await web3Connection.connect(); // if a privateKey was provided, can be ignored

/* Create an ERC1155Ownable Deployer */
const deployer = new ERC1155Ownable(web3Connection);

/* Deploy the ERC1155 Contract */
await deployer.loadAbi();
const tx = await deployer.deployJsonAbi('http://localhost:1337/');
 
/* Instantiate and use your new ERC1155 Token Contract*/
const erc1155Contract = new ERC1155Ownable(web3connection, tx.contractAddress);
await erc1155Contract.start();

erc1155Contract.mint('0xTO_ADDRESS', 0, 1000, '0x12345678');

Looking for more functions?

See all available functions here

Last updated