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
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.
Deployment with Foundry
Deployment with Hardhat
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: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
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://base-sepolia-testnet-explorer.skalenodes.com/api
Step 0: Setup Hardhat
If your Hardhat project isn’t set up yet, go to the Hardhat setup section before proceeding.Step 1: Create the ERC-1155 Contract
Create a contract script in contracts/MyERC721.sol. Run:touch contracts/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 {
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
Step 3: Create a Deployment Script
Create a deployment script in scripts/deploy_erc1155.sol. Run:touch scripts/deploy_erc1155
Add the deployment code: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
Step 5: Deploy to SKALE
npx hardhat run scripts/deploy_erc1155.js --network skale_testnet
SKALE-Specific Considerations
-
Transaction Types
Hardhat usually handles this automatically, but ensure your version supports legacy transactions if required.
-
Gas Configuration
networks: {
skale_testnet: {
url: "...",
accounts: [...],
gasPrice: 0, // SKALE gas is always zero
},
},
- Contract Verification
npx hardhat verify --network skale_testnet <CONTRACT_ADDRESS> <CONSTRUCTOR_ARGS>