Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/1inch/cross-chain-sdk/llms.txt

Use this file to discover all available pages before exploring further.

The SDK class is the primary interface for interacting with the 1inch Cross-Chain Fusion protocol. It provides methods for getting quotes, creating orders, submitting orders, and managing order lifecycle.

Constructor

constructor(config: CrossChainSDKConfigParams)
Initializes a new SDK instance with the provided configuration.
config
CrossChainSDKConfigParams
required
Configuration object for the SDK. See SDK Config for details.
Example:
import { SDK } from '@1inch/cross-chain-sdk'

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

Properties

api
FusionApi
Public readonly instance of the Fusion API client used for making HTTP requests to the 1inch Fusion API.

Quote Methods

getQuote

async getQuote(params: QuoteParams): Promise<Quote>
Retrieves a quote for a cross-chain swap with recommended presets.
params
QuoteParams
required
Parameters for the quote request
Returns: Promise<Quote> - Quote object containing swap details and presets Example:
const quote = await sdk.getQuote({
  srcChainId: NetworkEnum.ETHEREUM,
  dstChainId: NetworkEnum.BINANCE,
  srcTokenAddress: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // USDC
  dstTokenAddress: '0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d', // USDC on BSC
  amount: '1000000', // 1 USDC
  walletAddress: '0x...',
  enableEstimate: true
})

getQuoteWithCustomPreset

async getQuoteWithCustomPreset(
  params: QuoteParams,
  body: QuoteCustomPresetParams
): Promise<Quote>
Retrieves a quote with a custom auction preset instead of using recommended presets.
params
QuoteParams
required
Quote parameters (same as getQuote)
body
QuoteCustomPresetParams
required
Custom preset configuration
Returns: Promise<Quote> - Quote object with custom preset applied Example:
const quote = await sdk.getQuoteWithCustomPreset(
  {
    srcChainId: NetworkEnum.ETHEREUM,
    dstChainId: NetworkEnum.POLYGON,
    srcTokenAddress: '0x...',
    dstTokenAddress: '0x...',
    amount: '1000000',
    walletAddress: '0x...',
    enableEstimate: true
  },
  {
    customPreset: {
      auctionDuration: 180,
      startAuctionIn: 30,
      initialRateBump: 10000,
      auctionPoints: [
        { delay: 60, coefficient: 5000 },
        { delay: 120, coefficient: 2500 }
      ]
    }
  }
)

Order Creation Methods

createOrder

createOrder(quote: Quote, params: OrderParams): PreparedOrder
Creates a cross-chain order from a quote. This method prepares the order for signing and submission but does not submit it.
quote
Quote
required
Quote object obtained from getQuote or getQuoteWithCustomPreset. Must have enableEstimate: true to generate a quoteId.
params
OrderParams
required
Order creation parameters
Returns: PreparedOrder object containing:
order
EvmCrossChainOrder | SvmCrossChainOrder
The created cross-chain order object
hash
string
The order hash
quoteId
string
The quote ID from the original quote
Example:
import { HashLock } from '@1inch/cross-chain-sdk'

const secret = '0x1234...'
const hashLock = HashLock.forSingleFill(secret)

const preparedOrder = sdk.createOrder(quote, {
  walletAddress: '0x...',
  hashLock,
  secretHashes: [hashLock.secretHashes[0]],
  receiver: '0x...' // optional
})

Order Submission Methods

submitOrder

async submitOrder(
  srcChainId: SupportedChain,
  order: EvmCrossChainOrder,
  quoteId: string,
  secretHashes: string[]
): Promise<OrderInfo>
Submits an EVM order to the relayer. This method automatically signs the order using the configured blockchainProvider.
For orders involving native assets (ETH, MATIC, BNB, etc.), use submitNativeOrder instead.
srcChainId
SupportedChain
required
Source chain ID
order
EvmCrossChainOrder
required
The EVM cross-chain order to submit
quoteId
string
required
Quote ID from the original quote
secretHashes
string[]
required
Array of secret hashes for the order
Returns: Promise<OrderInfo> containing:
order
LimitOrderV4Struct
The order struct
signature
string
The order signature
quoteId
string
The quote ID
orderHash
string
The order hash
extension
string
Encoded order extension data
Example:
const orderInfo = await sdk.submitOrder(
  NetworkEnum.ETHEREUM,
  order,
  quoteId,
  secretHashes
)

console.log('Order submitted:', orderInfo.orderHash)

submitNativeOrder

async submitNativeOrder(
  srcChainId: SupportedChain,
  order: EvmCrossChainOrder,
  maker: EvmAddress,
  quoteId: string,
  secretHashes: string[]
): Promise<OrderInfo>
Submits an order involving native assets (ETH, MATIC, BNB, etc.) to the relayer.
Native asset orders must also be submitted on-chain using NativeOrdersFactory.create in addition to being submitted to the relayer.
srcChainId
SupportedChain
required
Source chain ID
order
EvmCrossChainOrder
required
The EVM cross-chain order to submit
maker
EvmAddress
required
Maker’s EVM address
quoteId
string
required
Quote ID from the original quote
secretHashes
string[]
required
Array of secret hashes for the order
Returns: Promise<OrderInfo> - Same structure as submitOrder

