Prerequisites
- A wallet address with USDC on Base (even a small amount like 1 USDC works)
- Node.js 18+ (for the TypeScript examples) or
curl
Get a Composer quote
Request a quote with Key parameters:
The response includes
toToken set to the vault token address:| Parameter | Value | Description |
|---|---|---|
fromChain | 8453 | Base chain ID |
toChain | 8453 | Base (same-chain deposit) |
fromToken | 0x8335...2913 | USDC on Base |
toToken | 0x7BfA...34A | Morpho vault token address |
fromAmount | 1000000 | 1 USDC (6 decimals) |
transactionRequest, a ready-to-sign EVM transaction, along with estimated output amounts and the tools used.Set token allowance
Before executing, ensure the LI.FI contract is approved to spend your tokens. The approval address is returned in the quote response at
quote.estimate.approvalAddress.If you’re sending a native token (e.g., ETH), skip this step. Native tokens don’t require approval.
Execute the transaction
Send the transaction using the That’s it. Composer handles the swap and deposit in a single atomic transaction.
transactionRequest object from the quote response.Track the status
For same-chain transactions, the transaction is complete once confirmed. For cross-chain Composer flows, poll the
For the full status reference, see Transaction Status Tracking.
/status endpoint:| Status | Meaning |
|---|---|
NOT_FOUND | Transaction doesn’t exist or not yet mined |
INVALID | Hash is not tied to the requested tool |
PENDING | Transaction is in progress |
DONE | Completed successfully |
FAILED | Transaction failed |
Full Working Example
Copy-paste this complete example to run your first Composer transaction:What Just Happened?
Behind the scenes, Composer:- Identified the optimal path — LI.FI’s routing engine determined the best way to convert USDC into the Morpho vault token
- Compiled eDSL instructions — The Composer compiler generated bytecode for the onchain VM
- Simulated the execution — The full path was simulated before returning the quote, ensuring it will succeed
- Executed atomically — Your single transaction swapped USDC and deposited into Morpho in one atomic operation

