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

Name
Type
Description

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

Name
Type
Description

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

Name
Type
Description

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

{
    "from": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
    "to": "0x6a000f20005980200259b80c5102003040001068",
    "value": "0",
    "data": "0xe3ead59e0000000000000000000000005f0000d4780a00d2dce0a00004000800cb0e5041000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000000000000000000000000000000000000000f42400000000000000000000000000000000000000000000000000db4d11c67691ad50000000000000000000000000000000000000000000000000dd8426a4440caf10a8104c26c244959a1d46f205acc49520000000000000000000000000133fc2c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000001800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000160a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000006000240000ff00000300000000000000000000000000000000000000000000000000000000a9059cbb0000000000000000000000004610ba8d5d10fba8c048a2051a0883ce04eabace00000000000000000000000000000000000000000000000000000000000f42406a000f20005980200259b80c51020030400010680000008000240000ff0600030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000f4240000000000000000000004de54610ba8d5d10fba8c048a2051a0883ce04eabace",
    "gasPrice": "16000000000",
    "chainId": 1
}

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 passed

  • Missing 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 deprecated

  • When "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 build

  • Unable to build transaction <code> - something went wrong during the transaction build

  • It 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