Skip to main content

Deploy an ERC-1155 Token

OpenZeppelin provides secure, community-vetted smart contract templates that follow best practices for ERC-1155 multi-token contracts. ERC-1155 enables you to deploy multiple fungible and non-fungible tokens from a single contract — ideal for gaming, collectibles, and multi-asset systems.

Step 0: Setup Foundry

If your Foundry project isn’t set up yet, please go to the Foundry setup section before proceeding.

Step 1: Create the ERC-1155 Contract

Create a contract script in src/MyERC721.sol. Run:
touch src/MyERC1155.sol
Add the contract code:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";

contract MyERC1155 is ERC1155 {
    // Token IDs
    uint256 public constant GOLD = 0;
    uint256 public constant SILVER = 1;
    uint256 public constant SWORD = 2;
    uint256 public constant SHIELD = 3;

    constructor() ERC1155("https://myapi.com/api/token/{id}.json") {
        // Initial supply
        _mint(msg.sender, GOLD, 1000, "");
        _mint(msg.sender, SILVER, 500, "");
        _mint(msg.sender, SWORD, 1, "");
        _mint(msg.sender, SHIELD, 1, "");
    }

    function mint(address to, uint256 id, uint256 amount) public {
        _mint(to, id, amount, "");
    }

    function mintBatch(
        address to,
        uint256[] memory ids,
        uint256[] memory amounts
    ) public {
        _mintBatch(to, ids, amounts, "");
    }
}
This contract:
  • Inherits OpenZeppelin’s ERC1155
  • Supports multiple token types
  • Sets a metadata URI using {id} placeholders
  • Implements single & batch minting
  • Mints initial supply on deployment
The URI string uses {id} as a placeholder that will be replaced automatically by compatible metadata servers.

Step 2: Compile the Contract

forge build

Step 3: Prepare Signer for Deployment

Create a Foundry keystore:
cast wallet import skale-deployer --private-key $(cast wallet new | grep 'Private key:' | awk '{print $3}')
Be sure to store your keystore password securely — it cannot be recovered.
Retrieve your wallet address:
cast wallet address --account skale-deployer
Visit the sFUEL Station, toggle testnet, and fill up your SKALE deployer wallet.
Always toggle testnet first when using testnet chains!

Step 4: Deploy the Contract

forge create src/MyERC1155.sol:MyERC1155 \
    --account skale-deployer \
    --rpc-url skale_testnet \
    --broadcast \
    --legacy
The --legacy flag is required for SKALE deployments.
Example output:
Enter keystore password:
Deployer: 0x63a38D694de837dDF765f9b2704814275586D812
Deployed to: 0x4A435f6E471f773173774E860EBDcd17B132a2b4
Transaction hash: 0x3f6cc66e860cb82a6a62e3f5181c401e5558d60d622a9157437002e16c1ce488

Step 5: Verify Your Smart Contract

forge verify-contract \
    --rpc-url skale_testnet \
    <DEPLOYED_ADDRESS> \
    src/MyERC1155.sol:MyERC1155 \
    --verifier blockscout \
    --verifier-url https://juicy-low-small-testnet.explorer.testnet.skalenodes.com/api

Next Steps

Congratulations! You’ve successfully deployed an ERC-1155 multi-token contract on SKALE. You can now:
  • Mint fungible and non-fungible tokens
  • Batch mint or transfer multiple token types
  • Build advanced games, inventories, or multi-asset dApps
  • Use metadata per token ID