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
The source chain ID where the order originates
order
EvmCrossChainOrder
required
The EVM cross-chain order instance from createOrder
The quote ID from the prepared order
Array of secret hashes for the order. Must match the order’s hash lock configuration
Returns
The order structure submitted to the relayer
The EIP-712 signature of the order
The quote ID associated with the order
The unique hash identifying the order
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
The source chain ID where the order originates
order
EvmCrossChainOrder
required
The EVM cross-chain order instance created for native assets
The maker’s address (required for native order signatures)
The quote ID from the prepared order
Array of secret hashes for the order
Returns
Returns the same OrderInfo structure as submitOrder.
Differences Between Methods
| Feature | submitOrder | submitNativeOrder |
|---|
| Asset Type | ERC-20 tokens | Native assets (ETH, MATIC, etc.) |
| Signature Type | EIP-712 typed data signature | Native signature |
| Blockchain Provider | Required in SDK config | Not required |
| On-chain Submission | Not needed | Required via NativeOrderFactory.create |
| Maker Parameter | From order | Explicitly provided |
Example Usage
Standard Order
Native Order
Complete Flow
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)
import { SDK, EvmAddress } from '@1inch/cross-chain-sdk'
const sdk = new SDK({
url: 'https://api.1inch.dev/fusion-plus',
authKey: 'your-auth-key'
// blockchainProvider not required for native orders
})
// Create native order
const { order, quoteId } = sdk.createOrder(quote, params)
const makerAddress = EvmAddress.fromString('0xYourAddress')
// Submit to relayer
const orderInfo = await sdk.submitNativeOrder(
1, // Ethereum
order,
makerAddress,
quoteId,
params.secretHashes
)
// IMPORTANT: Also submit on-chain
// await nativeOrderFactory.create(orderInfo.order, orderInfo.signature)
console.log('Native order submitted:', orderInfo.orderHash)
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
})
// 1. Get quote
const quote = await sdk.getQuote({
srcChainId: 1,
dstChainId: 137,
srcTokenAddress: '0x...',
dstTokenAddress: '0x...',
amount: '1000000000000000000',
walletAddress: '0xYourAddress',
enableEstimate: true
})
// 2. Create secrets and hash lock
const secrets = HashLock.generateSecrets()
const hashLock = HashLock.forMultipleFills(secrets)
// 3. Create order
const { order, quoteId } = sdk.createOrder(quote, {
walletAddress: '0xYourAddress',
hashLock,
secretHashes: secrets.map(s => s.hash)
})
// 4. Submit order
const orderInfo = await sdk.submitOrder(
quote.srcChainId,
order,
quoteId,
secrets.map(s => s.hash)
)
// 5. Track order status
console.log('Order Hash:', orderInfo.orderHash)
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