Skip to main content
The Execute Service handles bridge transaction execution via the LI.FI API, including token approvals, transaction signing, status polling, and step-by-step progress tracking.

Exports


Functions

execute(config)

Execute a bridge transaction from a quote.

ExecuteConfig

Returns: ExecutionResult Throws:
  • QuoteExpiredError if quote has expired (5 minute max age)
  • InvalidQuoteError if quote is malformed
  • TransactionFailedError if transaction fails on-chain
  • UserRejectedError if user rejects transaction
  • NetworkError if network request fails

Execution Flow

The execute function processes a quote through these stages:

Example: Basic Execution


Example: With Progress Callbacks


Example: With Event Emitter


validateQuote(quote)

Validate a quote before execution.
Throws:
  • QuoteExpiredError if quote has expired
  • InvalidQuoteError if quote is malformed
Validation Checks:
  1. Quote is not null/undefined
  2. Quote has a valid ID
  3. Quote has at least one execution step
  4. Quote has fromAmount and toAmount
  5. Quote has not expired (expiresAt timestamp)
  6. Quote age does not exceed 5 minutes
Example:

Error Types

QuoteExpiredError

Thrown when a quote has exceeded its validity period.
Example:

InvalidQuoteError

Thrown when a quote is malformed or missing required data.
Reasons:
  • null_quote - Quote is null or undefined
  • missing_id - Quote has no ID
  • no_steps - Quote has no execution steps
  • missing_amounts - Quote is missing amount information
Example:

Types

TransactionSigner

Compatible with viem WalletClient and ethers Signer.

TransactionRequest

ExecutionStatus

StepStatus

StepStatusPayload

Payload passed to onStepChange callback.

TransactionStatusPayload

Payload passed to onStatusChange callback.

Constants

Timing Constants


Common Patterns

Retry on Expiration

Progress UI State Machine

Cancel Support