Skip to main content

Setup

Learn how to set up your environment to integrate and use Immutable Orderbook


Install

Prerequisites

Node Version >18
Immutable's Typescript SDK requires **Node v18** (Active LTS version) or **higher**. Node v18 can be installed via `nvm`.

To install nvm follow these instructions. Once installed, run:

nvm install --lts
  • (Optional) To enable code splitting (importing only the SDK modules you need) there are additional prerequisites. See the Code Splitting section below.

Install the Immutable SDK

Run the following command in your project root directory.

npm install -D @imtbl/sdk
# if necessary, install dependencies
npm install -D typescript ts-node
Troubleshooting

The Immutable SDK is still in early development. If experiencing complications, use the following commands to ensure the most recent release of the SDK is correctly installed:

rm -Rf node_modules
npm cache clean --force
npm i

Initialize

When you initialize the SDK, the chainName configuration will direct the SDK to connect to a specific environment.

Supported values are:

Chain NameChain IDOperator Allowlist Address
imtbl-zkevm-testneteip155:134730x6b969FD89dE634d8DE3271EbE97734FEFfcd58eE
imtbl-zkevm-mainneteip155:133710x5F5EBa8133f68ea22D712b0926e2803E78D89221
import { config, orderbook } from '@imtbl/sdk';
import { ethers } from 'ethers'; // ethers v5

const PUBLISHABLE_KEY = 'YOUR_PUBLISHABLE_KEY'; // Replace with your Publishable Key from the Immutable Hub

const client = new orderbook.Orderbook({
baseConfig: {
environment: config.Environment.SANDBOX,
publishableKey: PUBLISHABLE_KEY,
},
});

Create signers for user authorisation

Creating, filling and cancelling orders require a user's authorisation.

💡What is a Signer?

A signer is a representation of a user's wallet (account) that is used to authorise transactions. These transactions typically involve transferring the ownership of assets (currencies or NFTs) from one account to another, hence why the user is required to "sign" these transactions. Applications use signers to obtain user signatures to execute payments, asset transfers, and more. For more information, see the Signers definition from the ethers library.

In order to create a signer, you must first establish a connection to the user's wallet. This is how you connect to different user wallets:

To initialise the passport module, please see the Passport Setup guide.

import { Web3Provider } from '@ethersproject/providers';

const passportWallet = passport.connectEvm(); // returns an EIP-1193 provider
const ethersProvider = new Web3Provider(passportWallet);
const signer = ethersProvider.getSigner();