A custom contract can call the Enso router with the transaction data returned from the API. Use the current tx fields from the response, and do not hardcode a router address.
Definition
Your contract is the on-chain caller. Enso still builds the shortcut off-chain. The contract forwards or executes the returned calldata against the tx.to for that quote.
How it works
Request a Route or Bundle as usual for the
fromAddressand tokens involved.Read
tx.to,tx.data, andtx.valuefrom the response.Have your contract call that
tx.towith the provided data and value.Submit any required
preTransactionsor approvals first, using spenders returned in the response.
How Enso does this
The FAQ says you can create a custom contract that calls the Enso router with the data returned from the API. Deployments and the FAQ also say the execution contract depends on the chain and routing strategy, so you should submit tx.to from the current response rather than a hardcoded address. See Should I hardcode Enso contract addresses?.
FAQ
Can I cache calldata in the contract?
No. Rebuild a fresh quote at execution time. Routes are market-dependent, and you should not reuse old calldata.
Does the user still sign something?
The user, or the contract’s usual execution path, still has to submit the transaction that performs that call. Enso does not take custody of funds.
Related articles
Should I hardcode Enso contract addresses?
How do I submit Enso transaction data from my app?
How should I implement recurring Enso transactions?
What is signer-ready transaction data?
Does Enso take custody of user funds?
