OnFinality
New RPC users get 35% off their first monthView the offer
OnFinality Learn
Network & Protocol Guides9 min read

ERC-1155 Tokens: Multi-Token Contracts, Transfers, and Developer Workflows

Understand how ERC-1155 tokens represent fungible, non-fungible, and semi-fungible assets and learn how to query, transfer, and verify them.

TL;DR

ERC-1155 is a token contract interface in which one deployed contract can manage many token IDs. Each ID can represent a fungible asset, a unique asset, or a semi-fungible asset whose supply and usage rules are defined by the application. The standard includes single and batch balance queries, transfers, approvals, metadata conventions, and receiver checks. This guide explains the data model, provides runnable JSON-RPC and JavaScript examples, and shows how to verify transfers without assuming that a token is visible in every wallet or explorer.

Direct scope and token model

ERC-1155 tokens are not one universal currency. ERC-1155 is a standard interface for a contract that manages multiple token types, identified by uint256 token IDs. A single contract may hold the state for game currencies, collectible items, tickets, membership units, or other assets.

The token ID determines which asset is being addressed, while the balance determines how many units an account owns. An application can treat an ID with a large supply as fungible, an ID with supply one as non-fungible, or an ID with a controlled supply as semi-fungible. These meanings are application rules rather than properties enforced solely by the interface.

For a practical starting point, review the ERC-1155 standard documentation alongside your contract's source code and deployment network. The standard describes interoperable functions; the implementation determines minting permissions, burning rules, supply accounting, metadata, and administrative controls.

  • One contract can represent many token IDs.
  • Balances are queried per account and per token ID.
  • A token ID is not globally unique across all ERC-1155 contracts.
  • The contract address and network are always part of an asset's identity.

ERC-1155 interface and mental model

The core interface resembles a combination of ERC-20-style quantities and ERC-721-style identifiers. balanceOf(account, id) returns the quantity of one ID, while balanceOfBatch(accounts, ids) returns several account-and-ID balances in one call. Transfers use safeTransferFrom for one ID and safeBatchTransferFrom for multiple IDs.

Approvals are set for an operator at the contract level with setApprovalForAll. This differs from an ERC-20 allowance, which normally specifies an amount for one spender, and from an ERC-721 approval, which can target an individual token ID. An ERC-1155 operator can act for all IDs held by an owner when approval is enabled, so applications should display and manage that permission carefully.

The standard emits TransferSingle and TransferBatch events. Minting is commonly represented by a transfer from the zero address, and burning by a transfer to the zero address, but an application should also inspect the contract's mint and burn logic before treating events as a complete supply record.

  • safeTransferFrom(from, to, id, value, data) transfers one token ID.
  • safeBatchTransferFrom(from, to, ids, values, data) transfers several IDs.
  • uri(id) exposes a metadata URI convention when implemented.
  • supportsInterface(interfaceId) helps clients detect supported interfaces through ERC-165.

Use cases and standard comparison

ERC-1155 is particularly useful when an application manages related assets together. A game might store gold, consumable items, equipment, and event rewards in one contract. A ticketing system might use one ID for a class of interchangeable tickets and another for a limited or individually tracked item.

The choice should follow the asset model rather than the popularity of a standard. ERC-20 remains a straightforward fit for one fungible balance type. ERC-721 is often clearer when each asset is individually represented and the surrounding ecosystem expects one token per identifier. ERC-1155 is attractive when many IDs share lifecycle logic or when batch operations are central.

A single contract does not automatically make every operation cheaper or faster. Gas depends on storage writes, calldata size, recipient behavior, event data, contract logic, and the network's fee rules. Treat efficiency as a hypothesis to measure for your workload, not as a guaranteed property.

  • Choose ERC-20 for a single fungible asset model.
  • Choose ERC-721 for individually identified assets with ERC-721-native integrations.
  • Choose ERC-1155 for multiple related asset types and batch-oriented workflows.
  • Check marketplace, wallet, indexing, and custody support before deployment.

Contract construction and safety boundaries

For production development, use a maintained library implementation or a carefully reviewed in-house implementation rather than copying an isolated code fragment. OpenZeppelin's ERC-1155 contracts documentation covers the base implementation and extensions; verify the version that matches your compiler and dependency lockfile.

