I have done everything that I can think of, use people’s examples online, tried Calculating it using the gas formular, but still got the same error.
Please here are my codes below, all I need is for someone to adjust my code to the correct form…
I’ve been in this issue for month and still haven’t gotten a solution, please.
const { runContractFunction: approve, data: enterTxResponse, error, isLoading, isFetching } = useWeb3Contract({
// chain: "eth",
contractAddress: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
abi: ABI,
functionName: "approve",
params: {
_spender: "0xc....",
_value: 1000000,
},
},
);
// gasprice
const gas = async () => {
const web3Provider = await Moralis.enableWeb3();
const gasPrice = await web3Provider.getGasPrice();
const signer = web3Provider.getSigner();
const contract = new ethers.Contract("0xdAC17F958D2ee523a2206206994597C13D831ec7", ABI, signer);
const tx = await contract.approve({
value: 1000000,
gasPrice: gasPrice,
gasLimit: 21000,
})
await tx.wait();
};
Look at a transaction on chain and try to understand what those 3 parameters mean. If you set them with random values it is not going to work.
The gasLimit, I saw the figure on my metamask when trying to run a transaction, the value is the amount of usdt I want to send, the gasPrice can be change by the user.
This were the explanations I saw online.
That gasLimit, what does it mean? Where from did you get that number?