Build a transaction: /transactions
Build Transaction
POST
https://api.paraswap.io/transactions/:network
Build parameters for a transaction with the response from /prices
endpoint.
Path Parameters
network
number
Network ID. (Mainnet - 1, Optimism - 10, BSC - 56, Polygon - 137, Fantom - 250, zkEVM - 1101, Base - 8453, Arbitrum - 42161, Avalanche - 43114, Gnosis - 100).
Query Parameters
gasPrice
string
Gas-price to be used for the transaction in wei.
ignoreChecks
boolean
Allows the API to skip performing on-chain checks such as balances, allowances, as well as possible transaction failures.
*Note: The response does not contain gas
parameter when ignoreChecks
is set to true.
Default: false
ignoreGasEstimate
boolean
Allows the API to skip gas checks
*Note: The response does not contain gas
parameter when ignoreGasEstimate
is set to true.
Default: false
onlyParams
boolean
Allows the API to return the contract parameters only.
Default: false
eip1559
boolean
Allows the API to return EIP-1559 styled transaction with maxFeePerGas
and maxPriorityFeePerGas
paramters.
*Note: We currently support EIP1559 transactions in the following chains:
Mainnet, Ropsten, and Avalanche.
Default: false
Request Body
srcToken
string
Destination Token Address. Only Token Symbol could be specified for tokens from /tokens
.
srcDecimals
integer
Source Token Decimals. (Can be omitted if Token Symbol is provided for srcToken
).
destToken
string
Destination Token Address. Only Token Symbol could be specified for tokens from /tokens
.
destDecimals
integer
Destination Token Decimals. (Can be omitted if Token Symbol is provided for destToken
).
srcAmount
integer
Source Amount with decimals. Required if side=SELL. Could only be omitted if slippage is provided when side=BUY
destAmount
integer
Destination amount with decimals. Required if side=BUY. Could only be omitted if slippage is provided when side=SELL.
priceRoute
object
priceRoute
from response body returned from /prices
endpoint. priceRoute
should be sent exactly as it was returned by the /prices
endpoint.
slippage
integer
Allowed slippage percentage represented in basis points.
Eg: for 2.5% slippage, set the value to 2.5 * 100 = 250; for 10% = 1000. Slippage could be passed instead of destAmount
when side=SELL or srcAmount
when side=BUY.
Min: 0; Max: 10000
userAddress
string
Address of the caller of the transaction (msg.sender
)
txOrigin
string
Whenever msg.sender
(userAddress) i.e. address calling the ParaSwap contract is different than the address sending the transaction, txOrigin
must be passed along with userAddress
.
receiver
string
Address of the Receiver (that will receive the output of the swap). Used for Swap&Transfer.
partnerAddress
string
Address that will be entitled to claim fees or surplus.
*Note: Fees have to be claimed from the Fee Claimer contract unless isSurplusToUser
or isDirectFeeTransfer
are used
partnerFeeBps
string
If provided it is used together with partnerAddress
. Should be in basis points percentage. Look at slippage
parameter description for understanding better.
Eg: 200
(for 2% fee percent)
*Note: Fees have to be claimed from the Fee Claimer contract unless isSurplusToUser
or isDirectFeeTransfer
are used
partner
string
Your project name.
Used for providing analytics on your project swaps.
permit
string
Hex string for the signature used for Permit. This can be used to avoid giving approval. Helps in saving gas.
deadline
integer
Timestamp (10 digit/seconds precision) till when the given transaction is valid. For a deadline of 5 minute, deadline: Math.floor(Date.now()/1000) + 300
E.g.: 1629214486
isCapSurplus
boolean
Allows for capping the surplus at 1% maximum.
Default: true
takeSurplus
boolean
Allows to collect surplus. Works with partnerAddress
Default: false
isSurplusToUser
boolean
Specify if user should receive surplus instead of partner.
Default: false
isDirectFeeTransfer
boolean
Specify if fees should be sent directly to the partner instead of registering them on FeeClaimer.
Default: false
Most common error messages
The following is a list of the most common error messages of the /transactions
endpoint. Most are self-explanatory and can be self-solved, but feel free to contact ParaSwap Support using the chat in the bottom right corner of this page.
Validation failed: permit signature should be lower than 706
Validation failed: <error>
- params validation failed (message has the exact reason of failure)Missing price route
- price route param is not passedMissing srcAmount
(sell)Cannot specify both slippage and destAmount
(sell)Missing slippage or destAmount
(sell)Missing slippage or srcAmount
(buy)Source Amount Mismatch
(sell)Destination Amount Mismatch
(buy)Missing destAmount
(buy)Cannot specify both slippage and srcAmount
(buy)Network Mismatch
Source Token Mismatch
Destination Token Mismatch
Contract method doesn't support swap and transfer
Side Mismatch
Source Decimals Mismatch
Destination Decimals Mismatch
It is not allowed to pass both params: "positiveSlippageToUser" and "takeSurplus".
- We advise removing "positiveSlippageToUser" because it is deprecatedWhen "isSurplusToUser"="true", "takeSurplus" must be also "true" and either "partnerAddress" or "partner" must be set
When "isDirectFeeTransfer"="true", please also set "takeSurplus"="true" and provide partner/fee information via "partnerFeeBps" & "partnerAddress" or valid "partner" params; or add "referrer" param
Internal Error while building transaction
- something went wrong during the transaction buildUnable to build transaction <code>
- something went wrong during the transaction buildIt is not allowed to have limit-orders Dex or paraswappool Dex in route and 'ignoreChecks=true' together. Consider requesting the price with excluded limit-orders if you want to use 'ignoreChecks': &excludeDEXS=ParaSwapPool,ParaSwapLimitOrders
It seems like the rate has changed, please re-query the latest Price
The rate has changed, please re-query the latest Price
This transaction has some errors and may fail. Please contact support for more details
Not enough <token> balance
Not enough <token> allowance given to TokenTransferProxy(<spender>)
Unable to check price impact
- src or dest tokens don’t have valid usd price
Last updated