A typical contract adds access control around minting and burning, defines how metadata URIs are formed, and exposes the required interface functions. It should also account for receiver checks: when tokens are sent to a contract, the recipient must implement the relevant ERC-1155 receiver interface and return the expected acceptance value.

Do not infer authorization from the token standard. ERC-1155 does not decide who can mint, pause, upgrade, or change metadata. Audit those controls, test malicious and rejecting receivers, validate array lengths in batch operations, and consider replay, reentrancy, and upgrade-administration risks in the surrounding application.

interface IERC1155Receiver {
    function onERC1155Received(
        address operator,
        address from,
        uint256 id,
        uint256 value,
        bytes calldata data
    ) external returns (bytes4);

    function onERC1155BatchReceived(
        address operator,
        address from,
        uint256[] calldata ids,
        uint256[] calldata values,
        bytes calldata data
    ) external returns (bytes4);
}

// A receiver should return the selector for the callback it accepted.
bytes4 constant ERC1155_ACCEPTED = 0xf23a6e61;
bytes4 constant ERC1155_BATCH_ACCEPTED = 0xbc197c81;

Read balances through JSON-RPC

The standard's read functions are ordinary EVM contract calls. You can query an ERC-1155 balance with eth_call against an RPC endpoint for the network where the contract is deployed. The example below encodes balanceOf(address,uint256) and decodes the returned 32-byte quantity without sending a transaction.

Replace every placeholder with values from the same network. CONTRACT_ADDRESS is the ERC-1155 contract, OWNER_ADDRESS is the account being inspected, and TOKEN_ID_DECIMAL is the token ID in decimal form. The function selector is derived from the ABI signature; the argument encoding uses 32-byte words for the address and ID.

RPC_URL="https://YOUR-RPC-ENDPOINT"
CONTRACT_ADDRESS="0xYourErc1155Contract"
OWNER_ADDRESS="0xOwnerAddress"
TOKEN_ID_DECIMAL="1"

python3 - <<'PY'
import os

def word(value):
    return value.replace("0x", "").lower().rjust(64, "0")

# keccak256("balanceOf(address,uint256)")[0:4] = 0x00fdd58e
calldata = "0x00fdd58e" + word(os.environ["OWNER_ADDRESS"]) + word(hex(int(os.environ["TOKEN_ID_DECIMAL"])))
print(calldata)
PY

# Export the variables before running the Python block if your shell does not
# automatically expose assignments to child processes.
export RPC_URL CONTRACT_ADDRESS OWNER_ADDRESS TOKEN_ID_DECIMAL
DATA=$(python3 - <<'PY'
import os

def word(value):
    return value.replace("0x", "").lower().rjust(64, "0")
print("0x00fdd58e" + word(os.environ["OWNER_ADDRESS"]) + word(hex(int(os.environ["TOKEN_ID_DECIMAL"]))))
PY
)
curl -s "$RPC_URL" \
  -H 'content-type: application/json' \
  --data "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"eth_call\",\"params\":[{\"to\":\"$CONTRACT_ADDRESS\",\"data\":\"$DATA\"},\"latest\"]}"

Send and verify a batch transfer

A state-changing transfer requires a signed transaction from the token owner or an approved operator. The following JavaScript example uses ethers to prepare a batch transfer, estimate gas, submit the transaction, and wait for a receipt. It assumes that PRIVATE_KEY belongs to an account authorized to transfer the selected balances and that the ABI matches the deployed contract.

Use a test network first. Never place a production private key in source control, shell history, shared notebooks, or client-side application code. A successful transaction receipt proves inclusion and execution; it does not by itself prove that an indexer, wallet, or marketplace has refreshed its view.

import "dotenv/config";
import { ethers } from "ethers";

const provider = new ethers.JsonRpcProvider(process.env.RPC_URL);
const signer = new ethers.Wallet(process.env.PRIVATE_KEY, provider);
const abi = [
  "function safeBatchTransferFrom(address from,address to,uint256[] ids,uint256[] values,bytes data)",
  "function balanceOfBatch(address[] accounts,uint256[] ids) view returns (uint256[])"
];

const token = new ethers.Contract(process.env.ERC1155_CONTRACT, abi, signer);
const ids = [1n, 7n];
const values = [2n, 1n];
const recipient = process.env.RECIPIENT;

const before = await token.balanceOfBatch(
  [signer.address, signer.address],
  ids
);
console.log("sender balances before:", before.map(String));

