How to execute the bidNFT function?

Do you have enough erc20 token balance to execute the bid as per the smartcontract function?

Yes, I have enough balance and tokens too.

Here is the contract function:
function makeBid(
address _nftContractAddress,
uint256 _tokenId,
address _erc20Token,
uint128 _tokenAmount
)
external
payable
auctionOngoing(_nftContractAddress, _tokenId)
onlyApplicableBuyer(_nftContractAddress, _tokenId)
{
_makeBid(_nftContractAddress, _tokenId, _erc20Token, _tokenAmount);
}

contarct git repo: https://github.com/avolabs-io/nft-auction/blob/master/contracts/NFTAuction.sol

The erc20 contract which is imported into your contract has an allowance function. you can try to run this function to check if you have token allowances to execute the transfer.

function allowance(address owner, address spender) external view returns (uint256); 

Can you share the failed transaction address for more details?

Sorry for the very late reply. I am really sorry for the late reply. I couldn’t do any transaction for NFT bid. I can give you the contract addresses so that you can check and bid an NFT which are in auction by this contract address. Please let me know.

It is probably due to insufficient allowance. You can try to approve some erc20 to increase the allowance in the smart contract. I guess doing this should fix it.

Check this if this helps for better explanation

I guess allowance allow a user to spend some tokens of msg.sender. But when a single user want to spend some token to bid other user NFTs then that user should spend some token from his/her wallet. Isn’t it? I am still facing this problem.

can you share the contract address and deployed chain details?
and a failed tx address if available.

Yes. I can sharing it below.

NFT Auction Contract Address: 0xe25d3be5F5276A7E3E39E4aE0f060417d8A5b30D

ERC 721 Contract Address / NFT Contract Address: 0xD09c517b2b59A9bf1429a7e87d8c7CaA554Ac130

ERC 20 Contract Address: 0xb8EeF6eF1944676a2072104FCE746BF446794a6c

Deployed chain: bsc testnet.

I have just created an auction and the NFT token id is: 9932. Here is the transaction: https://testnet.bscscan.com/tx/0xc0c8016f6afd0494604ef3170f1688f1d9292c6360f062c84f8600ff3e6534e0

Here are some more information about that auction:
“_minPrice”: “10”,
“_buyNowPrice”: “100”,
“_auctionBidPeriod”: “3”,
“_bidIncreasePercentage”: “1000”

Can you remove the ABI or keep it with a drop-down like below, you can find it in this option. image

Summary

This text will be hidden

ABI is too big for the thread. Thank you

Can you tell me which contract function is throwing the insufficient allowance error?

I have removed the ABI. And ERC 20 Contract address (0xb8EeF6eF1944676a2072104FCE746BF446794a6c) is throwing error.

I am trying to do bid like this way:

const oprtions = {
contractAddress: “0xe25d3be5F5276A7E3E39E4aE0f060417d8A5b30D”,
functionName: “makeBid”,
abi: “ABI”,
params: {
_nftContractAddress: “0xD09c517b2b59A9bf1429a7e87d8c7CaA554Ac130”,
_tokenId: body._tokenId,
_erc20Token: “0xb8EeF6eF1944676a2072104FCE746BF446794a6c”,
_tokenAmount: body._tokenAmount,
}
};

And when I try to execute this function using moralis it shows this “Error: cannot estimate gas; transaction may fail or may require manual gas limit”. I am getting this error only from this function.

Is this the function that caused insufficient allowance error?

This probably has occurred due to the wrong network in metamask or maybe metamask is taking too long to verify the data from the contract function and cannot estimate gas.
also, check if all the parameters are correct.

Maybe, I am sure about it. I got the insufficient allowance error when I have tried to execute the function using Remix IDE. Can you try to bid that NFT from your side by using the contract addresses?

I would probably get the same error as i do not have the erc20 balance.

Okay then. Thank you so much for trying to helping me. Thanks a lot and please if you find any solution then please suggest me. It will be really helpful for me. Trying to build my first NFT marketplace using moralis.

1 Like

I got the insufficient allowance error

Which function call actually results in this error? You haven’t made that clear.

You need an allowance for the ERC20 token. So call the approve function on this token contract using the relevant address.

You can read about approve/allowance here.

I am also confused about it. When I have tried to bid any NFT using moralis, it doesn’t work and give an error named: cannot estimate gas; transaction may fail or may require manual gas limit. I only get this error whenever I try to execute the “makeBid” function.

Do you know how to work with it. Here is the contract: https://github.com/avolabs-io/nft-auction

Here is the error.

You may need to set gas manually, to do that, for now you will have to use ethers.js or web3.js directly. Here is an example on doing it.