Skip to main content

Output Modes

The CLI auto-detects your terminal and adjusts output format accordingly.
ModeTriggerBehaviour
HumanDefault (TTY detected)Coloured tables, formatted amounts
Machine--json flag or non-TTY pipeRaw JSON, stable schema, no colour

Pipe-Friendly Output

The CLI auto-detects non-TTY environments and switches to JSON:
# Auto-detects non-TTY — outputs JSON
lifi chains | jq '.chains[].name'

Force JSON in Terminal

lifi chains --json

Disable Colour

lifi chains --no-color

Verbose Errors

Enable stack traces for debugging:
lifi quote --from 1 --to 42161 --verbose

Exit Codes

CodeMeaning
0Success
1General error
2Invalid arguments / usage
3Authentication error
4API error (rate limit, server error)
5Network error (unreachable)

End-to-End Workflow: Cross-Chain Swap

This example walks through a complete cross-chain USDC transfer from Ethereum to Base.

Step 1: Find Chain IDs

lifi chains --type EVM

Step 2: Look Up Token Address

lifi token 1 USDC

Step 3: Get Best Quote

lifi quote \
  --from 1 --to 8453 \
  --from-token USDC --to-token USDC \
  --amount 1000000000 \
  --from-address 0xYOUR_ADDRESS
The response includes a transactionRequest object ready for signing.

Step 4: Approve and Sign (External)

Use your wallet to:
  1. Approve the token spend if needed
  2. Sign and broadcast the transactionRequest from the quote

Step 5: Track Progress

lifi status 0xTX_HASH --watch
The --watch flag polls until the transfer completes or fails.

Scripting Example

Combine commands in a shell script:
#!/bin/bash

# Get the cheapest route for 1000 USDC from Ethereum to Base
QUOTE=$(lifi quote \
  --from 1 --to 8453 \
  --from-token USDC --to-token USDC \
  --amount 1000000000 \
  --from-address "$WALLET_ADDRESS" \
  --json)

# Extract estimated output
echo "$QUOTE" | jq '.estimate.toAmountUSD'

# Extract transaction request for external signing
echo "$QUOTE" | jq '.transactionRequest'