0

The following code,

function createForwarder() public returns (address) {
   return new Forwarder();
}

gives error,

TypeError: Return argument type contract Forwarder is not implicitly convertible to expected type (type of first return variable) address.
return new Forwarder();

Currently I am using pragma solidity version ^0.5.1, how can I solve this particular error?

1

Option #1: Change new Forwarder() to address(new Forwarder()).

Option #2: Change returns (address) to returns (Forwarder).

I'd go with #1 (to be honest, I've tried #2 only with interfaces).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.