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
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.
Parameters for the quote request Show QuoteParams properties
Destination token address
Amount of source token to swap (in wei/smallest unit)
Wallet address of the maker
Enable estimation to receive a quoteId (required for order creation)
Permit signature for gasless approval
Integrator fee configuration
Source identifier for analytics
Whether to use Permit2 for token approval
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.
Quote parameters (same as getQuote)
body
QuoteCustomPresetParams
required
Custom preset configuration Show QuoteCustomPresetParams properties
Custom auction preset configuration defining auction parameters
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 object obtained from getQuote or getQuoteWithCustomPreset. Must have enableEstimate: true to generate a quoteId.
Order creation parameters Show OrderParams properties
Hash lock configuration for atomic swap security
Array of secret hashes for the order
Permit signature (without first 20 bytes of token address)
Receiver address on destination chain (defaults to walletAddress)
Auction preset to use (defaults to recommended preset)
Unique nonce for the order (can be serial or random)
Source identifier for analytics
Custom preset configuration
Returns: PreparedOrder object containing:
order
EvmCrossChainOrder | SvmCrossChainOrder
The created cross-chain order object
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.
order
EvmCrossChainOrder
required
The EVM cross-chain order to submit
Quote ID from the original quote
Array of secret hashes for the order
Returns: Promise<OrderInfo> containing:
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.
order
EvmCrossChainOrder
required
The EVM cross-chain order to submit
Quote ID from the original quote
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 object with enableEstimate: true
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
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
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
Quote ID from the original quote
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.
Returns: Promise<OrderStatusResponse> containing:
Current order status: pending, executed, expired, cancelled, refunding, or refunded
Validation status of the order
Estimated amount to be received
Array of fill executions for this order
Auction start timestamp (Unix seconds)
Auction duration in seconds
Order creation timestamp (Unix milliseconds)
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 Show ActiveOrdersRequestParams properties
Filter by destination chain
Items per page (default: 100)
Returns: Promise<ActiveOrdersResponse> - Paginated list of active orders
Pagination metadata including total items, pages, etc.
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 Show OrdersByMakerParams properties
Filter by destination chain
Filter by source token address
Filter by destination token address
Filter by either source or destination token
Filter orders created after this timestamp
Filter orders created before this timestamp
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.
Returns: Promise<ReadyToAcceptSecretFills> containing:
fills
ReadyToAcceptSecretFill[]
Array of fills ready for secret submission Show ReadyToAcceptSecretFill properties
Source escrow deployment transaction hash
Destination escrow deployment transaction hash
submitSecret
async submitSecret ( orderHash : string , secret : string ): Promise < void >
Submits the secret for an order to enable withdrawal on the destination chain.
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.
Returns: Promise<PublishedSecretsResponse> containing:
Order type: SingleFill or MultipleFills
Array of published secrets with escrow details
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.
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.
Chain type to filter: ChainType.EVM or ChainType.SVM (default: ChainType.SVM)
Items per page (default: 100)
Returns: Paginated list of cancellable orders. Return type depends on chainType:
For EVM orders:
items
EvmOrderCancellationData[]
Show EvmOrderCancellationData properties
Remaining amount to be filled
For Solana orders:
items
SvmOrderCancellationData[]
Show SvmOrderCancellationData properties
cancellationConfig
ResolverCancellationConfig
Cancellation configuration including premium and auction duration
Whether the source asset is native SOL
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.
Optional filter Show OrderVersionFilter properties
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' )
}