That looks fine as long as youâre using the USDT ABI, can you log the error from the useWeb3Contract hook to try and see whatâs going on when you call approve.
useEffect(() => {
console.log("error", error);
}, [error]);
That looks fine as long as youâre using the USDT ABI, can you log the error from the useWeb3Contract hook to try and see whatâs going on when you call approve.
useEffect(() => {
console.log("error", error);
}, [error]);
so sorry on my late reply⌠please here is the error message.
So this error happens and your MetaMask doesnât get the transaction to sign? If so you may need to use ethers.js directly to set gas. You can try testing with another wallet.
Thanks for replying, please can you direct me on how to use ether.js to set the gas?
There is an example here. The approve transaction on that Ethereum contract goes to my MetaMask fine, I just donât have enough ETH to pay for it. You can test with another wallet as well.
Okay Iâm about to try it with the example I saw there, thanks. Iâll update you on the outcome, thanks again.
const { runContractFunction: approve, data: enterTxResponse, error, isLoading, isFetching } = useWeb3Contract({
// chain: "eth",
contractAddress: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
abi: ABI,
functionName: "approve",
params: {
_spender: "0xc.....",
_value: 1,
},
}
);
//gasprice
const gas = async () => {
const tx = await contract.approve(_spender, _value, [], {
gasLimit: 100000,
nonce: nonce || undefined,
});
};
const Web3Api = useMoralisWeb3Api();
const allowace = async () => {
//Get token allowace on ETH
const options = {
//token holder
_owner: user,
//uniswap v3 router 2 contract address
_spender: "0xc....",
//ENS token contract address
contractAddress: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
};
const allowance = await Web3Api.token.getTokenAllowance(options);
console.log(allowance);
};
please i still got the same error.
Youâre getting the same error from running the gas
function now? Can you post the other code youâre using e.g. where gas
is being called, your ethers.js code for the contract. Try setting a gasPrice and a higher gasLimit.
const gas = async () => {
const ethers = Moralis.web3Library;
const web3Provider = await Moralis.enableWeb3();
const gasPrice = await web3Provider.getGasPrice();
const signer = web3Provider.getSigner();
const contract = new ethers.contract("0xdAC17F958D2ee523a2206206994597C13D831ec7", ABI, signer);
const transaction = await contract.approve({
_spender: "0xc......",
_value: 1,
gasLimit: 10000000,
gasPrice: gasPrice,
// nonce: nonce || undefined,
});
await transaction.wait();
};
so sorry on the late reply
What version of Moralis and react-moralis are you using? And are you using vite?
thanks for replyingâŚ
âreact-moralisâ: â^1.3.5â,
âmoralis-v1â: â^1.11.0â,
And are you using Vite too ?
no Iâm not using vite
Oh
Try change your dependencies to these
"moralis": "1.8.0",
"react-moralis": "1.4.0",
the error is still coming up
Which of the error ?
please this same error
Please how can I solve this?
If same execution reverted due to gas, try increasing the gas price. You try add it manually