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.

Overview

The createOrder method prepares a cross-chain order from a quote. It returns a PreparedOrder object containing the order instance, order hash, and quote ID. The order must be created with enableEstimate=true in the quote.

Method Signature

creatOrder(quote: Quote, params: OrderParams): PreparedOrder

Parameters

quote
Quote
required
The quote object obtained from getQuote(). Must have enableEstimate=true and contain a quoteId.
params
OrderParams
required
Order creation parameters
walletAddress
string
required
The maker’s wallet address
hashLock
HashLock
required
Hash lock for the escrow mechanism
secretHashes
string[]
required
Array of secret hashes for order fulfillment. Single hash for single-fill orders, multiple hashes for multi-fill orders
receiver
string
Destination chain receiver address. Defaults to walletAddress (maker address) if not provided. Required for Solana orders
preset
PresetEnum
Custom preset for order parameters. Uses recommended preset by default
nonce
bigint
Unique nonce for the wallet address. Can be serial or randomly generated
permit
string
Permit signature (without the first 20 bytes of token address)
source
string
Source identifier for tracking
isPermit2
boolean
Whether to use Permit2 for approvals
customPreset
CustomPreset
Custom preset configuration

Returns

PreparedOrder
object
order
EvmCrossChainOrder | SvmCrossChainOrder
The created order instance (EVM or Solana)
hash
string
The order hash (hex string for EVM, base58 for Solana)
quoteId
string
The quote ID from the original quote

Example Usage

import { SDK, HashLock } from '@1inch/cross-chain-sdk'

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

// Get quote with enableEstimate
const quote = await sdk.getQuote({
  srcChainId: 1,
  dstChainId: 137,
  srcTokenAddress: '0x...',
  dstTokenAddress: '0x...',
  amount: '1000000000000000000',
  walletAddress: '0xYourAddress',
  enableEstimate: true
})

// Create hash lock and secrets
const secrets = HashLock.generateSecrets()
const hashLock = HashLock.forMultipleFills(secrets)

// Create order
const preparedOrder = sdk.createOrder(quote, {
  walletAddress: '0xYourAddress',
  hashLock,
  secretHashes: secrets.map(s => s.hash),
  receiver: '0xReceiverAddress'
})

console.log('Order Hash:', preparedOrder.hash)
console.log('Quote ID:', preparedOrder.quoteId)

Error Handling

try {
  const preparedOrder = sdk.createOrder(quote, params)
} catch (error) {
  if (error.message.includes('request quote with enableEstimate=true')) {
    // Quote was not created with enableEstimate flag
    console.error('Quote must have enableEstimate=true')
  }
}

Notes

  • The quote must be obtained with enableEstimate: true to contain a valid quoteId
  • For Solana orders, the receiver parameter is required
  • The order is not yet submitted to the relayer at this point - use submitOrder or announceOrder to submit
  • The returned order hash is in hex format for EVM chains and base58 format for Solana
  • Secret hashes must match the hash lock configuration:
    • Single-fill orders: 1 secret hash
    • Multi-fill orders: Number of secrets must equal hashLock.getPartsCount() + 1