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.
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,
},
],
})
.catch((err)=>{
console.log(err)
})
}
does anybody know what I do wrong? It might be a rookie mistake.
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”