hey there kai29! i’ve been playing around with erc20 and erc721 contracts lately too, so i totally get your frustration. that error message is a bit confusing, right?
from what i can see, you’re not actually using the ERC20 contract in your code, just the interface. so you probably don’t need to import the full ERC20.sol file. try removing that import and just stick with the IERC20 interface you’re already using.
btw, have you considered adding a function to let users choose between eth and token payments? might make your contract even cooler!
oh, and quick question - how are you planning to handle the token pricing? will it be fixed or do you want to make it dynamic based on eth price? just curious cuz i’m working on something similar and still figuring out the best approach.
keep us posted on how it goes! nft projects are so exciting rn
yo kai29, ben_comics got a point about the import. but also check ur compiler version. sometimes older versions throw weird errors. make sure ur using ^0.8.0 or higher.
for token pricing, u could use a chainlink oracle to get real-time eth/usdt rates. that’d make ur contract way more flexible. just a thought!
I’ve encountered similar issues when working with ERC20 and ERC721 contracts. The error you’re seeing is likely due to a naming conflict in your imports. As others have mentioned, you’re only using the IERC20 interface, so you can safely remove the ERC20 import.
Regarding your implementation, it’s worth considering gas optimization. For the mintWithToken function, you might want to add a check for the allowance before attempting the transfer. This can save users gas if the transaction would fail due to insufficient allowance.
Also, have you thought about implementing a withdraw function for the contract owner? This would allow you to retrieve the collected funds and tokens. It’s a common practice in many NFT projects I’ve worked on.
Lastly, ensure you’re testing thoroughly, especially the interaction between ETH and token payments. Unexpected behavior can occur when dealing with multiple payment methods.