Native ITEMs are different from wrapped ITEMs in that they have all of the awesome ITEM standard implementations as well as the ability to maintain extended functionalities.

Native ITEMs in a collection inherit the functionalities from the collection extension. Using the extension, you can expand the scope of an ITEM to anything made possible by Solidity.

Read more about ITEMs Collection extensions here: Build Collections

The basic hosting functions of a single ITEM, even if inherited by the collection, can also be removed for Mint and Metadata updates.

Single ITEM Hosting: Mint and Metadata

//Let's create and unload the metadata on IPFS
var IPFSHttpClient = require('ipfs-http-client');

var ipfs = new IPFSHttpClient();

var metadata = {
    licence_url : '',
    image : '',
    description : "My Item is the best on earth!"

var fileToUpload = [new Blob([JSON.stringify(metadata, null, 4)], { type: "application/json" })];

var metadataLink = "ipfs://ipfs/";
for await (var upload of ipfs.add(fileToUpload)) {
    metadataLink += upload.path;

//Now we can create a new objectId
var amountToMint = "100";
//Token name and symbol can be left blank. In that case, the collection ones will be used
var tokenName = "My awesome Item";
var tokenSymbol = "";

var objectUri = metadataLink;

//Editable true means that the host can mint more tokens later or change the uri.
var editable = true;

//Take the current block number, useful for search later
var blockNumber = web3.eth.getBlockNumber();

await, tokenName, tokenSymbol, objectUri, editable).send();

//Unfortunately, actually it is not possible to grab return types of Smart Contract from web3, so we need to search for the NewToken event in the blockchain to retrieve the new item
var logs = await web3.eth.getPastLogs({
    address : collection.addres,
    topics : [web3.utils.sha3("NewItem(uint256,address)")],
    fromBlock : blockNumber,
    toBlock : 'latest'

var collectionItemObjectId = web3.eth.abi.decodeParameter("uint256", logs[0].topics[1]);

//We've chosen editable = true, this means that we can now mint more tokens for this objectId

//Let's mint 100 more tokens
await collection.contract.methods['mint(uint256,uint256)'](collectionItemObjectId, amountToMint).send();

//Let's change the URI
metadata.licence_url = "";

fileToUpload = [new Blob([JSON.stringify(metadata, null, 4)], { type: "application/json" })];

metadataLink = "ipfs://ipfs/";
for await (var upload of ipfs.add(fileToUpload)) {
    metadataLink += upload.path;

await collection.contract.methods.setUri(collectionItemObjectId, metadataLink).send();

//And now let's make this item read only
await collection.contract.methods.makeReadOnly(collectionItemObjectId).send();

//From now on, for this single objectId, no more tokens can be minted and the token uri cannot be change anymore                 

Last updated