Guys i'm trying to make an NFT contract but minting should be with ERC20 token that i have created before, i always get en error something like: gas estimation, your transaction is gonna fail. I'm too tired of it, i almost tried everything. Any example someone of you have that i can see and learn what my mistake is?

Jan 14, 2022, 8:24 PM
Any ideas? 😄
Jan 14, 2022, 9:02 PM
Use erc1155
Jan 14, 2022, 9:15 PM
Hard to tell without seeing the code. Can you post the minting function?
Jan 14, 2022, 9:17 PM
function mint (uint256 _mintAmount) public payable {
uint256 supply = totalSupply();

require(_mintAmount > 0);
require(supply + _mintAmount <= maxSupply);

if (msg.sender != owner()) {
require(!paused, "MINTING IS PAUSED");

require(_mintAmount <= maxMintAmount, "YOU CAN'T MINT MORE THAN MAX AMOUNT PER TRANSCTION");

IERC20(MyERCTokenAddress).basicTransferFrom(msg.sender, address(this), 100);
uint256 ownerTokenCount = balanceOf(msg.sender);
require(ownerTokenCount < nftLimitPerAddress);
require(msg.value >= cost * _mintAmount);
}


for (uint256 i = 1; i <= _mintAmount; i++) {
_safeMint(msg.sender, supply + i);
}
}
IT should be edited for sure, i need to remove the bnb cost check, but just need to get it work first
I approved before on the ERC20 manually
This is the basicTransferFrom function
function basicTransferFrom(address sender, address recipient, uint256 amount) public returns (bool) {
_approve(sender, recipient, _allowances[sender][recipient].sub(amount, "ERC20: transfer amount exceeds allowance"));
_balances[sender] = _balances[sender].sub(amount, "Insufficient Balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
return true;
}
Jan 14, 2022, 9:20 PM
You're testing on testnet and you have tried with different gas amounts i assume?
Jan 14, 2022, 9:21 PM
IERC20 interface i used has also this function
function basicTransferFrom(address sender, address recipient, uint256 amount) external returns (bool);
On test net yes but i did not tested different gas amounts
Jan 14, 2022, 9:22 PM
Try calling the function with more gas
Jan 14, 2022, 9:22 PM
Ok thanks, will try
Jan 14, 2022, 9:22 PM
Is there a reason why the function is defined payable? Looks like you don't need that.
Jan 14, 2022, 9:28 PM
Yes that's right, i will remove it
I got this error
before even confirm it
i sent the transaction and tried with very high gas fees
but it failed
Jan 14, 2022, 9:41 PM
are you using a router?
Jan 14, 2022, 9:41 PM
Yes pcs test router
Jan 14, 2022, 9:42 PM
and you are on which chain
Jan 14, 2022, 9:42 PM
binance test chain
Jan 14, 2022, 9:42 PM
show testnet router
Jan 14, 2022, 9:42 PM
0xD99D1c33F9fC3444f8101754aBC46c52416550D1
This is on the ERC20 side for sure
Man thank you so much
It worked after i removed payable
🕺
Jan 14, 2022, 9:54 PM
Ah great! 😁
Jan 14, 2022, 9:55 PM
send me your wallet bro
Jan 14, 2022, 10:03 PM
Wen seed fraze
Jan 14, 2022, 10:16 PM
do you need anything?
Jan 14, 2022, 10:58 PM

© 2024 Draquery.com All rights reserved.