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
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:
b) Next, create a file named NFT_1155.sol
under the contracts
folder.
c) Lastly, add the following smart contract to NFT_1155.sol
file.
2. Install Hardhat Deploy
3. Install an Ethereum library
In this example, we will use Ether.js
4. Set environment variables with dotenv
- Install
dotenv
- Create a
.gitignore
file
A great example of a Solidity .gitignore file can be found here
- Create an
.env
file n your project’s root folder, and set environment variables in the file as follows
PRIVATE_KEY = #The private key of the account you intend to use on the Palm network INFURA_API_KEY = #Your Infura API key
5. Edit hardhat.config.js
with the following text:
- You can add additional supported fields on the
hardhat.config.js
file.
6. Compile your Contract
To make sure everything is working so far, let’s compile our contract:
7. Write a deploy script
a) Navigate to the scripts
folder and create a new file called deploy_NFT_1155.js
b) Add the below code
8. Deploy to the target Palm network environment
-
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://testnet.palm.chainlens.com/ | https://palm.chainlens.com/ |
Paste your contract address into the search bar.
You will see something like this upon successful deployment 👇
10. Verify via Sourcify
Next Step 👉 Mint your NFT
Using the Smart Contract you just deployed you can now Mint NFTs with Hardhat