Skip to main content
Typed clients for all Immutable APIs and services.

Packages

Install only what you need:
PackagePurposeInstall
@imtbl/authAuthentication & sessionsnpm i @imtbl/auth
@imtbl/walletEmbedded wallets & transactionsnpm i @imtbl/wallet
@imtbl/auth-nextjsNext.js integrationnpm i @imtbl/auth-nextjs
@imtbl/orderbookNFT tradingnpm i @imtbl/orderbook
@imtbl/blockchain-dataOn-chain data queries (Indexer)npm i @imtbl/blockchain-data
@imtbl/minting-backendServer-side mintingnpm i @imtbl/minting-backend
@imtbl/contractsSmart contract ABIs & typesnpm i @imtbl/contracts
@imtbl/webhookWebhook signature validationnpm i @imtbl/webhook
@imtbl/configEnvironment configurationnpm i @imtbl/config
Install individual packages instead of @imtbl/sdk for smaller bundles and better tree-shaking.

Quick Start

import { Auth } from '@imtbl/auth';
import { connectWallet } from '@imtbl/wallet';
import { Orderbook } from '@imtbl/orderbook';
import { BlockchainData } from '@imtbl/blockchain-data';
import { Environment } from '@imtbl/config';

const baseConfig = {
  environment: Environment.SANDBOX,
  publishableKey: 'YOUR_PUBLISHABLE_KEY',
};

// Authentication
const auth = new Auth({
  clientId: 'YOUR_CLIENT_ID',
  redirectUri: 'http://localhost:3000/callback',
  logoutRedirectUri: 'http://localhost:3000',
  audience: 'platform_api',
  scope: 'openid offline_access email transact',
});

// Wallet (returns EIP-1193 provider)
const provider = await connectWallet({ auth });

// Trading
const orderbook = new Orderbook({ baseConfig });

// On-chain data
const indexer = new BlockchainData({ baseConfig });

Environment Configuration

import { Environment } from '@imtbl/config';

// Development
const sandboxConfig = { environment: Environment.SANDBOX };

// Production
const productionConfig = { environment: Environment.PRODUCTION };
EnvironmentChainAPI Base
SANDBOXImmutable Testnetapi.sandbox.immutable.com
PRODUCTIONImmutable Mainnetapi.immutable.com

Using with viem

viem has built-in Immutable Chain support:
import { createWalletClient, createPublicClient, custom, http } from 'viem';
import { immutableZkEvm, immutableZkEvmTestnet } from 'viem/chains';

// Get wallet provider
const provider = await connectWallet({ auth });

// Create viem clients
const walletClient = createWalletClient({
  chain: immutableZkEvmTestnet,
  transport: custom(provider),
});

const publicClient = createPublicClient({
  chain: immutableZkEvmTestnet,
  transport: http(),
});

// Get address
const [address] = await walletClient.getAddresses();

// Send transaction
const hash = await walletClient.sendTransaction({
  to: '0x...',
  value: parseEther('0.1'),
});

Backend Integration

For server-side operations like minting:
import { MintingBackend } from '@imtbl/minting-backend';
import { Environment } from '@imtbl/config';

const minting = new MintingBackend({
  baseConfig: { environment: Environment.SANDBOX },
  apiKey: process.env.IMMUTABLE_SECRET_KEY!,
});

// Mint NFTs
await minting.mintByID({
  collectionAddress: '0xYourContract',
  assets: [
    {
      ownerAddress: '0xRecipient',
      tokenId: '1',
      metadata: {
        name: 'Epic Sword',
        image: 'https://...',
        attributes: [{ trait_type: 'Rarity', value: 'Legendary' }],
      },
    },
  ],
});

Webhook Validation

Verify incoming webhooks from Immutable:
import { validateWebhook } from '@imtbl/webhook';

app.post('/webhook', (req, res) => {
  const signature = req.headers['x-immutable-signature'] as string;
  const rawBody = req.body; // Must be raw body, not parsed JSON
  
  const isValid = validateWebhook(
    rawBody,
    signature,
    process.env.WEBHOOK_SECRET!
  );
  
  if (!isValid) {
    return res.status(403).send('Invalid signature');
  }
  
  // Process event...
  res.status(200).send('OK');
});

TypeScript Configuration

Ensure your tsconfig.json includes:
{
  "compilerOptions": {
    "target": "ES2020",
    "module": "ESNext",
    "moduleResolution": "bundler",
    "esModuleInterop": true,
    "strict": true
  }
}

Resources