Assemble the Transaction
To execute an Odos Zap quote on-chain, the transaction must first be assembled.
The Odos API will generate the complete transaction for you — manual assembly is not supported.
Once you have the pathId from the quote, send a POST request to the /sor/assemble endpoint to get the full on-chain transaction data.
This is the same endpoint used for assembling quotes from /sor/quote/v3.
- Python
- JavaScript
import requests
import os
from dotenv import load_dotenv
load_dotenv()
assemble_url = "https://enterprise-api.odos.xyz/sor/assemble"
assemble_request_body = {
"userAddr": "0x...", # the checksummed address used to generate the quote
"pathId": quote["pathId"], # Replace with pathId from quote response (Step 1)
"simulate": False, # set to True if user isn't doing their own gas estimation
}
headers = {
"Content-Type": "application/json",
"x-api-key": os.getenv("ODOS_API_KEY")
}
response = requests.post(assemble_url, json=assemble_request_body, headers=headers)
if response.status_code == 200:
assembled_transaction = response.json()
print(assembled_transaction)
else:
print(f"Error assembling transaction: {response.status_code} - {response.text}")
import 'dotenv/config';
const assembleUrl = 'https://enterprise-api.odos.xyz/sor/assemble';
const assembleRequestBody = {
userAddr: '0x...', // the checksummed address used to generate the quote
pathId: quote.pathId, // Replace with the pathId from quote response (Step 1)
simulate: true, // set to true if not performing your own gas estimation
};
const response = await fetch(assembleUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': process.env.ODOS_API_KEY
},
body: JSON.stringify(assembleRequestBody),
});
if (response.ok) {
const assembledTransaction = await response.json();
console.log(assembledTransaction);
} else {
console.error('Error assembling transaction:', response.statusText);
}
Replace placeholder values with real addresses and token data.
The userAddr should be the checksummed address of the user who requested the quote and will execute the transaction.
The response includes the transaction object containing all necessary fields for on-chain execution — ready to sign and broadcast via Web3 or ethers.js.
Note: Be sure to update your endpoint URLs to use the Enterprise API for production integrations:
https://enterprise-api.odos.xyz/sor/assemble