Skip to main content

Overview

The SDK class is the main entry point for interacting with the 1inch Cross Chain SDK. It provides methods for getting quotes, creating orders, submitting orders, and querying order status.

Constructor

SDK(config)

Creates a new SDK instance.
config
CrossChainSDKConfigParams
required
Configuration parameters for the SDK
import { SDK } from '@1inch/cross-chain-sdk'

const sdk = new SDK({
  url: 'https://api.1inch.dev/fusion-plus',
  authKey: 'your-api-key'
})

Properties

api
FusionApi
The underlying FusionApi instance for making API requests

Quote Methods

getQuote(params)

Get a quote for a cross-chain swap.
params
QuoteParams
required
Quote request parameters
quote
Quote
Quote object containing swap details and presets
const quote = await sdk.getQuote({
  srcChainId: 1, // Ethereum
  dstChainId: 137, // Polygon
  srcTokenAddress: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', // USDC
  dstTokenAddress: '0x2791bca1f2de4661ed88a30c99a7a9449aa84174', // USDC on Polygon
  amount: '1000000', // 1 USDC
  walletAddress: '0x...',
  enableEstimate: true
})

getQuoteWithCustomPreset(params, body)

Get a quote with custom auction parameters.
params
QuoteParams
required
Quote request parameters (same as getQuote)
body
QuoteCustomPresetParams
required
Custom preset configuration
quote
Quote
Quote object with custom preset applied
const quote = await sdk.getQuoteWithCustomPreset(
  {
    srcChainId: 1,
    dstChainId: 137,
    srcTokenAddress: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
    dstTokenAddress: '0x2791bca1f2de4661ed88a30c99a7a9449aa84174',
    amount: '1000000',
    walletAddress: '0x...',
    enableEstimate: true
  },
  {
    customPreset: {
      auctionDuration: 180,
      auctionStartAmount: '990000',
      auctionEndAmount: '980000'
    }
  }
)

Order Methods

createOrder(quote, params)

Create an order from a quote without submitting it.
quote
Quote
required
Quote object from getQuote (must have enableEstimate: true)
params
OrderParams
required
Order creation parameters
preparedOrder
PreparedOrder
Prepared order ready for signing and submission
const preparedOrder = sdk.createOrder(quote, {
  walletAddress: '0x...',
  hashLock: hashLock,
  secretHashes: ['0x...']
})

submitOrder(srcChainId, order, quoteId, secretHashes)

Submit an EVM order to the relayer.
For orders from native assets, use submitNativeOrder instead.
srcChainId
SupportedChain
required
Source chain ID
order
EvmCrossChainOrder
required
EVM cross-chain order
quoteId
string
required
Quote ID from the prepared order
secretHashes
string[]
required
Array of secret hashes
orderInfo
OrderInfo
Submitted order information
const orderInfo = await sdk.submitOrder(
  1, // Ethereum
  order,
  quoteId,
  secretHashes
)

submitNativeOrder(srcChainId, order, maker, quoteId, secretHashes)

Submit an order from native assets (ETH, MATIC, etc.).
Native orders must also be submitted on-chain using NativeOrdersFactory.
srcChainId
SupportedChain
required
Source chain ID
order
EvmCrossChainOrder
required
EVM cross-chain order
maker
EvmAddress
required
Maker’s address
quoteId
string
required
Quote ID
secretHashes
string[]
required
Array of secret hashes
orderInfo
OrderInfo
Submitted order information

announceOrder(order, quoteId, secretHashes)

Announce a Solana order to the relayer before on-chain creation.
order
SvmCrossChainOrder
required
Solana cross-chain order
quoteId
string
required
Quote ID
secretHashes
string[]
required
Array of secret hashes
orderHash
string
Order hash for tracking
const orderHash = await sdk.announceOrder(
  solanaOrder,
  quoteId,
  secretHashes
)

placeOrder(quote, params)

Convenience method that creates and submits an order in one call.
quote
Quote
required
Quote object (must have enableEstimate: true)
params
OrderParams
required
Order parameters
orderInfo
OrderInfo
Submitted order information
const orderInfo = await sdk.placeOrder(quote, {
  walletAddress: '0x...',
  hashLock: hashLock,
  secretHashes: ['0x...']
})

Order Status Methods

getActiveOrders(params)

Get list of active orders.
params
ActiveOrdersRequestParams
Filter parameters
response
ActiveOrdersResponse
Paginated list of active orders
const activeOrders = await sdk.getActiveOrders({
  srcChainId: 1,
  page: 1,
  limit: 10
})

getOrderStatus(orderHash)

Get detailed status of a specific order.
orderHash
string
required
Order hash to query
status
OrderStatusResponse
Detailed order status
const status = await sdk.getOrderStatus('0x...')
console.log(status.status) // 'pending' | 'executed' | etc.

getOrdersByMaker(params)

Get orders created by a specific maker address.
params
OrdersByMakerParams
required
Query parameters
response
OrdersByMakerResponse
Paginated list of orders by maker
const orders = await sdk.getOrdersByMaker({
  address: '0x...',
  srcChain: 1,
  page: 1,
  limit: 20
})

Advanced Methods

signOrder(order, srcChainId)

Sign an order using the configured blockchain provider.
order
EvmCrossChainOrder
required
Order to sign
srcChainId
SupportedChain
required
Source chain ID
signature
string
Order signature

signNativeOrder(order, maker)

Sign a native order.
order
EvmCrossChainOrder
required
Order to sign
maker
EvmAddress
required
Maker address
signature
string
Order signature

buildCancelOrderCallData(orderHash)

Build calldata for cancelling an EVM order.
orderHash
string
required
Order hash to cancel
callData
string
Encoded cancel order calldata
const callData = await sdk.buildCancelOrderCallData('0x...')

getCancellableOrders(chainType, page, limit, orderVersion)

Get orders that can be cancelled by resolvers for premium.
chainType
ChainType
Chain type filter (EVM or SVM, defaults to SVM)
page
number
Page number (defaults to 1)
limit
number
Results per page (defaults to 100)
orderVersion
ApiVersion[]
Filter by order version
response
PaginationOutput<EvmOrderCancellationData> | PaginationOutput<SvmOrderCancellationData>
Paginated list of cancellable orders

getReadyToAcceptSecretFills(orderHash)

Get fills ready to accept secret publication.
orderHash
string
required
Order hash
fills
ReadyToAcceptSecretFills
Array of fills ready for secrets

getReadyToExecutePublicActions(filter)

Get public actions (withdrawals, cancellations) ready to execute.
filter
OrderVersionFilter
Version filter
actions
ReadyToExecutePublicActions
Array of executable public actions

getPublishedSecrets(orderHash)

Get published secrets for an order.
orderHash
string
required
Order hash
secrets
PublishedSecretsResponse
Published secrets data

submitSecret(orderHash, secret)

Submit a secret for an order.
orderHash
string
required
Order hash
secret
string
required
Secret to publish
await sdk.submitSecret('0x...', '0xsecret...')

Build docs developers (and LLMs) love