const tx = await token.safeBatchTransferFrom(
  signer.address,
  recipient,
  ids,
  values,
  "0x"
);
console.log("submitted:", tx.hash);
const receipt = await tx.wait();
console.log("mined in block:", receipt.blockNumber);

const after = await token.balanceOfBatch(
  [signer.address, recipient],
  ids
);
console.log("sender and recipient balances after:", after.map(String));

Verification workflow and measurement table

Test caseRPC URL labelRequests or IDsMedian latencyp95 latencyError rateBlock consistencyNotes
Single balanceOfendpoint-a1—————
balanceOfBatchendpoint-aN IDs—————
Batch transfer receiptendpoint-aN IDs—————

  • Run enough repetitions to reduce the effect of transient network conditions.
  • Use the same block tag when comparing historical reads.
  • Separate client-side encoding time from network round-trip time.
  • Record throttling, timeouts, retries, and malformed-response errors separately.

Troubleshooting incomplete or unexpected results

A zero balance can be correct even when a token appears in an explorer. Check the exact network, contract address, owner address, and token ID. Token IDs are numeric values, and an explorer's display name or metadata label is not a substitute for the on-chain ID.

If a transfer reverts, inspect the revert data and confirm that the sender has enough units, the caller is the owner or approved operator, and the recipient address is not a rejecting contract. For batch calls, verify that the IDs and values arrays are equal in length and that custom application constraints do not reject one item in the batch.

If a wallet does not display the asset, distinguish custody from presentation. The balance may exist on-chain even when the wallet has not indexed the contract, resolved uri(id), supported the metadata format, or recognized the network. Query the contract directly and inspect logs before concluding that the transfer failed.

For missing events or inconsistent reads, compare the transaction's receipt block with the block used by the balance query. A node or indexer may be behind the latest chain head. Review RPC endpoint guidance and use the OnFinality RPC service when you need a documented endpoint configuration for your environment.

  • Wrong network or contract address
  • Incorrect decimal-to-hex token ID encoding
  • Insufficient balance or missing operator approval
  • Receiver callback rejection
  • Indexer, wallet, or metadata propagation delay
  • Reading different block states during verification

Operational limits and design tradeoffs

ERC-1155 standardization improves interface compatibility but does not standardize every application convention. Metadata schemas, URI substitution rules, total-supply tracking, royalties, access control, pausability, upgradeability, and mint authorization can vary substantially between contracts.

Batching can reduce transaction overhead when several IDs are already known and the recipient and authorization model are shared. It can also make failures less granular: one invalid item may revert the entire call, and large arrays increase calldata and execution work. Test realistic batch sizes rather than assuming that the largest possible batch is best.

A shared contract can simplify deployment and indexing, but it creates a broader blast radius for implementation or administration errors. Consider immutable versus upgradeable deployment, role separation, emergency procedures, metadata permanence, and how marketplaces or custodians will identify each ID.

For workloads that require predictable isolation, high-volume archival access, or dedicated capacity, compare the operational model with dedicated node options and review current RPC pricing. These are infrastructure decisions, not properties guaranteed by ERC-1155 itself.

Next implementation steps

Begin with a test deployment and write down the contract address, network, compiler and library versions, token ID definitions, minting roles, and metadata policy. Add tests for single transfers, batch transfers, operator approval, rejected receivers, zero-address mint and burn events, and malformed array inputs.

Build verification into the application rather than relying only on a wallet interface. Store transaction hashes, decode receipts, query balances at an explicit block when appropriate, and make indexing lag visible to users. For historical ownership or supply analytics, consume transfer events with reorganization handling instead of repeatedly polling only the latest balance.

Before production launch, load-test the exact read and write patterns, review key management, validate the chosen RPC configuration, and document recovery procedures. The multi-chain RPC guide can help organize endpoint selection when the same ERC-1155 application is deployed across multiple EVM networks.

  • Confirm standard compliance with interface and receiver tests.
  • Validate metadata and token ID behavior across the target wallets and indexers.
  • Measure single versus batch operations using your own contract and workload.
  • Monitor transaction inclusion, reverts, RPC errors, and indexing freshness.
  • Keep contract addresses and network identifiers explicit in every integration.

Never Worry about Infrastructure Again

OnFinality takes away the heavy lifting of DevOps so you can build smarter and faster.

Get Started