I don't get the right transaction data back using the ethers API in combination with 1inch

Hi all,

I am trying to integrate the 1inch swagger API in my dapp with javascript. I have not that much experience so I might do something wrong. Fetching the 1inch API goes fine.
But when I want to use the following code, I get either high gas fees or the swap doesnt execute at all. I attached also a picture of the data format, which seems odd to me.
Schermafbeelding 2022-08-01 om 14.56.48

let result = await window.ethereum.request({method: “eth_sendTransaction”,
params: [
from: tx.from,
to: tx.to,
gas: Number(2100000).toString(16),
gasPrice: Number(2500000).toString(16),
value: Number(500000000000000).toString(16),
data : tx.data,

does anybody know what I do wrong? It might be a rookie mistake.


1 Like

Any error messages you are getting?

Can you provide steps to reproduce?

1 Like

it works now, must have used the API wrongly.

What is interesting now is that I want to swap now the opposite direction.
Despite i fill in all the variables, metamasks thinks I would like to swap native token ethereum instead of an ERC20 token.

Should there be an additional step when you want to use ’ eth_sendTransaction’ for an ERC20 token?

Can you please provide any additional information or screenshots of your current problem? I’m a little unclear as to why you are having issues swapping in the “other direction”

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.