Skip to main content

Installation

Get started with the 1inch Cross Chain SDK by installing the package and setting up your development environment.

Package Installation

Install the SDK using your preferred package manager:
npm install @1inch/cross-chain-sdk

Requirements

The SDK requires Node.js version 18.16.0 or higher. Check your Node version with node --version.

Peer Dependencies

The SDK has one optional peer dependency:
package.json
{
  "peerDependencies": {
    "assert": "^2.0.0"
  }
}
This dependency is automatically handled by most package managers and is only required in certain environments.

Setup with Web3.js

If you’re using Web3.js as your blockchain provider, here’s how to initialize the SDK:
1

Import dependencies

import { SDK, PrivateKeyProviderConnector, NetworkEnum } from '@1inch/cross-chain-sdk'
import Web3 from 'web3'
2

Configure your environment

const privateKey = '0x...'  // Your wallet private key
const rpc = 'https://ethereum-rpc.publicnode.com'  // RPC endpoint
const authKey = 'your-auth-key'  // Get from https://portal.1inch.dev
const source = 'sdk-tutorial'  // Identifier for your integration
Never hardcode private keys in production. Use environment variables or secure key management solutions.
3

Initialize Web3 and wallet

const web3 = new Web3(rpc)
const walletAddress = web3.eth.accounts.privateKeyToAccount(privateKey).address
4

Create SDK instance

const sdk = new SDK({
  url: 'https://api.1inch.com/fusion-plus',
  authKey,
  blockchainProvider: new PrivateKeyProviderConnector(privateKey, web3)
})
The blockchainProvider is only required for creating orders. You can omit it if you only need to fetch quotes or query order status.

Setup with Ethers.js

For Ethers.js v6 users, create a custom provider connector:
1

Import dependencies

import { SDK, PrivateKeyProviderConnector } from '@1inch/cross-chain-sdk'
import { JsonRpcProvider, Wallet } from 'ethers'
2

Create provider connector

const ethersRpcProvider = new JsonRpcProvider('https://ethereum-rpc.publicnode.com')

const ethersProviderConnector = {
  eth: {
    call(transactionConfig): Promise<string> {
      return ethersRpcProvider.call(transactionConfig)
    }
  },
  extend(): void {}
}
3

Initialize SDK with Ethers provider

const privateKey = '0x...'
const authKey = 'your-auth-key'

const connector = new PrivateKeyProviderConnector(
  privateKey,
  ethersProviderConnector
)

const sdk = new SDK({
  url: 'https://api.1inch.com/fusion-plus',
  authKey,
  blockchainProvider: connector
})

const wallet = new Wallet(privateKey, ethersRpcProvider)

Authentication

All SDK requests require an authentication key from the 1inch Developer Portal.
1

Visit the Developer Portal

Navigate to portal.1inch.dev and create an account if you don’t have one.
2

Generate an API key

Go to the API Keys section and generate a new key for the Fusion+ API.
3

Store securely

Add your API key to your environment variables:
.env
INCH_AUTH_KEY=your-api-key-here
4

Use in SDK configuration

const sdk = new SDK({
  url: 'https://api.1inch.com/fusion-plus',
  authKey: process.env.INCH_AUTH_KEY,
  blockchainProvider: connector
})

SDK Configuration Options

The SDK constructor accepts the following configuration parameters:
ParameterTypeRequiredDescription
urlstringYesFusion+ API endpoint (use https://api.1inch.com/fusion-plus)
authKeystringYesYour 1inch Developer Portal API key
blockchainProviderBlockchainProviderConnectorNoProvider for signing transactions (required for order creation)
httpProviderHttpProviderConnectorNoCustom HTTP client for API requests

Verify Installation

Test your setup by fetching a quote:
import { SDK, NetworkEnum } from '@1inch/cross-chain-sdk'

const sdk = new SDK({
  url: 'https://api.1inch.com/fusion-plus',
  authKey: process.env.INCH_AUTH_KEY
})

async function test() {
  const quote = await sdk.getQuote({
    srcChainId: NetworkEnum.POLYGON,
    dstChainId: NetworkEnum.BINANCE,
    srcTokenAddress: '0xc2132d05d31c914a87c6611c10748aeb04b58e8f', // USDT on Polygon
    dstTokenAddress: '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee', // BNB
    amount: '10000000', // 10 USDT
    enableEstimate: true
  })
  
  console.log('Quote received:', quote)
}

test()
If you see quote data in your console, you’re ready to start building!

Next Steps

Quickstart Guide

Build your first cross-chain swap

EVM to EVM Swaps

Learn the complete swap workflow

Build docs developers (and LLMs) love