Skip to content

Commit 0429380

Browse files
authored
Merge 39ba315 into d583776
2 parents d583776 + 39ba315 commit 0429380

12 files changed

Lines changed: 204 additions & 2 deletions

File tree

docs.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,8 @@
10041004
"guides/using-unity-iap-to-sell-nfts",
10051005
"guides/unity-primary-sales",
10061006
"guides/unity-webgl-telegram",
1007-
"guides/telegram-integration"
1007+
"guides/telegram-integration",
1008+
"guides/packs"
10081009
]
10091010
}
10101011
]

es/guides/guide-cards.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"lastUpdated":"2025-09-03T12:15:39.593Z","totalCards":6,"sections":[{"title":"Desarrolladores de videojuegos","cards":[{"title":"Cree un juego móvil con Unity + Sequence","img":"/images/unity/jellyforest-iphone.jpg","href":"/guias/jelly-forest-unity-guia","description":"Aprenda a crear un juego atractivo para iOS y Android que utiliza Sequence Embedded Wallets en segundo plano para habilitar un marketplace integrado y una moneda dentro del juego."},{"title":"Cómo crear un juego con Unreal Engine","img":"/images/guides/overview/unreal-ew-guide.th.png","href":"/guias/unreal-ew-guia","description":"Utilice el SDK de Unreal de Sequence para mostrar información de Embedded Wallet, firmar mensajes y enviar transacciones."},{"title":"Cree un juego Dungeon Crawler con recompensas generadas por IA","img":"/images/guides/treasure-chest/dungeonMinter.th.png","href":"/guias/tesoro-guia","description":"Con este tutorial, cree un laberinto web donde los objetos de caja de recompensas (lootbox) se generan usando IA y se mintean dinámicamente en el wallet universal del jugador."},{"title":"Cree un juego WebGL en Typescript","img":"/images/aviator.th.jpg","href":"/guias/webgl-guia","description":"Siga una guía paso a paso para crear una demo de juego web que utiliza Sequence Embedded Wallet y tokens de logros personalizados dentro del juego."},{"title":"Venda objetos del juego a través de una tienda web","img":"/images/guides/overview/primary-sales.th.jpg","href":"/guias/ventas-primarias","description":"Impulse el crecimiento de su juego vendiendo objetos directamente a sus jugadores. En esta guía, le mostraremos cómo desplegar un contrato de Primary Sale paso a paso usando cualquier moneda personalizada o existente para una tienda web que utiliza objetos del juego de un contrato ERC1155."},{"title":"Compre artículos on-chain en Unity","img":"/images/guides/overview/unity-primary-sales.th.jpg","href":"/guias/unity-ventas-primarias","description":"Esta guía cubre la creación de una Primary Sale con el SDK de Unity de Sequence."}]}]}
1+
{"lastUpdated":"2025-09-03T12:15:39.593Z","totalCards":7,"sections":[{"title":"Desarrolladores de videojuegos","cards":[{"title":"Cree un juego móvil con Unity + Sequence","img":"/images/unity/jellyforest-iphone.jpg","href":"/guias/jelly-forest-unity-guia","description":"Aprenda a crear un juego atractivo para iOS y Android que utiliza Sequence Embedded Wallets en segundo plano para habilitar un marketplace integrado y una moneda dentro del juego."},{"title":"Cómo crear un juego con Unreal Engine","img":"/images/guides/overview/unreal-ew-guide.th.png","href":"/guias/unreal-ew-guia","description":"Utilice el SDK de Unreal de Sequence para mostrar información de Embedded Wallet, firmar mensajes y enviar transacciones."},{"title":"Cree un juego Dungeon Crawler con recompensas generadas por IA","img":"/images/guides/treasure-chest/dungeonMinter.th.png","href":"/guias/tesoro-guia","description":"Con este tutorial, cree un laberinto web donde los objetos de caja de recompensas (lootbox) se generan usando IA y se mintean dinámicamente en el wallet universal del jugador."},{"title":"Cree un juego WebGL en Typescript","img":"/images/aviator.th.jpg","href":"/guias/webgl-guia","description":"Siga una guía paso a paso para crear una demo de juego web que utiliza Sequence Embedded Wallet y tokens de logros personalizados dentro del juego."},{"title":"Venda objetos del juego a través de una tienda web","img":"/images/guides/overview/primary-sales.th.jpg","href":"/guias/ventas-primarias","description":"Impulse el crecimiento de su juego vendiendo objetos directamente a sus jugadores. En esta guía, le mostraremos cómo desplegar un contrato de Primary Sale paso a paso usando cualquier moneda personalizada o existente para una tienda web que utiliza objetos del juego de un contrato ERC1155."},{"title":"Compre artículos on-chain en Unity","img":"/images/guides/overview/unity-primary-sales.th.jpg","href":"/guias/unity-ventas-primarias","description":"Esta guía cubre la creación de una Primary Sale con el SDK de Unity de Sequence."},{"title":"Configurar un contrato ERC1155Pack","img":"/images/guides/overview/packs.th.jpg","href":"/guias/packs","description":"Configure el contenido de un contrato ERC1155Pack con Sequence Builder y cargue los packs vía CSV."}]}]}