placeOrder

async placeOrder(quote: Quote, params: OrderParams): Promise<OrderInfo>
Convenience method that combines createOrder and submitOrder in a single call. Only works for EVM orders.
quote
Quote
required
Quote object with enableEstimate: true
params
OrderParams
required
Order parameters (same as createOrder)
Returns: Promise<OrderInfo> - Order information after submission Throws: Error if the order is a Solana order (Solana orders must use announceOrder and be placed on-chain) Example:
const orderInfo = await sdk.placeOrder(quote, {
  walletAddress: '0x...',
  hashLock,
  secretHashes: [hashLock.secretHashes[0]]
})

Signing Methods

signOrder

async signOrder(
  order: EvmCrossChainOrder,
  srcChainId: SupportedChain
): Promise<string>
Signs an EVM order using the blockchainProvider configured in the SDK.
For native asset orders, use signNativeOrder instead.
order
EvmCrossChainOrder
required
The order to sign
srcChainId
SupportedChain
required
Source chain ID
Returns: Promise<string> - The signature Throws: Error if blockchainProvider is not configured

signNativeOrder

signNativeOrder(
  order: EvmCrossChainOrder,
  maker: EvmAddress
): string
Generates a signature for native asset orders. This is a synchronous method that creates a special signature for native orders.
order
EvmCrossChainOrder
required
The native order to sign
maker
EvmAddress
required
Maker’s address
Returns: string - The native order signature

Solana Order Methods

announceOrder

async announceOrder(
  order: SvmCrossChainOrder,
  quoteId: string,
  secretHashes: string[]
): Promise<string>
Announces a Solana order to the relayer before on-chain creation. This is required because on-chain data does not contain auction details.
After announcing, you must also create the order on-chain using the appropriate Solana program instructions.
order
SvmCrossChainOrder
required
The Solana cross-chain order
quoteId
string
required
Quote ID from the original quote
secretHashes
string[]
required
Array of secret hashes (length must match the number of secrets in hashLock)
Returns: Promise<string> - The order hash Throws: Error if secret hashes length doesn’t match the expected count Example:
const orderHash = await sdk.announceOrder(
  solanaOrder,
  quoteId,
  secretHashes
)

console.log('Order announced:', orderHash)
// Now create the order on-chain...

Order Status and History Methods

getOrderStatus

async getOrderStatus(orderHash: string): Promise<OrderStatusResponse>
Retrieves the current status and details of an order.
orderHash
string
required
The order hash to query
Returns: Promise<OrderStatusResponse> containing:
orderHash
string
The order hash
status
OrderStatus
Current order status: pending, executed, expired, cancelled, refunding, or refunded
validation
ValidationStatus
Validation status of the order
points
AuctionPoint[]
Auction curve points
approximateTakingAmount
string
Estimated amount to be received
fills
Fill[]
Array of fill executions for this order
auctionStartDate
number
Auction start timestamp (Unix seconds)
auctionDuration
number
Auction duration in seconds
createdAt
number
Order creation timestamp (Unix milliseconds)
cancelable
boolean
Whether the order can be cancelled
Example:
const status = await sdk.getOrderStatus(orderHash)

if (status.status === OrderStatus.Executed) {
  console.log('Order executed!')
  console.log('Fills:', status.fills)
}

getActiveOrders

async getActiveOrders(
  params?: ActiveOrdersRequestParams
): Promise<ActiveOrdersResponse>
Retrieves active orders with optional filtering and pagination.
params
ActiveOrdersRequestParams
Optional filter and pagination parameters
Returns: Promise<ActiveOrdersResponse> - Paginated list of active orders
meta
PaginationMeta
Pagination metadata including total items, pages, etc.
items
ActiveOrder[]
Array of active orders
Example:
const activeOrders = await sdk.getActiveOrders({
  srcChainId: NetworkEnum.ETHEREUM,
  page: 1,
  limit: 50
})

console.log(`Found ${activeOrders.meta.totalItems} active orders`)

getOrdersByMaker

async getOrdersByMaker(
  params: OrdersByMakerParams
): Promise<OrdersByMakerResponse>
Retrieves orders created by a specific maker address with filtering options.
params
OrdersByMakerParams
required
Filter parameters
Returns: Promise<OrdersByMakerResponse> - Paginated list of orders Example:
const myOrders = await sdk.getOrdersByMaker({
  address: '0x...',
  srcChain: NetworkEnum.ETHEREUM,
  page: 1,
  limit: 20
})

Secret Management Methods

getReadyToAcceptSecretFills

