Crowdsale.sol Operator != not compatible with types contract ERC20

Hi, I am trying to include crowdsale.sol in my ERC20 contract but I get these two lines are causig compatibility errors:

Line 56:

require(_token != address(0));

TypeError: Operator != not compatible with types contract ERC20 and address payable require (_token != address(0));

Line 193:

wallet.transfer(msg.value);

TypeError: "send" and "transfer" are only available for objects of type "address payable", not "address". wallet.transfer(msg.value);

1 Like

Hi @testingneverstop,

Have a look at: Simple ERC20 Crowdsale

Hi @abcoathup ,
I have the same problem like the thread opener and I cant see how your answer helps with the problem.

What am I missing?

Thank you very much.

Hey @nkccorp12,

The link @abcoathup is sharing has a detailed implementation reference that avoid these errors. The reason behind the error is clear on its description, there’s a type mismatch between variables.

  1. For require(_token != address(0)), I’m guessing the problem is because _token is a variable of type ERC20, so it needs to be casted as an address with address(_token)
  2. For wallet.transfer(…), the .transfer function is added to payable addresses, which are a special type of address. It can be casted as well with payable(wallet).transfer(…)

Marking this as a solution.
Best!

1 Like