es/guides/packs.mdx

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
---
2+
title: "Cómo configurar un contrato ERC1155Pack en Sequence Builder"
3+
description: Aprenda cómo funciona ERC1155Pack en Builder, incluido el esquema commit-reveal, la carga de CSV y la publicación de contenidos.
4+
sidebarTitle: Usar un contrato ERC1155Pack
5+
---
6+
7+
Use esta guía para configurar paquetes en su contrato ERC1155Pack en Sequence Builder. El contrato `ERC1155Pack` amplía ERC1155Items para añadir una apertura de paquetes con commit-reveal, de modo que los resultados puedan verificarse y solo se revelen una vez.
8+
9+
<Warning>
10+
Prerequisito: Desplegar contratos y objetos
11+
12+
Asegúrese de haber [creado un proyecto](/solutions/builder/getting-started), desplegado su contrato ERC1155Pack y desplegado las colecciones ERC1155 o ERC721 cujos ítems quiere incluir en cada paquete.
13+
</Warning>
14+
15+
## Paso 1: Abra su contrato ERC1155Pack
16+
17+
Desde el panel del proyecto, seleccione el contrato PACK que quiere configurar y abra la pestaña `Pack` para gestionar su contenido. Confirme que está en la red correcta y que la colección vinculada es la adecuada antes de editar.
18+
<Frame>
19+
![Resumen del contrato Pack](/images/builder/builder-packs-1.png)
20+
</Frame>
21+
22+
## Paso 2: Elija o agregue un pack para editar
23+
24+
Use el selector de packs para elegir el que quiere actualizar o haga clic en `Add new pack` para crear otro. La tabla muestra la dirección, tipo, IDs y cantidades de tokens que se incluirán cuando se abra un pack.
25+
<Frame>
26+
![Seleccionar pack y revisar contenidos](/images/builder/builder-packs-2.png)
27+
</Frame>
28+
29+
## Paso 3: Cargue el contenido del pack vía CSV
30+
31+
Haga clic en `Add New Pack` o `Update Pack Contents` para abrir el cargador CSV. Ingrese el `Pack ID` que va a modificar, defina el `Supply` (cuántos packs pueden abrirse) y cargue un CSV con una fila por contenido del pack.
32+
33+
Cada fila debe incluir:
34+
35+
- `Pack Content ID`
36+
- Para cada ítem: `Token Address`, `Token Type` (1155/721), `Token IDs` y `Amounts`
37+
38+
Ejemplo:
39+
```
40+
Pack Content ID, Item 1 Token Addr, Item 1 Token Type, Item 1 Token IDs, Item 1 Amounts, Item 2 Token Addr, Item 2 Token Type, Item 2 Token IDs, Item 2 Amounts
41+
1,0x3a6a8f4091b705fe1241c47e2532d45a6dff5a85,721,"1200","1",0xa558419686308ce836c36a5c44eeeb4b0916ca7b,1155,"5,6","7,3"
42+
2,0x3a6a8f4091b705fe1241c47e2532d45a6dff5a85,721,"1201","1",0xa558419686308ce836c36a5c44eeeb4b0916ca7b,1155,"9,10","7,9"
43+
3,0x3a6a8f4091b705fe1241c47e2532d45a6dff5a85,721,"1202","1",0xa558419686308ce836c36a5c44eeeb4b0916ca7b,1155,"7,8","4,8"
44+
4,0x3a6a8f4091b705fe1241c47e2532d45a6dff5a85,721,"1203","1",0xa558419686308ce836c36a5c44eeeb4b0916ca7b,1155,"9","7"
45+
5,0x3a6a8f4091b705fe1241c47e2532d45a6dff5a85,721,"1204","1",0xa558419686308ce836c36a5c44eeeb4b0916ca7b,1155,"9,10","5,4"
46+
```
47+
48+
<Frame>
49+
![Cargar CSV para el contenido del pack](/images/builder/builder-packs-3.png)
50+
</Frame>
51+
52+
<Warning>
53+
El CSV reemplaza todo el contenido existente para el Pack ID seleccionado y reinicia el seguimiento de distribución.
54+
55+
Si ya distribuyó packs para un ID concreto, recomendamos no cambiar el CSV, ya que restablece qué packs han sido abiertos.
56+
57+
Si un ítem 721 ya se distribuyó en un pack previo y aparece en un nuevo CSV, fallará al acuñar cuando un usuario abra ese pack.
58+
</Warning>
59+
60+
## Paso 4: Dé al contrato de packs el rol de Minter en su colección de ítems
61+
62+
Para que el pack pueda mintear los ítems al abrirse, otorgue al contrato ERC1155Pack el rol `Minter` en la colección ERC1155 que usa para el contenido. Abra `Settings > Permissions` en ese contrato de ítems, agregue la dirección del contrato de packs y asigne `Minter`, luego firme la transacción.
63+
64+
## Paso 5: Revise y publique
65+
66+
Cuando se procese el CSV verá una vista previa de las filas de contenido. Verifique direcciones, IDs, cantidades y totales, y luego haga clic en `Create Pack Contents` para guardar. Su pack estará listo para que los jugadores lo abran.
67+
<Frame>
68+
![Vista previa del contenido procesado y publicación](/images/builder/builder-packs-4.png)
69+
</Frame>
70+
71+
¿Quiere un frontend para abrir packs? Revise el ejemplo open source en https://github.com/0xsequence-demos/pack-opening-boilerplate/.
72+
73+
74+
## Cómo funciona ERC1155Pack
75+
76+
Las cuentas con `PACK_ADMIN_ROLE` gestionan el contenido con `setPacksContent(bytes32 _merkleRoot, uint256 _supply, uint256 packId)`. La raíz de Merkle codifica todo el contenido posible y `supply` define cuántos packs pueden abrirse para ese ID. Builder genera la raíz desde su CSV para que se concentre en el contenido.
77+
78+
Flujo on-chain:
79+
80+
- El usuario llama `commit(packId)` para quemar su pack y crear el compromiso.
81+
- Tras al menos un bloque, cualquiera puede llamar `reveal(user, packContent, proof, packId)` con la prueba Merkle del contenido seleccionado; el contrato verifica y mintea los ítems. La API de Sequence puede hacerlo automáticamente.
82+
- Si no se revela antes de que expire el hash del bloque de compromiso (30 minutos), `refundPack(user, packId)` devuelve el pack.
83+
84+
Aleatoriedad:
85+
86+
- El compromiso registra `block.number + 1` para la aleatoriedad.
87+
- La revelación deriva `randomSeed = keccak256(abi.encode(blockHash, user))`.
88+
- El contrato elige `randomSeed % remainingSupply[packId]` usando un mapa `_availableIndices` estilo Fisher–Yates, garantizando que cada contenido solo se revele una vez y con distribución uniforme.
89+
- La hoja de Merkle es `keccak256(abi.encode(revealIdx, packContent))`, que debe coincidir con la prueba suministrada.
90+
91+
<Warning>
92+
Si validadores o mineros controlan bloques secuenciales pueden sesgar los hashes y la aleatoriedad. Permitir que cualquiera llame `reveal` ayuda a asegurar que los packs comprometidos se revelen antes de que el hash del bloque caduque.
93+
</Warning>

