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 getReadyToAcceptSecretFills() method returns a list of fills for which secrets can be safely submitted. This indicates that both source and destination escrows have been deployed.
Method Signature
async getReadyToAcceptSecretFills ( orderHash : string ): Promise < ReadyToAcceptSecretFills >
Parameters
The order hash to check for ready fills
Returns
Object containing fills ready for secret submission Array of fills ready to accept secrets Index of the secret to submit (corresponds to secrets array from order creation)
Destination escrow address
When Fills Become Ready
A fill becomes ready when:
Source escrow deployed - Resolver creates escrow on source chain
Destination escrow deployed - Resolver creates escrow on destination chain
Escrows are valid - Parameters match order requirements
Time locks active - Sufficient time remaining for safe execution
Empty fills array means no secrets should be submitted yet. Keep polling until fills appear.
Examples
Basic Usage
import { SDK } from '@1inch/cross-chain-sdk'
const sdk = new SDK ({
url: 'https://api.1inch.com/fusion-plus' ,
authKey: 'your-auth-key'
})
const orderHash = '0x...'
// Check ready fills
const result = await sdk . getReadyToAcceptSecretFills ( orderHash )
if ( result . fills . length > 0 ) {
console . log ( ` ${ result . fills . length } fill(s) ready for secret submission` )
for ( const fill of result . fills ) {
console . log ( `Fill ${ fill . idx } :` )
console . log ( ` Source escrow: ${ fill . srcEscrow } ` )
console . log ( ` Destination escrow: ${ fill . dstEscrow } ` )
}
} else {
console . log ( 'No fills ready yet' )
}
Polling Loop
import { OrderStatus } from '@1inch/cross-chain-sdk'
async function waitAndSubmitSecrets (
sdk : SDK ,
orderHash : string ,
secrets : string []
) : Promise < void > {
const submittedSecrets = new Set < number >()
console . log ( 'Monitoring order for ready fills...' )
while ( true ) {
// Check for ready fills
const { fills } = await sdk . getReadyToAcceptSecretFills ( orderHash )
// Submit secrets for new ready fills
for ( const { idx , srcEscrow , dstEscrow } of fills ) {
if ( ! submittedSecrets . has ( idx )) {
console . log ( ` \n Fill ${ idx } is ready` )
console . log ( ` Src escrow: ${ srcEscrow } ` )
console . log ( ` Dst escrow: ${ dstEscrow } ` )
// In production, validate escrow addresses here
// before submitting secrets
console . log ( ` Submitting secret...` )
await sdk . submitSecret ( orderHash , secrets [ idx ])
submittedSecrets . add ( idx )
console . log ( ` Secret ${ idx } submitted successfully` )
}
}
// Check if order is complete
const { status } = await sdk . getOrderStatus ( orderHash )
if (
status === OrderStatus . Executed ||
status === OrderStatus . Expired ||
status === OrderStatus . Refunded
) {
console . log ( ` \n Order completed with status: ${ status } ` )
break
}
// Wait before next check
await new Promise ( resolve => setTimeout ( resolve , 2000 ))
}
}
// Usage
await waitAndSubmitSecrets ( sdk , orderHash , secrets )
With Escrow Validation
interface EscrowValidation {
isValid : boolean
errors : string []
}
function validateEscrow (
fill : FillInfo ,
expectedSrcToken : string ,
expectedDstToken : string ,
expectedAmount : string
) : EscrowValidation {
const errors : string [] = []
// Add your validation logic here
// - Check escrow contract is correct implementation
// - Verify token addresses
// - Validate amounts
// - Check time locks
// - Verify no suspicious parameters
// Example validations:
if ( ! fill . srcEscrow . startsWith ( '0x' )) {
errors . push ( 'Invalid source escrow address' )
}
if ( ! fill . dstEscrow . startsWith ( '0x' )) {
errors . push ( 'Invalid destination escrow address' )
}
return {
isValid: errors . length === 0 ,
errors
}
}
// Check ready fills with validation
const { fills } = await sdk . getReadyToAcceptSecretFills ( orderHash )
for ( const fill of fills ) {
const validation = validateEscrow (
fill ,
srcTokenAddress ,
dstTokenAddress ,
amount
)
if ( ! validation . isValid ) {
console . error ( `Fill ${ fill . idx } validation failed:` )
validation . errors . forEach ( err => console . error ( ` - ${ err } ` ))
continue
}
// Safe to submit secret
await sdk . submitSecret ( orderHash , secrets [ fill . idx ])
}
With Multiple Orders
interface OrderSecrets {
orderHash : string
secrets : string []
submitted : Set < number >
}
async function monitorMultipleOrders (
sdk : SDK ,
orders : OrderSecrets []
) : Promise < void > {
const activeOrders = new Set ( orders . map ( o => o . orderHash ))
while ( activeOrders . size > 0 ) {
// Check all active orders in parallel
const results = await Promise . all (
orders
. filter ( o => activeOrders . has ( o . orderHash ))
. map ( async ( order ) => {
const { fills } = await sdk . getReadyToAcceptSecretFills ( order . orderHash )
return { order , fills }
})
)
// Process ready fills
for ( const { order , fills } of results ) {
for ( const { idx } of fills ) {
if ( ! order . submitted . has ( idx )) {
await sdk . submitSecret ( order . orderHash , order . secrets [ idx ])
order . submitted . add ( idx )
console . log ( `Order ${ order . orderHash . slice ( 0 , 10 ) } ... secret ${ idx } submitted` )
}
}
// Check if order is done
const { status } = await sdk . getOrderStatus ( order . orderHash )
if (
status === OrderStatus . Executed ||
status === OrderStatus . Expired ||
status === OrderStatus . Refunded
) {
activeOrders . delete ( order . orderHash )
console . log ( `Order ${ order . orderHash . slice ( 0 , 10 ) } ... completed: ${ status } ` )
}
}
await new Promise ( resolve => setTimeout ( resolve , 3000 ))
}
console . log ( 'All orders completed' )
}
Polling Strategy
Recommended polling interval: 2-5 seconds
Too frequent: Wastes API calls and bandwidth
Too infrequent: Delays secret submission and order execution
Exponential Backoff
async function pollWithBackoff (
sdk : SDK ,
orderHash : string ,
secrets : string [],
initialDelay : number = 1000 ,
maxDelay : number = 10000
) : Promise < void > {
let delay = initialDelay
const submittedSecrets = new Set < number >()
while ( true ) {
const { fills } = await sdk . getReadyToAcceptSecretFills ( orderHash )
if ( fills . length > 0 ) {
// Reset delay when activity detected
delay = initialDelay
for ( const { idx } of fills ) {
if ( ! submittedSecrets . has ( idx )) {
await sdk . submitSecret ( orderHash , secrets [ idx ])
submittedSecrets . add ( idx )
}
}
} else {
// Increase delay when no activity
delay = Math . min ( delay * 1.5 , maxDelay )
}
const { status } = await sdk . getOrderStatus ( orderHash )
if ( status === OrderStatus . Executed ) break
await new Promise ( resolve => setTimeout ( resolve , delay ))
}
}
Security Best Practices
Always validate escrow deployments before submitting secrets:
Verify escrow contract addresses match expected implementations
Check token addresses and amounts are correct
Validate time locks provide sufficient security buffer
Ensure no suspicious or malicious parameters
Confirm both source and destination escrows exist
The presence of a fill in the ready list means escrows are deployed, but you must validate them before revealing secrets.