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

# ERC-1155 (Multi-Tokens)

ERC-1155 tokens support both unique and stackable assets in one contract. Multiple copies of an item share the same token ID, making them ideal for consumables, crafting materials, and editions.

## Why Use ERC-1155?

<AccordionGroup>
  <Accordion title="Efficient Batching" icon="layer-group">
    Transfer multiple token types in a single transaction. Perfect for loot drops, rewards, and crafting systems.
  </Accordion>

  <Accordion title="Flexible Token Types" icon="shuffle">
    Mix fungible (stackable) and non-fungible (unique) tokens in one contract. No need for multiple contracts.
  </Accordion>

  <Accordion title="Lower Gas Costs" icon="gas-pump">
    More efficient storage and batch operations mean lower costs for games with many item types.
  </Accordion>

  <Accordion title="Stackable Inventory" icon="boxes-stacked">
    Players can hold 100 health potions as one balance entry, not 100 separate NFTs.
  </Accordion>
</AccordionGroup>

## Use Cases

* **Consumables**: Potions, ammo, food
* **Crafting Materials**: Ore, wood, gems
* **Editions**: Limited prints of artwork
* **Loot Boxes**: Reward bundles
* **Event Tickets**: Time-limited access tokens

## Deploy via Hub

<Card title="Deploy Contracts" icon="file-contract" href="/docs/products/hub/deploy-contracts">
  Deploy ERC-1155 contracts in Hub
</Card>

## Metadata

```json theme={null}
{
  "name": "Health Potion",
  "description": "Restores 50 HP",
  "image": "https://assets.example.com/potion.png",
  "attributes": [
    { "trait_type": "Type", "value": "Consumable" },
    { "trait_type": "Healing", "display_type": "number", "value": 50 }
  ]
}
```

## Minting

### Via [Minting API](/docs/products/asset-contracts/minting-api)

```bash theme={null}
curl -X POST '{baseURL}/v1/chains/{chain_name}/collections/{contract_address}/nfts/mint-requests' \
  -H 'x-immutable-api-key: YOUR_SECRET_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "assets": [{
      "owner_address": "0xRecipient",
      "token_id": "1",
      "amount": "10",
      "metadata": {
        "name": "Health Potion",
        "image": "https://assets.example.com/potion.png"
      }
    }]
  }'
```

### Batch Different Token Types

```typescript theme={null}
const assets = [
  { owner_address: player, token_id: "1", amount: "5", metadata: healthPotion },
  { owner_address: player, token_id: "2", amount: "3", metadata: manaPotion },
  { owner_address: player, token_id: "3", amount: "10", metadata: ironOre },
];

await fetch(`${API_URL}/collections/${contract}/nfts/mint-requests`, {
  method: 'POST',
  headers: { 'x-immutable-api-key': secretKey },
  body: JSON.stringify({ assets }),
});
```

## Fungible vs Non-Fungible Patterns

### Fungible (Stackable)

All health potions share `token_id: "1"` and are interchangeable:

```typescript theme={null}
// Mint 100 health potions
await mint({ token_id: "1", amount: "100", metadata: healthPotion });

// Player transfers 10 to friend
await contract.safeTransferFrom(player, friend, "1", 10, "0x");
```

### Non-Fungible (Unique)

Each legendary weapon gets a unique ID:

```typescript theme={null}
// Mint unique weapons
await mint({ token_id: "1001", amount: "1", metadata: uniqueSword });
await mint({ token_id: "1002", amount: "1", metadata: uniqueShield });
```

## Common Patterns

### Loot Box Rewards

```typescript theme={null}
async function openLootBox(playerAddress: string) {
  const rewards = generateRandomRewards();
  
  const assets = rewards.map((reward, i) => ({
    owner_address: playerAddress,
    token_id: reward.tokenId,
    amount: String(reward.quantity),
  }));
  
  await mintBatch(assets);
}
```

## Deploy via Code

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

import "@imtbl/contracts/contracts/token/erc1155/preset/ImmutableERC1155.sol";

contract MyGameItems is ImmutableERC1155 {
    constructor(
        address owner,
        string memory name,
        string memory baseURI,
        string memory contractURI,
        address operatorAllowlist,
        address royaltyReceiver,
        uint96 royaltyFeeNumerator
    ) ImmutableERC1155(
        owner, name, baseURI, contractURI,
        operatorAllowlist, royaltyReceiver, royaltyFeeNumerator
    ) {}
}
```

## ERC-721 vs ERC-1155

| Feature            | ERC-721          | ERC-1155               |
| ------------------ | ---------------- | ---------------------- |
| **Token Type**     | Always unique    | Unique or stackable    |
| **Gas Efficiency** | Higher per token | Lower for batches      |
| **Use Case**       | Characters, land | Materials, consumables |
| **Complexity**     | Simpler          | More flexible          |

## Next Steps

<CardGroup cols={2}>
  <Card title="Minting API" icon="wand-magic-sparkles" href="/docs/products/asset-contracts/minting-api">
    Mint tokens via API
  </Card>

  <Card title="Deploy Contracts" icon="rocket" href="/docs/products/hub/deploy-contracts">
    Deploy via Hub
  </Card>

  <Card title="Contracts Overview" icon="file-contract" href="/docs/products/asset-contracts/overview">
    Explore contract options
  </Card>

  <Card title="ERC-721" icon="image" href="/docs/products/asset-contracts/erc721">
    Compare with ERC-721
  </Card>
</CardGroup>
