Search…
Build-Tx
Returns transaction data needed to execute a Single Transaction Bridging flow

/v2/build-tx

How this endpoint is to be used :
  • This endpoint is to be used only in case of Single Transaction Bridging flow.
  • Once a route has been selected from the routes list inside the response of /v2/quote, this endpoint can be used to build the transaction data for executing it.
  • The full object containing route details (from /v2/quote) has to be passed to this API as body via a POST request.
  • For a Refuel + Bridge transaction, the full refuel object from the quote needs to be passed in the body as well
  • For passing data as query params, use the GET request Build-tx ​
post
https://api.socket.tech/v2
/build-tx
Returns the transaction data for bridging assets
IMPORTANT : amount parameter in the query needs to be decimal adjusted. For example 1 USDC = 1000000 as USDC supports upto 6 decimal places. Where as 1 UNI = 1000000000000000000 as UNI supports upto 18 decimal places.
API-KEY needs to be passed in the headers while making the POST request

Description of response parameters :

Parameter
Description
success
Status of the api response.
result.userTxType
The type of transaction being done. Indicates if it is a bridging tx, dex tx etc.
result.txType
The type of transaction from wallet's context. Indicates if it is a send tx, sign tx etc.
result.txData
The raw data that should be sent to the contract for making a transaction. Includes the encoded function signature and params.
result.txTarget
The contract address where transaction has to be sent.
result.chainId
The chainId where transaction has to be sent.
result.value
The amount of native tokens that need to be sent as value along with the transaction.
result.approvalData
Details about approval needed before the main transaction. In case approval is not needed this will be null.
result.approvalData.minimumApprovalAmount
The minimum amount of approval required.
result.approvalData.approvalTokenAddress
Address of the token that needs to be given approval.
result.approvalData.allowanceTarget
The contract that needs approval in order to transfer user tokens.

POST REQUEST

{
"route": {
// The selected route from quote response.
}
"refuel" : {
// In case the transaction is Refuel + Bridge,
// full "refuel" object from quote gets added here
}
}
TEST QUERY :

RESPONSE

Response body
Response Headers
​
{
"success": true,
"result": {
"userTxType": "fund-movr",
"txType": "eth_sendTransaction",
"txData": "0xa44bbb1500000000000000000000000000000000000000000000000000000000000000200000000000000000000000003e8cb4bd04d81498ab4b94a392c334f5328b237b00000000000000000000000000000000000000000000000000000000000000380000000000000000000000000000000000000000000000000000000005f5e10000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000420000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa84174000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000002c87c0252000000000000000000000000002ec255797fef7669fa243509b7a599121148ffba000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001800000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa841740000000000000000000000008f3cf7ad23cd3cadbd9735aff958023239c6a063000000000000000000000000356cb8ae24b6814bd8aa1a281b14532c52a4e404000000000000000000000000c30141b657f4216252dc59af2e7cdb9d8792e1b00000000000000000000000000000000000000000000000000000000005f5e1000000000000000000000000000000000000000000000000055d83cd5ce0eca0640000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020800000000000000000000000356cb8ae24b6814bd8aa1a281b14532c52a4e404000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000024bd6015b40000000000000000000000001111111254fb6c44bac0bed2854e76f90643097d00000000000000000000000000000000000000000000000000000000733d4004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000008f3cf7ad23cd3cadbd9735aff958023239c6a063000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000200000000000000000000000009b17baadf0f21f03e35249e0e59723f34994f806",
"txTarget": "0xc30141B657f4216252dc59Af2e7CdB9D8792e1B0",
"chainId": 137,
"value": "0x00",
"approvalData": {
"minimumApprovalAmount": "100000000",
"approvalTokenAddress": "0x2791bca1f2de4661ed88a30c99a7a9449aa84174",
"allowanceTarget": "0xc317144DE60E6bC9455363bB09852C00bd14CD61",
"owner": "0x3e8cB4bd04d81498aB4b94a392c334F5328b237b"
}
}
}
​
access-control-allow-origin: *
content-length: 3068
content-type: application/json; charset=utf-8
date: Tue,16 Nov 2021 08:44:53 GMT
etag: W/"bfc-sF6mwWtk90Kmv4p/FaQ5SrKhl9M"
x-powered-by: Express

NEXT STEP

  • Once the transaction data is retrieved on the frontend, a contract call needs to be made using the returned data to send callData to Socket contracts. The Socket contracts then swap (only if needed and specified by middlewareRoute response param) and bridge in a single transaction.
  • Once the user has initiated a transaction, the status of the transaction can be tracked using Socket Bridge Status APIs
Copy link
On this page
post
Returns the transaction data for bridging assets
Description of response parameters :