Request Transaction Data
Last updated
Last updated
Provides the transaction request that needs to be sent, comprising the Router contract address
(to), transaction data
(data), and the amount of ETH to be carried in the transaction (value).
const getRouterTransactionRequest = async (routerData) => {
const result = await client.post("/v1/transactions/build", { body: routerData });
return result.data;
};
const routerData = {
chainId: 1,
account: USER_ADDRESS,
logics: [swapLogic, supplyLogic],
// If the estimate result returns permitData, the user should sign the permitData,
// and return the signed permitSig along with it.
permitData: permitData,
permitSig: permitSig,
// If there is only one referral address, you can use the 'referral' property.
// If there are multiple referral addresses, use 'referrals' and specify the rates accordingly.
referral: collector,
referrals: [
{ collector: collector, rate: 5000 },
...
]
};
const transactionRequest = await getRouterTransactionRequest(routerData);
The result contains a list of chains that looks the following:
{
"to": "0xDec80E988F4baF43be69c13711453013c212feA8",
"data": "0x1c81999100000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000032000000000000000000000000000000000000000000000000000000000000004c00000000000000000000000000000000000000000000000000000000000000780000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba300000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000028000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001842b67b570000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000ffffffffffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000645faecd00000000000000000000000000000000000000000000000000000000000000000000000000000000000000009e2a2394c69874545c013492d52d1dc0c607b20800000000000000000000000000000000000000000000000000000000643828d500000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000041bb8d0cf3e494c2ed4dc1057ee31c90cab5387b8a606019cc32a6d12f714303df183b1b0cd7a1114bd952a4c533ac18606056dda61f922e030967df0836cf76f91c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba300000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000180000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008436c78516000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000000000000000000009e2a2394c69874545c013492d52d1dc0c607b208000000000000000000000000000000000000000000000000000000003b9aca00000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e592427a0aece92de3edee1f18e0157c0586156400000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000002400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000144c04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000009e2a2394c69874545c013492d52d1dc0c607b20800000000000000000000000000000000000000000000000000000000643828d6000000000000000000000000000000000000000000000000000000003b9aca0000000000000000000000000000000000000000000000000000000000003612330000000000000000000000000000000000000000000000000000000000000042a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480001f4c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20001f42260fac5e5542a773aa44fbcfedf7c193bc2c599000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000003b9aca0000000000000000000000000087870bca3f3fd6335c3f4ce8392d69350b4fa4e200000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000084617ba0370000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c5990000000000000000000000000000000000000000000000000000000000369e050000000000000000000000009e2a2394c69874545c013492d52d1dc0c607b20800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000369e0500000000000000000000000000000000000000000000000000000000000000030000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c5990000000000000000000000005ee5bf7ae06d1be5997a1a72006fe6c607ec6de8000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"value": "0"
}
For more information on the routerData object and its properties, please refer to the Router Data Documentation.
/v1/transactions/build
42161
0xa3C1C91403F0026b9dd086882aDbC8Cdbc3b3cfB
0x00
curl -L \
--request POST \
--url 'https://api.protocolink.com/v1/transactions/build' \
--header 'Content-Type: application/json' \
--data '{"chainId":42161,"account":"0xa3C1C91403F0026b9dd086882aDbC8Cdbc3b3cfB","logics":[{"rid":"uniswap-v3:swap-token","fields":{"tradeType":"exactIn","path":"0xaf88d065e77c8cc2239327c5edb3a432268e5831000064fd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9000bb882af49447d8a07e3bd95bd0d56f35241523fbab1","slippage":100,"input":{"token":{"chainId":42161,"address":"0xaf88d065e77c8cC2239327C5EDb3A432268e5831","decimals":6,"symbol":"USDC","name":"USDCoin"},"amount":"1000"},"output":{"token":{"chainId":42161,"address":"0x0000000000000000000000000000000000000000","decimals":18,"symbol":"ETH","name":"Ethereum"},"amount":"0.532050407772720708"}}}],"permitData":{"domain":{"name":"Permit2","chainId":42161,"verifyingContract":"0x000000000022D473030F116dDEE9F6B43aC78BA3"},"values":{"spender":"0x2C0e22b8d5070cb2500628E0bf43925a5c7b1559","sigDeadline":1689302375,"details":{"token":"0xaf88d065e77c8cC2239327C5EDb3A432268e5831","amount":"0xffffffffffffffffffffffffffffffffffffffff","expiration":1691892575,"nonce":0}},"types":{"PermitSingle":[{"name":"details","type":"PermitDetails"},{"name":"spender","type":"address"},{"name":"sigDeadline","type":"uint256"}],"PermitDetails":[{"name":"token","type":"address"},{"name":"amount","type":"uint160"},{"name":"expiration","type":"uint48"},{"name":"nonce","type":"uint48"}]}},"permitSig":"0x00"}'
{
"to": "0xf4dEf6B4389eAb49dF2a7D67890810e5249B5E70",
"data": "0x...",
"value": "0"
}
OK