guides/guide-cards.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@
4040
"img": "/images/guides/overview/unity-primary-sales.th.jpg",
4141
"href": "/guides/unity-primary-sales",
4242
"description": "This guide covers the creation of a Primary Sale with Sequence's Unity SDK."
43+
},
44+
{
45+
"title": "Configure a ERC1155Pack Contract",
46+
"img": "/images/guides/overview/packs.th.jpg",
47+
"href": "/guides/packs",
48+
"description": "This guide covers the configuration of a ERC1155Pack Contract via Sequence Builder."
4349
}
4450
]
4551
}

guides/guide-overview.mdx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,11 @@ sidebarTitle: Overview
9696
>
9797
This guide covers the creation of a Primary Sale with Sequence's Unity SDK.
9898
</Card>
99+
<Card
100+
title="Configure a ERC1155Pack Contract"
101+
img="/images/guides/overview/packs.th.jpg"
102+
href="/guides/packs"
103+
>
104+
This guide covers the configuration of a ERC1155Pack Contract via Sequence Builder.
105+
</Card>
99106
</CardGroup>

guides/packs.mdx

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
---
2+
title: "How to Configure a ERC1155Pack Contract in Sequence Builder"
3+
description: Learn how ERC1155Pack works in Builder, including commit-reveal mechanics, and publishing pack contents.
4+
sidebarTitle: Using a ERC1155Pack Contract
5+
---
6+
7+
Use this guide to configure packs in your ERC1155Pack contract in Sequence Builder. The `ERC1155Pack` contract extends ERC1155Items to add a pack-opening flow powered by a commit-reveal scheme.
8+
9+
<Warning>
10+
Prerequisite: Deploy Contracts and Items
11+
12+
Make sure you have [created a project](/solutions/builder/getting-started), deployed your ERC1155Pack contract, and deployed the ERC1155 or ERC721 contracts/collections whose items you want inside each pack.
13+
</Warning>
14+
15+
## Step 1: Open your ERC1155Pack contract
16+
17+
From your project dashboard, select the PACK contract you want to configure, then open the `Pack` tab to manage its contents. Confirm you are on the correct network and linked collection before editing.
18+
<Frame>
19+
![Pack contract overview](/images/builder/builder-packs-1.png)
20+
</Frame>
21+
22+
## Step 2: Choose or add a pack to edit
23+
24+
Use the pack selector to pick the pack you want to update, or click `Add new pack` to create another pack entry. The table lists each pack's underlying token address, type, IDs, and amounts that will be included when a pack is opened.
25+
<Frame>
26+
![Select pack and review contents](/images/builder/builder-packs-2.png)
27+
</Frame>
28+
29+
## Step 3: Upload pack contents via CSV
30+
31+
Click `Add New Pack` or `Update Pack Contents` to open the CSV uploader. Enter the `Pack ID` you want to modify, set the `Supply` for how many packs can be opened, and upload a CSV with one row per pack content.
32+
33+
Each row must include:
34+
35+
- `Pack Content ID`
36+
- For each item: `Token Address`, `Token Type` (1155/721), `Token IDs`, and `Amounts`
37+
38+
e.g.
39+
```
40+
Pack Content ID, Item 1 Token Addr, Item 1 Token Type, Item 1 Token IDs, Item 1 Amounts, Item 2 Token Addr, Item 2 Token Type, Item 2 Token IDs, Item 2 Amounts
41+
1,0x3a6a8f4091b705fe1241c47e2532d45a6dff5a85,721,"1200","1",0xa558419686308ce836c36a5c44eeeb4b0916ca7b,1155,"5,6","7,3"
42+
2,0x3a6a8f4091b705fe1241c47e2532d45a6dff5a85,721,"1201","1",0xa558419686308ce836c36a5c44eeeb4b0916ca7b,1155,"9,10","7,9"
43+
3,0x3a6a8f4091b705fe1241c47e2532d45a6dff5a85,721,"1202","1",0xa558419686308ce836c36a5c44eeeb4b0916ca7b,1155,"7,8","4,8"
44+
4,0x3a6a8f4091b705fe1241c47e2532d45a6dff5a85,721,"1203","1",0xa558419686308ce836c36a5c44eeeb4b0916ca7b,1155,"9","7"
45+
5,0x3a6a8f4091b705fe1241c47e2532d45a6dff5a85,721,"1204","1",0xa558419686308ce836c36a5c44eeeb4b0916ca7b,1155,"9,10","5,4"
46+
47+
```
48+
49+
<Frame>
50+
![Upload CSV for pack contents](/images/builder/builder-packs-3.png)
51+
</Frame>
52+
53+
<Warning>
54+
The CSV replaces all existing contents for the selected Pack ID, and resets pack distribution tracking.
55+
56+
If you have already distributed packs for a specific ID, we recommend you do not change the CSV, as this resets which packs have been opened.
57+
58+
If a 721 item was already distributed in a previous pack, and it is in a new pack CSV, it will fail to mint when a user opens that pack.
59+
</Warning>
60+
61+
62+
## Step 4: Give the pack contract a Minter role on your item collection
63+
64+
For packs to mint items when opened, grant the ERC1155Pack contract address the `Minter` role on the ERC1155 collection you're using for pack contents. Open that item contract’s `Settings > Permissions`, add the pack contract address, and assign `Minter`, then sign the transaction.
65+
66+
## Step 5: Review and publish
67+
68+
After the CSV is processed you will see a preview of the parsed Pack Content rows. Verify the token addresses, IDs, amounts, and totals, then click `Create Pack Contents` to save. Your pack is now ready to be opened by players.
69+
<Frame>
70+
![Preview processed pack contents and publish](/images/builder/builder-packs-4.png)
71+
</Frame>
72+
73+
Looking for a frontend to open packs? Check out our react boilerplate at https://github.com/0xsequence-demos/pack-opening-boilerplate/.
74+
75+
76+
## How ERC1155Pack works
77+
78+
Pack contents are managed by addresses with `PACK_ADMIN_ROLE` using `setPacksContent(bytes32 _merkleRoot, uint256 _supply, uint256 packId)`. The merkle root encodes every possible pack content, and `supply` defines how many packs can be opened for that ID. Builder handles the root creation from your CSV so you can focus on content.
79+
80+
Flow (on-chain):
81+
82+
- User calls `commit(packId)` to burn their pack and create a commitment.
83+
- After at least one block, anyone can call `reveal(user, packContent, proof, packId)` with a merkle proof for the selected content; the contract verifies and mints the items. The Sequence API will do this automatically.
84+
- If reveal is not called before the commitment block hash expires (30 minutes), `refundPack(user, packId)` returns the pack.
85+
86+
Randomization:
87+
88+
- Commitment records `block.number + 1` for randomness.
89+
- Reveal derives `randomSeed = keccak256(abi.encode(blockHash, user))`.
90+
- The contract picks `randomSeed % remainingSupply[packId]`, using a Fisher–Yates-style `_availableIndices` map so each content can only be revealed once and stays uniformly random.
91+
- The merkle leaf is `keccak256(abi.encode(revealIdx, packContent))`, matched by the supplied proof.
92+
93+
<Warning>
94+
Validators or miners controlling sequential blocks could bias block hashes. Allowing anyone to call `reveal` helps ensure committed packs are revealed before block hashes expire.
95+
</Warning>

images/builder/builder-packs-1.png

650 KB
Loading

images/builder/builder-packs-2.png

363 KB
Loading

images/builder/builder-packs-3.png

191 KB
Loading

images/builder/builder-packs-4.png

272 KB
Loading

0 commit comments

Comments
 (0)