trying to call a smart contract function
expect the call to be signed without metamasks, but:
- metamask pops up and offers to sign the transaction
- when I try to sign I get the following error:
<<MetaMask - RPC Error: [ethjs-query] while formatting outputs from RPC â{âvalueâ:{âcodeâ:-32603,âdataâ:{âcodeâ:-32000,âmessageâ:âtransaction underpricedâ}}}â >>
what am I doing wrong?
code:
document.getElementById(âbuyâ).addEventListener(âclickâ, async function() {
const web3 = await Moralis.enableWeb3({ privateKey: "0058233e........e619e3f4795a" });
const contract = "0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506"; // Sushiswap router
const USDC = "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174";
const USDT = "0xc2132D05D31c914a87C6611C10748AEb04B58e8F";
let masterAdres = "0x8/////////////////8904";
const ABI = [................];
const options = {
contractAddress: contract,
functionName: "swapExactTokensForTokens",
abi: ABI,
params: {
amountIn: 1000000,
amountOutMin: 1,
path: [USDC, USDT],
to: masterAdres,
deadline: Date.now() + 1000 * 60 * 5
},
};
try {
const res = await Moralis.executeFunction(options);
console.log("result", res);
}
catch (e) {
console.log(e);
}
});