Skip to content
This repository was archived by the owner on Jan 8, 2026. It is now read-only.

Commit 3a6480f

Browse files
authored
refactor: [DX-2625] update examples to use Unified SDK (#46)
* update CODEOWNERS * update user registration script * add create project script * update create collection script * update add metadata schema script * add minting script and minting utils * refactor public method scripts * remove unsed bulk minting script * update utils * update env examples * remove admin scripts * remove dockerfile * remove unused docs * update onboarding docs * update public interfaces doc * remove unused dependencies, update package.json scripts * lock TS version to fix ESLint * update create project instructions * update metadata schema to match NFT minting tutorial * update README * update onboarding docs with clearer steps * update lint workflow * use node 18 in workflow * remove yarn cache from workflow * update ESLint * lint fix
1 parent 8e8573f commit 3a6480f

32 files changed

Lines changed: 14658 additions & 9341 deletions

.env.example

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,16 @@
33
#=============================================
44
ALCHEMY_API_KEY=
55
ETH_NETWORK=sepolia
6-
# IMX API endpoint
7-
PUBLIC_API_URL=https://api.sandbox.x.immutable.com/v1
8-
# sandbox contracts in sepolia
9-
STARK_CONTRACT_ADDRESS=0x2d5C349fD8464DA06a3f90b4B0E9195F3d1b7F98
10-
REGISTRATION_ADDRESS=0xDbA6129C02E69405622fAdc3d5A7f8d23eac3b97
11-
GAS_LIMIT=7000000
12-
GAS_PRICE=40000000000
136

14-
# Your environment's api key generated from https://hub.immutable.com/
15-
API_KEY=
16-
#=============================================
17-
# Bulk Minting
18-
#=============================================
19-
PRIVATE_KEY1=
20-
TOKEN_ID=
21-
TOKEN_ADDRESS=
22-
BULK_MINT_MAX=50
237

248
#=============================================
259
# Onboarding
2610
#=============================================
11+
# Your environment's api key generated from https://hub.immutable.com/
12+
API_KEY=
2713
OWNER_ACCOUNT_PRIVATE_KEY=
28-
COLLECTION_CONTRACT_ADDRESS=
2914
COLLECTION_PROJECT_ID=
15+
COLLECTION_CONTRACT_ADDRESS=
3016

3117

3218
#=============================================

.eslintrc.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@ module.exports = {
99
sourceType: 'module',
1010
project: './tsconfig.eslint.json',
1111
},
12-
plugins: ['@typescript-eslint', 'simple-import-sort', 'fp-ts'],
12+
plugins: ['@typescript-eslint', 'simple-import-sort', 'import'],
1313
extends: [
1414
'plugin:@typescript-eslint/recommended',
15-
'plugin:fp-ts/all',
1615
'airbnb-typescript/base',
1716
// @NOTE: Make sure this is always the last element in the array.
1817
'plugin:prettier/recommended',

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @immutable/imx-developer-experience
1+
* @immutable/sdk

.github/workflows/lint.yml

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,19 @@ on:
55
branches:
66
- main
77
pull_request:
8-
branches:
9-
- main
108

119
jobs:
12-
build:
10+
lint:
1311
name: Lint
14-
runs-on: ubuntu-latest
12+
runs-on: ubuntu-latest-4-cores
1513
steps:
1614
- name: Checkout
17-
uses: actions/checkout@v2
18-
with:
19-
fetch-depth: 0
20-
21-
- name: Check NPM Package Lock File Version
22-
uses: mansona/npm-lockfile-version@v1
23-
24-
- name: Use Node.js 12.22.6
25-
uses: actions/setup-node@v1
26-
with:
27-
node-version: 12.22.6
28-
29-
- name: Install npm 7.x
30-
run: npm i -g npm@7
15+
uses: actions/checkout@v3
3116

32-
- name: Cache node modules
33-
uses: actions/cache@v2
34-
env:
35-
cache-name: node-modules
17+
- name: Use Node.js
18+
uses: actions/setup-node@v3
3619
with:
37-
path: ~/.npm
38-
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
39-
restore-keys: |
40-
${{ runner.os }}-build-${{ env.cache-name }}-
41-
${{ runner.os }}-build-
42-
${{ runner.os }}-
20+
node-version: 18
4321

4422
- name: Install dependencies
4523
run: npm ci

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"typescript.tsdk": "node_modules/typescript/lib"
3+
}

README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<div align="center">
2-
<a href="https://www.immutable.com">
3-
<img width="150" src="https://assets-global.website-files.com/5f7eec37ff782e797edabe11/5f8d36771ffcf8c91b03e7f4_dark.svg">
4-
</a>
5-
<br>
6-
<br>
2+
<p align="center">
3+
<a href="https://docs.x.immutable.com/docs">
4+
<img src="https://cdn.dribbble.com/users/1299339/screenshots/7133657/media/837237d447d36581ebd59ec36d30daea.gif" width="280"/>
5+
</a>
6+
</p>
77
</div>
88

99
---
@@ -14,16 +14,19 @@
1414

1515
This repository contains example scripts for interacting with Immutable X APIs.
1616

17+
## Guides
18+
19+
This repository is intended to be used alongside the Immutable X [NFT minting tutorial](https://docs.immutable.com/docs/x/zero-to-hero-nft-minting).
20+
1721
## Docs
1822

1923
* [Onboarding (Self Service)](docs/onboarding.md)
20-
* [Administration](docs/administration.md)
21-
* [Minting Assets](docs/minting-assets.md)
2224
* [Public Interfaces](docs/public-interfaces.md)
2325

2426
## License
2527

2628
Immutable Examples repository is distributed under the terms of the [Apache License (Version 2.0)](LICENSE).
2729

2830
## Contributing
31+
2932
Please check [contributing guidelines](CONTRIBUTING.md) to learn how to help this project.

docker-dev/Dockerfile

Lines changed: 0 additions & 3 deletions
This file was deleted.

docs/administration.md

Lines changed: 0 additions & 53 deletions
This file was deleted.

docs/minting-assets.md

Lines changed: 0 additions & 16 deletions
This file was deleted.

docs/onboarding.md

Lines changed: 72 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
# Onboarding (Self-service)
22

3+
## Pre-requisites
4+
5+
- Node.js v18 (LTS) or later.
6+
- An Alchemy API key. You can create an account and get an API key following this [quickstart guide](https://docs.alchemy.com/docs/alchemy-quickstart-guide).
7+
- A MetaMask wallet with some Sepolia testnet ETH. You can get testnet ETH from the [Etherem Sepolia faucet](https://www.alchemy.com/faucets/ethereum-sepolia).
8+
- Alternatively, you can use the [Sepolia PoW faucet](https://sepolia-faucet.pk910.de/).
9+
- You will need to export the private key of the wallet you want to use for onboarding.
10+
- A collection contract deployed on Immutable X. You can deploy a collection contract following this [guide](https://github.com/immutable/contracts/blob/main/deploy/x/README.md)
11+
12+
### Immutable Developer Hub
13+
14+
Register with your email address at the [Immutable Developer Hub](https://hub.immutable.com) to get access to customized documentation in the hub as well as the ability to create Immutable X and Immutable zkEVM projects on Immutable.
15+
16+
You must first have a project in order to create collections that you can mint assets from on Immutable (L2).
17+
18+
For this onboarding guide, we will need to create an **Immutable X** project. Make sure you note down the Legacy ID of the project from the project overview page.
19+
20+
If you have already created an account, and have a Immutable X project, you can skip this step.
21+
22+
## Getting started
23+
324
To begin, clone this repository:
425

526
```sh
@@ -14,30 +35,22 @@ Copy environment file
1435
cp .env.example .env
1536
```
1637

17-
Set the onboarding private key in `.env`. Your private key will be used to create a signed payload only and will not be sent to our backend services.
18-
19-
```sh
20-
OWNER_ACCOUNT_PRIVATE_KEY=YOUR_PRIVATE_KEY
21-
```
22-
23-
Set the `API_KEY` in the `.env` file. You can create and manage your API key in the [Immutable Hub](https://hub.immutable.com/). The Immutable Hub serves as a portal for creating, displaying, and refreshing API keys. Navigate to the "API Keys" menu item within your chosen project and environment to manage or create your API keys.
38+
Set the environment variables in the `.env` file:
2439

25-
```sh
26-
API_KEY=YOUR_SECRET_API_KEY
27-
```
40+
| Field Name | Description |
41+
| ----------------------------- | ----------- |
42+
| `ALCHEMY_API_KEY` | The Alchemy API key. |
43+
| `API_KEY` | The API key generated from your environment's API Key page in the Immutable Hub. |
44+
| `OWNER_ACCOUNT_PRIVATE_KEY` | Metamask private key. |
45+
| `COLLECTION_PROJECT_ID` | The Legacy ID from your environment's overview page in the Immutable Hub. |
46+
| `COLLECTION_CONTRACT_ADDRESS` | Deployed contract address. |
2847

29-
Install dependencies
48+
Install project dependencies
3049

3150
```sh
3251
npm install
3352
```
3453

35-
## 0. Register with your email for the Immutable Developer Hub
36-
37-
Register with your email address at the [Immutable Developer Hub](https://hub.immutable.com) to get access to customized documentation in the hub as well as the ability to create projects on Immutable via the [Public API](https://docs.x.immutable.com/reference#/operations/createProject) or the CLI in this repo.
38-
39-
You must first have a project in order to create collections that you can mint assets from on Immutable (L2).
40-
4154
## 1. Register as a user with Immutable X
4255

4356
We provide an authentication service to protect your administrative level assets from being accessed or updated by someone else. This is done using a simliar technique as described [here](https://link.medium.com/CVTcj7YfQkb).
@@ -56,11 +69,15 @@ npm run onboarding:user-registration
5669

5770
Follow the guide at [here](https://docs.immutable.com/docs/x/launch-collection/register-project) to create a project in the [Immutable Hub](https://hub.immutable.com).
5871

59-
## 3. Add a collection
72+
- Ensure you create a project for the **`Immutable X`** rollup.
73+
74+
## 3. Create a collection
6075

6176
A collection refers to a smart contract you have deployed. Minted assets belong to a collection. In order to mint assets on L2
6277
you must first register your collection (smart contract) with Immutable X.
6378

79+
If you have not deployed a collection contract, you can follow the guide [here](https://github.com/immutable/contracts/blob/main/deploy/x/README.md) to deploy a Asset collection contract.
80+
6481
Add the collection contract address to the environment variable `COLLECTION_CONTRACT_ADDRESS`.
6582

6683
Set `COLLECTION_PROJECT_ID` to the legacy ID in your created environment's overview page from step 2.
@@ -81,9 +98,19 @@ npm run onboarding:create-collection
8198

8299
If you see a `replacement transaction underpriced` error message when trying to run `create-collection` please try again in 5 minutes.
83100

101+
There is a convenience script to get the info of the newly created collection:
102+
103+
```sh
104+
npm run public:get-collection-info
105+
```
106+
107+
The collection should also be visible in the [Immutable Hub](https://hub.immutable.com).
108+
84109
## 4. Add metadata schema to your collection
85110

86-
Update the values in file `4-add-metadata-schema.ts` with the values of the metadata you want to define.
111+
Update the `4-add-metadata-schema.ts` file with the metadata schema values you want to define. The metadata schema is used to define the structure of the metadata that will be associated with the NFTs in your collection.
112+
113+
Descriptions of the metadata schema fields can be found [here](https://docs.immutable.com/docs/x/launch-collection/register-metadata-schema#metadata-schema).
87114

88115
Once updated, run the following script to create your collection:
89116

@@ -92,3 +119,29 @@ _Requires environment variables `OWNER_ACCOUNT_PRIVATE_KEY` and `COLLECTION_CONT
92119
```sh
93120
npm run onboarding:add-metadata-schema
94121
```
122+
123+
If you want to add additional metadata schemas, you can do so by adding more objects to the `metadata` array, and remove any existing metadata schemas from the `metadata` array, and then run the script again.
124+
125+
If you want to change the properties of an existing field, you can use the `updateMetadataSchemaByName` function instead. There is an example of this in the `4-add-metadata-schema.ts` file.
126+
127+
## 5. Mint NFTs
128+
129+
There is an minting example script, `5-mint-nfts.ts`, which is used to mint example NFTs to a wallet.
130+
131+
The default behaviour is to mint the NFTs to the wallet that owns the `OWNER_ACCOUNT_PRIVATE_KEY`. If you want to mint the NFTs to a different wallet, you can uncomment and update the `mintRecipient` value passed to the `mint` function in the script.
132+
133+
Also take a look at the example token objects in `tokens` array and update the blueprint values to your liking.
134+
135+
For a deeper explanation of the blueprint string, see the [Deep dive into metadata section] in the Immutable X documentation(https://docs.immutable.com/docs/x/deep-dive-metadata#providing-a-blueprint-string-when-token-is-minted-on-l2).
136+
137+
_Requires environment variables `OWNER_ACCOUNT_PRIVATE_KEY` and `COLLECTION_CONTRACT_ADDRESS` to be set._
138+
139+
```sh
140+
npm run onboarding:mint
141+
```
142+
143+
Once the NFTs have been minted, you can run the following script to get the info of the minted NFTs in the collection:
144+
145+
```sh
146+
npm run public:get-assets-info
147+
```

0 commit comments

Comments
 (0)