website logo
Join the CommunityContact Us
Navigate through spaces
Main
⌘K
Palm Network Developer Portal
The Palm Network
Submit an Article
Network Details
Validators
Get Started
Get PALM Tokens
Gas Fees
Connect to Palm network
Run a Transaction Node
How To Tutorials
MetaMask Wallet Setup
Deploy NFT Contracts
Verifying NFT Contracts
Mint NFTs with Hardhat
Bridge
Use the Bridge
Integrate With the Bridge
Bridge Component Addresses
Deprecated
Use Supported Tools
Block Explorer
Moralis
The Graph
Covalent API
Docs powered by archbee 
40min

ERC-1155

Overview

Pros

  • Allows for the creation of multiple types of tokens within a single contract.
  • Supports both fungible and non-fungible tokens.
  • More efficient and cost-effective for creating a wide range of NFTs.

Cons

  • Relatively new and complex standard.
  • Limited support from Ethereum wallets and exchanges.
  • Requires advanced development skills to implement.

🏁 Prerequisites

  • Using Hardhat Intro

Tutorial

1. Write your ERC-1155 contract

We'll use a contract based on the OpenZeppelin library’s [ERC-1155 implementation]().

a) First, install the Open Zeppelin library in order to inherit its classes:



Shell
|



b) Next, create a file named NFT_1155.sol under the contracts folder.

Document image

c) Lastly, add the following smart contract to NFT_1155.sol file.

Note that we have named our contract NFT_1155, this can be any name. The name will be important in the next step.



JS
|

2. Install Hardhat Deploy

Shell
|

3. Install an Ethereum library

In this example, we will use Ether.js

Shell
|

4. Set environment variables with dotenv

  • Install dotenv
Shell
|

Keep Your Private Keys Secret Private keys must be kept secret and not committed to any code repository. In the example of this tutorial, the .env file should be added to your .gitignore file and kept local. For example, see MyCrypto's Protecting Yourself and Your Funds guide.



  • Create a .gitignore file

A great example of a Solidity .gitignore file can be found here

Document image
  • Create an .env file n your project's root folder, and set environment variables in the file as follows
    • Intro to Infura
    • MetaMask Wallet Setup
PRIVATE_KEY = #The private key of the account you intend to use on the Palm network INFURA_API_KEY = #Your Infura API key
Document image



5. Edit hardhat.config.js with the following text:

  • You can add additional supported fields on the hardhat.config.js file.
JS
|



6. Compile your Contract

To make sure everything is working so far, let’s compile our contract:

Shell
Example Response
|

7. Write a deploy script

a) Navigate to the scripts folder and create a new file called deploy_NFT_1155.js

Document image

b) Add the below code

JS
|

8. Deploy to the target Palm network environment

Palm Testnet
Palm Mainnet
Example log
|



  • TLDR; How This is Working
  • The task will execute the scripts in the scripts folder and saves the contract deployments to disk. Each deployment is saved into the deployments folder for the specific network.

9. Look Up Your Deployment on the Palm Network Block Explorer



Testnet

Mainnet

Explorer URL

https://explorer.palm-uat.xyz

https://explorer.palm.io

Paste your contract address into the search bar.



Get your contract address in 2 ways:

  • Console.log() output Contract deployed to address: contractNumber
  • In deployments/palm_testnet/NFT_1155.json or deployments/palm_mainnet/NFT_1155.json where you will also find the ABI (Application Binary Interface) information.



You will see something like this upon successful deployment 👇

Document image

10. Verify via Sourcify

Palm Testnet
Palm Mainnet
Example log
|
  • More ways to verify

Next Step 👉 Mint your NFT

Using the Smart Contract you just deployed you can now Mint NFTs with Hardhat

Updated 22 Dec 2022
Did this page help you?
Yes
No
UP NEXT
Using Truffle
Docs powered by archbee 
TABLE OF CONTENTS
Overview
🏁 Prerequisites
Tutorial
1. Write your ERC-1155 contract
2. Install Hardhat Deploy
3. Install an Ethereum library
4. Set environment variables with dotenv
5. Edit hardhat.config.js with the following text:
6. Compile your Contract
7. Write a deploy script
8. Deploy to the target Palm network environment
9. Look Up Your Deployment on the Palm Network Block Explorer
10. Verify via Sourcify
Next Step 👉 Mint your NFT