1

In older solidity compilers this code snippet works. In newer compilers, I get an error. Can someone what I need to change so it works again? I get the following error message: "Type contract createWallet is not implicitly convertible to expected type address. I extracted the snippet so it is easier to see my problem.

contract factorywallet { 

   function newWallet(uint256 _unlockDate) public returns(address wallet){
        wallet = new createWallet(msg.sender);
    }
}





contract createWallet{
    address public owner;

    constructor(address _owner) public {
        owner = _owner;
    }
}
2

You can just use an explicit cast:

wallet = address(new createWallet(msg.sender));
  • Shouldn't that be address(new createWallet(mag.sender))? – Rosco Kalis Jan 5 at 8:47
  • That's better, yes. Edited. (Both work.) – smarx Jan 5 at 8:54
  • Cool, didn't know the first way of casting worked as well – Rosco Kalis Jan 5 at 10:16

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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