> ## Documentation Index
> Fetch the complete documentation index at: https://docs.skale.space/llms.txt
> Use this file to discover all available pages before exploring further.

# Deploy an ERC-1155 Token

> Step-by-step guide to deploying an ERC-1155 (Multi-Token Standard) on SKALE using Foundry or Hardhat with OpenZeppelin Contracts

## 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.

<Tabs>
  <Tab title="Deployment with Foundry">
    <Note title="Setup Foundry">
      ## Step 0: Setup Foundry

      If your Foundry project isn't set up yet, please go to the [Foundry setup section](../deployment/setup-foundry) before proceeding.
    </Note>

    ## Step 1: Create the ERC-1155 Contract

    Create a contract script in `src/MyERC721.sol`. Run:

    ```shell theme={null}
    touch src/MyERC1155.sol
    ```

    Add the contract code:

    ```solidity theme={null}
    // 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

    <Note>
      The URI string uses `{id}` as a placeholder that will be replaced automatically by compatible metadata servers.
    </Note>

    ## Step 2: Compile the Contract

    ```shell theme={null}
    forge build
    ```

    ## Step 3: Prepare Signer for Deployment

    Create a Foundry keystore:

    ```shell theme={null}
    cast wallet import skale-deployer --private-key $(cast wallet new | grep 'Private key:' | awk '{print $3}')
    ```

    <Note>
      Be sure to store your keystore password securely — it cannot be recovered.
    </Note>

    Retrieve your wallet address:

    ```shell theme={null}
    cast wallet address --account skale-deployer
    ```

    Visit the [sFUEL Station](https://www.sfuelstation.com/), toggle testnet, and fill up your SKALE deployer wallet.

    <Tip>
      Always toggle testnet first when using testnet chains!
    </Tip>

    ## Step 4: Deploy the Contract

    ```shell theme={null}
    forge create src/MyERC1155.sol:MyERC1155 \
        --account skale-deployer \
        --rpc-url skale_testnet \
        --broadcast \
        --legacy
    ```

    <Note>
      The `--legacy` flag is required for SKALE deployments.
    </Note>

    Example output:

    ```shell theme={null}
    Enter keystore password:
    Deployer: 0x63a38D694de837dDF765f9b2704814275586D812
    Deployed to: 0x4A435f6E471f773173774E860EBDcd17B132a2b4
    Transaction hash: 0x3f6cc66e860cb82a6a62e3f5181c401e5558d60d622a9157437002e16c1ce488
    ```

    ## Step 5: Verify Your Smart Contract

    ```shell theme={null}
    forge verify-contract \
        --rpc-url skale_testnet \
        <DEPLOYED_ADDRESS> \
        src/MyERC1155.sol:MyERC1155 \
        --verifier blockscout \
        --verifier-url https://base-sepolia-testnet-explorer.skalenodes.com/api
    ```
  </Tab>

  <Tab title="Deployment with Hardhat">
    <Note title="Setup Hardhat">
      ## Step 0: Setup Hardhat

      If your Hardhat project isn't set up yet, go to the [Hardhat setup section](../deployment/setup-hardhat) before proceeding.
    </Note>

    ## Step 1: Create the ERC-1155 Contract

    Create a contract script in `contracts/MyERC721.sol`. Run:

    ```shell theme={null}
    touch contracts/MyERC1155.sol
    ```

    Add the contract code:

    ```solidity theme={null}
    // SPDX-License-Identifier: MIT
    pragma solidity ^0.8.19;

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

    contract MyERC1155 is ERC1155 {
        constructor() ERC1155("https://myapi.com/api/token/{id}.json") {}

        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, "");
        }
    }
    ```

    ## Step 2: Compile Contracts

    ```shell theme={null}
    npx hardhat compile
    ```

    ## Step 3: Create a Deployment Script

    Create a deployment script in `scripts/deploy_erc1155.sol`. Run:

    ```shell theme={null}
    touch scripts/deploy_erc1155
    ```

    Add the deployment code:

    ```javascript theme={null}
    const hre = require("hardhat");

    async function main() {
        const MultiToken = await hre.ethers.getContractFactory("MyERC1155");
        const multi = await MultiToken.deploy();

        await multi.waitForDeployment();

        console.log("Contract deployed to:", await multi.getAddress());
    }

    main().catch((error) => {
        console.error(error);
        process.exit(1);
    });
    ```

    ## Step 4: Run Tests

    ```shell theme={null}
    npx hardhat test
    ```

    ## Step 5: Deploy to SKALE

    ```shell theme={null}
    npx hardhat run scripts/deploy_erc1155.js --network skale_testnet
    ```

    ## SKALE-Specific Considerations

    1. **Transaction Types**\
       Hardhat usually handles this automatically, but ensure your version supports legacy transactions if required.

    2. **Gas Configuration**

    ```javascript theme={null}
    networks: {
        skale_testnet: {
            url: "...",
            accounts: [...],
            gasPrice: 0, // SKALE gas is always zero
        },
    },
    ```

    3. **Contract Verification**

    ```shell theme={null}
    npx hardhat verify --network skale_testnet <CONTRACT_ADDRESS> <CONSTRUCTOR_ARGS>
    ```
  </Tab>
</Tabs>

## Related Topics

* [Solidity Quickstart](/developers/solidity-quickstart)
* [Deploy on SKALE](/developers/deploy-on-skale)
* [Deploy an ERC-20 Token](/cookbook/smart-contracts/deploy-erc20-token)
* [Deploy an ERC-721 Token](/cookbook/smart-contracts/deploy-erc721-token)
* [Troubleshooting](/developers/troubleshooting)
