How to use the Vottun NFT API to deploy an ERC1155 contract

The ERC1155 standard is a powerful way to create NFTs that is more efficient and flexible than traditional ERC721 tokens. With ERC1155, you can create multiple types of NFTs within a single contract, reducing gas costs and making it easier to manage your tokens.

1

In this tutorial, we’ll show you how to use the Vottun NFT API to deploy an ERC1155 contract, mint new tokens, and transfer them to different addresses. We’ll provide step-by-step instructions and sample code to make it easy for you to get started.

By the end of this tutorial, you’ll have a solid understanding of how to use the Vottun NFT API and the ERC1155 standard to create and manage your own NFTs.

Here are the steps we are going to follow to deploying a ERC1155 token:

1- Get your credentials to be able to use the APIs.

2- Be clear about the number of tokens and the quantity of each of them that you are going to deploy. 

3- Upload your digital assets to IPFS using our APIs. 

4- Add the url of the folder of your assets and the token id-s you are going to mint in the deployment of the contract.

How to get my credentials

If still you do not get your free 30 days trial token you can obtain it following the steps described in the following article

The NFTs:

In order to create your tokens it is necessary to consider the same aspects described in the previously mentioned article but you must take into consideration that as you are going to work with multiple assets you are going to manage folders in IPFS.

Let’s make an example with the following 3 images:

Upload Files To Ipfs

First of all we have to do a ZIP file with the digital assets we are going to upload to IPFS. We have to upload it using the following API and this will create a directory in IPFS. The API will return the URL of it.

Its content type must be multipart/form-data and it is necessary to add the recently created ZIP file to the call:

  • file: the file ZIP itself

The endpoint for uploading the ZIP file:

https://ipfsapi-v2.vottun.tech/ipfs/v2/upload/zip

The API will return the following result that contains the IPFS url to the folder where the assets are:

The complete call launched from curl:

Now, we have the url of the directory in IPFS. The different assets will be accessible if we append the file name of the file to the url. For example:

With the urls of the three assets we are going to work with, we have to create the metadata for each asset. The metadata has to be created following the same steps described in the ERC721 article. The following example is the metadata for one of the assets. 

Once we have the metadata files for each media file, we have to create a zip file with them and use the same API of the previous step to upload it to IPFS.

The API will return the following result that contains the IPFS url to the folder that contains the metadata files:

Deploy The Contract And Mint Tokens

Now we are ready to mint our tokens, but first we need to deploy our ERC1155 contract. With the Vottun API it is possible to make a deployment of the contract and the minting of the NFTs on a single API call. For this example we are going to use Avalanche network and remember you have all the information https://developers.vottun.tech

The end point for the deployment is:

https://api.vottun.tech/nft/v2/erc1155/deploy

It is a POST call and it is necessary to send the following message in a JSON format. Let’s see the parameters one by one:

  • Name: The name that is going to appear as the collection name in marketplaces
  • BlockchainNetwork: the network ID of the blockchain of your choice
  • GasLimit: The gas limit to use
  • IDs: the token ids of the tokens that are going to be minted
  • Quantities: the quantity of each token that is going to be minted
  • RoyaltyRecipient: the account that is going to receive the royalty of each sale.
  • Alias: an alias to use by the user. 

The complete call launched from curl:

The API answer should be as follow:

It is very interesting to see in the blockchain explorer the transaction. You can see both the contract deployment and the minting of the amount of tokens we express in the API call:

Transfer Tokens

With the contract deployed and the tokens minted it is possible to transfer one or more tokens to the wallet we want. Actually this is one of the most powerful features of the ERC-1155. Lets see how to transfer to different tokens. 

The end point for the transferring tokens is:

https://api.vottun.tech/nft/v3/erc1155/transfer

It is a POST call and it is necessary to send the following message in a JSON format. Let’s see what is each parameter:

  • contractAddress: the blockchain address of the contract
  • from: the address of the current owner of the token
  • to: the address of the receiver 
  • ids: the token id-s of the tokens we are going to send
  • quantities: the quantity of each token
  • blockchainNetwork: the network id

The complete call launched from curl:

We obtain the following answer from the API. The id is an identifier for the operation we are performing and we can check the status of it with another API call. We do not receive the result of the transference because the operation is done in an asynchronous way.

If we use the following endpoint we will be able to check the status of the operation:

https://api.vottun.tech/nft/v3/operation/9246ccba-942b-479c-a5b3-66c59280ec2b

We will receive an answer similar to the following:

In which the most important is the statusId, which returns a 4 (a 5 means that there has been an error and another value means that the process has not finished), means that everything went well and also the transactionHash, with which we can check its status in the avalanche testnet explorer:

https://testnet.snowtrace.io/tx/0xc8388bfbc0e87f519c69ddad15f5ad3e8b063d7f52fe081bdc1cedb989c52c78

Conclusions

In this article we learn:

  • The difference between the ERC721 and ERC1155
  • How to upload a zip file with multiple media assets and multiple metadata files to IPFS
  • Deploy and mint a ERC-1155 contract and multiple tokens with a single API call.
  • Transfer multiple tokens.
  • Check the status of an operation.

In future articles we are going to go deeper into Vottun APIs and different standards such as rental NFTs (ERC4907).