Skip to main content

Installation & Setup

This guide will help you install and configure the JACK TypeScript SDK.

Prerequisites

  • Node.js 18+ or 20+
  • npm, pnpm, or yarn
  • TypeScript 5.0+ (recommended)

Installation

Using npm

npm install @jack-kernel/sdk

Using pnpm

pnpm add @jack-kernel/sdk

Using yarn

yarn add @jack-kernel/sdk

Peer Dependencies

The SDK requires viem for EIP-712 signing:

npm install viem

Optional Dependencies

LI.FI Integration

LI.FI is included by default as a dependency:

# Already included
@lifi/sdk

Yellow Network Integration

For Yellow Network state channels, you'll need a wallet client from viem:

import { createWalletClient, http } from 'viem';
import { mainnet } from 'viem/chains';

const walletClient = createWalletClient({
chain: mainnet,
transport: http()
});

Basic Configuration

Minimal Setup

import { JACK_SDK } from '@jack-kernel/sdk';

const sdk = new JACK_SDK({
baseUrl: 'https://api.jack.example'
});

Production Setup

import { JACK_SDK } from '@jack-kernel/sdk';

const sdk = new JACK_SDK({
baseUrl: 'https://api.jack.example',
timeout: 60000,
maxRetries: 5,
headers: {
'Authorization': 'Bearer your-api-token',
'X-Client-Version': '1.0.0'
}
});

With LI.FI Integration

import { JACK_SDK } from '@jack-kernel/sdk';

const sdk = new JACK_SDK({
baseUrl: 'https://api.jack.example',
lifi: {
integrator: 'jackkernel',
maxRetries: 3
}
});

With Yellow Network Integration

import { JACK_SDK } from '@jack-kernel/sdk';
import { createWalletClient, http } from 'viem';
import { mainnet } from 'viem/chains';

const walletClient = createWalletClient({
chain: mainnet,
transport: http()
});

const sdk = new JACK_SDK({
baseUrl: 'https://api.jack.example',
yellow: {
custodyAddress: '0x...',
adjudicatorAddress: '0x...',
chainId: 1,
walletClient
}
});

Full Configuration

import { JACK_SDK } from '@jack-kernel/sdk';

const sdk = new JACK_SDK({
// Required
baseUrl: 'https://api.jack.example',

// Optional HTTP settings
timeout: 60000,
maxRetries: 5,
retryDelay: 1000,
retryBackoff: 2,

// Optional caching
enableCache: true,
cacheTTL: 60000,

// Optional headers
headers: {
'Authorization': 'Bearer token',
'X-Client-Version': '1.0.0'
},

// Optional LI.FI
lifi: {
integrator: 'jackkernel',
maxRetries: 3
},

// Optional Yellow Network
yellow: {
custodyAddress: '0x...',
adjudicatorAddress: '0x...',
chainId: 1,
walletClient: myWalletClient
}
});

Configuration Options

ClientConfig

OptionTypeDefaultDescription
baseUrlstringrequiredBase URL for the JACK API
timeoutnumber30000Request timeout in milliseconds
maxRetriesnumber3Maximum number of retry attempts
retryDelaynumber1000Initial delay between retries in ms
retryBackoffnumber2Backoff multiplier for exponential retry
enableCachebooleantrueEnable response caching for GET requests
cacheTTLnumber60000Cache time-to-live in milliseconds
headersRecord<string, string>{}Custom HTTP headers for all requests

LifiConfig

OptionTypeDefaultDescription
integratorstring'jackkernel'Integrator identifier for LI.FI
maxRetriesnumber3Maximum retry attempts for LI.FI calls

YellowConfig

OptionTypeRequiredDescription
custodyAddressstringCustody contract address
adjudicatorAddressstringAdjudicator contract address
chainIdnumberChain ID for Yellow Network
walletClientWalletClientViem wallet client for signing

Environment Variables

You can use environment variables for configuration:

const sdk = new JACK_SDK({
baseUrl: process.env.JACK_API_URL || 'https://api.jack.example',
headers: {
'Authorization': `Bearer ${process.env.JACK_API_TOKEN}`
},
lifi: {
integrator: process.env.LIFI_INTEGRATOR || 'jackkernel'
}
});

Verification

Verify your installation:

import { JACK_SDK } from '@jack-kernel/sdk';

const sdk = new JACK_SDK({
baseUrl: 'https://api.jack.example'
});

console.log('SDK initialized successfully!');
console.log('Managers available:', {
intents: !!sdk.intents,
execution: !!sdk.execution,
costs: !!sdk.costs,
agent: !!sdk.agent,
lifi: !!sdk.lifi,
yellow: !!sdk.yellow
});

Next Steps

Continue exploring the SDK documentation to learn more about creating and managing intents.