What ERC1155 defines
An ERC1155 contract stores balances by token ID and owner. One ID can be a currency with a large supply, and another can be a unique item. safeBatchTransferFrom moves several IDs at once, which saves gas compared with one ERC20 or ERC721 call per token.
Token IDs become mints
Create one mint for each ERC1155 token ID. Every mint uses the same Token Program, so adding a token type is a transaction and needs no deployment. If you have not read the ERC20 guide, it explains mints and token accounts.
| ERC1155 token type | Solana mint |
|---|---|
| Fungible ID, such as a currency | A mint with decimals and a large supply |
| Semi-fungible ID, such as a stackable item | A mint with 0 decimals and a supply above 1 |
| Non-fungible ID | A mint with 0 decimals and a supply of 1, or a Metaplex Core asset |
ERC1155 functions on Solana
Replace the token ID argument with the mint address.
balanceOf(owner, id)balanceOfBatch()getMultipleAccounts.safeTransferFrom()TransferCheckedsafeBatchTransferFrom()setApprovalForAll()uri(id)uriBatch transfers
A batch transfer is a list of transfer instructions in one transaction. They run in order and atomically: if one fails, none of them applies.
const instructions = [
// Token ID 1: a stackable item with 0 decimals
getTransferCheckedInstruction({
source: potionSource,
mint: potionMint,
destination: potionDestination,
authority: sender,
amount: 50n,
decimals: 0,
}),
// Token ID 2: a unique item
getTransferCheckedInstruction({
source: swordSource,
mint: swordMint,
destination: swordDestination,
authority: sender,
amount: 1n,
decimals: 0,
}),
];Collections and metadata
An ERC1155 contract address groups its token IDs. On Solana, mints are independent, so you link them with metadata: