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 SDK provides two methods for submitting orders to the relayer: submitOrder for standard orders and submitNativeOrder for orders involving native assets (ETH, MATIC, etc.). Both methods handle signing and submission to the relayer network.

submitOrder

Submit a standard ERC-20 token order to the relayer.

Method Signature

async submitOrder(
  srcChainId: SupportedChain,
  order: EvmCrossChainOrder,
  quoteId: string,
  secretHashes: string[]
): Promise<OrderInfo>

Parameters

srcChainId
SupportedChain
required
The source chain ID where the order originates
order
EvmCrossChainOrder
required
The EVM cross-chain order instance from createOrder
quoteId
string
required
The quote ID from the prepared order
secretHashes
string[]
required
Array of secret hashes for the order. Must match the order’s hash lock configuration

Returns

OrderInfo
object
order
LimitOrderV4Struct
The order structure submitted to the relayer
signature
string
The EIP-712 signature of the order
quoteId
string
The quote ID associated with the order
orderHash
string
The unique hash identifying the order
extension
string
Encoded extension data containing escrow parameters

submitNativeOrder

Submit an order involving native assets (ETH, MATIC, etc.). Native orders require on-chain submission in addition to relayer submission.

Method Signature

async submitNativeOrder(
  srcChainId: SupportedChain,
  order: EvmCrossChainOrder,
  maker: EvmAddress,
  quoteId: string,
  secretHashes: string[]
): Promise<OrderInfo>

Parameters

srcChainId
SupportedChain
required
The source chain ID where the order originates
order
EvmCrossChainOrder
required
The EVM cross-chain order instance created for native assets
maker
EvmAddress
required
The maker’s address (required for native order signatures)
quoteId
string
required
The quote ID from the prepared order
secretHashes
string[]
required
Array of secret hashes for the order

Returns

Returns the same OrderInfo structure as submitOrder.

Differences Between Methods

FeaturesubmitOrdersubmitNativeOrder
Asset TypeERC-20 tokensNative assets (ETH, MATIC, etc.)
Signature TypeEIP-712 typed data signatureNative signature
Blockchain ProviderRequired in SDK configNot required
On-chain SubmissionNot neededRequired via NativeOrderFactory.create
Maker ParameterFrom orderExplicitly provided

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',
  blockchainProvider: yourProvider // Required for signing
})

// Create order
const { order, quoteId } = sdk.createOrder(quote, params)

// Submit to relayer
const orderInfo = await sdk.submitOrder(
  1, // Ethereum
  order,
  quoteId,
  params.secretHashes
)

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

RelayerRequest Types

The SDK internally uses different request types for EVM and Solana orders:

RelayerRequestEvm

type RelayerRequestEvm = {
  order: LimitOrderV4Struct
  signature: string
  quoteId: string
  extension: string
  srcChainId: SupportedChain
  secretHashes?: string[] // Optional for single-fill orders
}

RelayerRequestSvm

type RelayerRequestSvm = {
  order: SolanaOrderJSON
  auctionOrderHash: string
  quoteId: string
  secretHashes?: string[] // Optional for single-fill orders
}

Error Handling

try {
  const orderInfo = await sdk.submitOrder(
    srcChainId,
    order,
    quoteId,
    secretHashes
  )
} catch (error) {
  if (error.message.includes('blockchainProvider has not set')) {
    console.error('Blockchain provider required for submitOrder')
  } else if (error.message.includes('secretHashes')) {
    console.error('Invalid number of secret hashes')
  } else {
    console.error('Order submission failed:', error)
  }
}

Secret Hash Validation

Both methods validate secret hashes:
  • Single-fill orders (multipleFillsAllowed: false): Only 1 secret hash allowed
  • Multi-fill orders (multipleFillsAllowed: true): Number of hashes must equal hashLock.getPartsCount() + 1
// Multi-fill order example
const secrets = HashLock.generateSecrets(3) // Generates 3 secrets
const hashLock = HashLock.forMultipleFills(secrets)

// This will succeed
await sdk.submitOrder(chainId, order, quoteId, secrets.map(s => s.hash))

// This will throw an error
await sdk.submitOrder(chainId, order, quoteId, ['single-hash'])

Notes

  • submitOrder requires blockchainProvider in SDK configuration for signing
  • submitNativeOrder generates signatures internally and doesn’t require a provider
  • Native orders must be submitted both off-chain (to relayer) and on-chain
  • The extension field in OrderInfo contains encoded escrow parameters
  • For single-fill orders, secretHashes can be a single-element array
  • Signature format differs between standard and native orders