async getReadyToAcceptSecretFills(
  orderHash: string
): Promise<ReadyToAcceptSecretFills>
Retrieves fills that are ready to accept secret submission for an order.
orderHash
string
required
The order hash
Returns: Promise<ReadyToAcceptSecretFills> containing:
fills
ReadyToAcceptSecretFill[]
Array of fills ready for secret submission

submitSecret

async submitSecret(orderHash: string, secret: string): Promise<void>
Submits the secret for an order to enable withdrawal on the destination chain.
orderHash
string
required
The order hash
secret
string
required
The secret value (must match the hash lock)
Returns: Promise<void> Example:
// Check which fills are ready
const ready = await sdk.getReadyToAcceptSecretFills(orderHash)

if (ready.fills.length > 0) {
  // Submit the secret
  await sdk.submitSecret(orderHash, secret)
  console.log('Secret submitted!')
}

getPublishedSecrets

async getPublishedSecrets(
  orderHash: string
): Promise<PublishedSecretsResponse>
Retrieves all published secrets for an order.
orderHash
string
required
The order hash
Returns: Promise<PublishedSecretsResponse> containing:
orderType
OrderType
Order type: SingleFill or MultipleFills
secrets
PublicSecret[]
Array of published secrets with escrow details
secretHashes
string[]
Array of secret hashes (empty for single fill orders)

Order Cancellation Methods

buildCancelOrderCallData

async buildCancelOrderCallData(orderHash: string): Promise<string>
Builds the calldata for cancelling an EVM order on-chain.
This method only works for orders with EVM source chains. It will throw an error for Solana orders.
orderHash
string
required
The order hash to cancel
Returns: Promise<string> - Encoded calldata for the cancel transaction Throws:
  • Error if order is not found
  • Error if source chain is not EVM
Example:
const calldata = await sdk.buildCancelOrderCallData(orderHash)

// Use the calldata to submit a cancel transaction
await signer.sendTransaction({
  to: SETTLEMENT_CONTRACT_ADDRESS,
  data: calldata
})

getCancellableOrders

async getCancellableOrders(
  chainType?: ChainType,
  page?: number,
  limit?: number,
  orderVersion?: ApiVersion[]
): Promise<PaginationOutput<EvmOrderCancellationData> | PaginationOutput<SvmOrderCancellationData>>
Retrieves on-chain created orders that can be cancelled by a resolver for a premium.
chainType
ChainType
Chain type to filter: ChainType.EVM or ChainType.SVM (default: ChainType.SVM)
page
number
Page number (default: 1)
limit
number
Items per page (default: 100)
orderVersion
ApiVersion[]
Filter by API version
Returns: Paginated list of cancellable orders. Return type depends on chainType: For EVM orders:
items
EvmOrderCancellationData[]
For Solana orders:
items
SvmOrderCancellationData[]
Example:
import { ChainType } from '@1inch/cross-chain-sdk'

// Get cancellable Solana orders
const svmOrders = await sdk.getCancellableOrders(
  ChainType.SVM,
  1,
  50
)

// Get cancellable EVM orders
const evmOrders = await sdk.getCancellableOrders(
  ChainType.EVM,
  1,
  50
)

Public Actions

getReadyToExecutePublicActions

async getReadyToExecutePublicActions(
  filter?: OrderVersionFilter
): Promise<ReadyToExecutePublicActions>
Retrieves public actions (withdrawals, cancellations) that are ready to be executed.
filter
OrderVersionFilter
Optional filter
Returns: Promise<ReadyToExecutePublicActions> containing:
actions
ReadyToExecutePublicAction[]
Array of executable public actions

Complete Workflow Example

Here’s a complete example showing the typical order flow:
import { SDK, HashLock, NetworkEnum } from '@1inch/cross-chain-sdk'

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

// 2. Get a quote
const quote = await sdk.getQuote({
  srcChainId: NetworkEnum.ETHEREUM,
  dstChainId: NetworkEnum.POLYGON,
  srcTokenAddress: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
  dstTokenAddress: '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174',
  amount: '1000000',
  walletAddress: '0x...',
  enableEstimate: true
})

// 3. Create hash lock and order
const secret = '0x' + '1'.repeat(64)
const hashLock = HashLock.forSingleFill(secret)

const { order, hash, quoteId } = sdk.createOrder(quote, {
  walletAddress: '0x...',
  hashLock,
  secretHashes: [hashLock.secretHashes[0]]
})

// 4. Submit the order
const orderInfo = await sdk.submitOrder(
  quote.srcChainId,
  order,
  quoteId,
  [hashLock.secretHashes[0]]
)

console.log('Order submitted:', orderInfo.orderHash)

// 5. Monitor order status
const status = await sdk.getOrderStatus(orderInfo.orderHash)
console.log('Order status:', status.status)

// 6. When ready, submit secret
const readyFills = await sdk.getReadyToAcceptSecretFills(orderInfo.orderHash)

if (readyFills.fills.length > 0) {
  await sdk.submitSecret(orderInfo.orderHash, secret)
  console.log('Secret submitted - withdrawal can now occur')
}