1

what is the wrong with this function i can't get the address of LenderRegistration contract

mapping (address=>address) lendersToContracts;    
function lenderRegister(uint256 _rentedStorage) public isNewLender returns (bool) {
    lendersToContracts[msg.sender] = new LenderRegistration(Admin, _rentedStorage, Token, msg.sender);
    lenderIndex++;
    return true;
}

the error after compiling

typeError: Type contract LenderRegistration is not implicitly convertible to expected type address.
        lendersToContracts[msg.sender] = new  LenderRegistration(Admin, _rentedStorage , Token ,msg.sender);
  • isNewLender is a modifier , and LenderRegistration is another contract that i imported with 4 parameters – Mahmoud M. Tayel Feb 8 at 2:36
1

See "explicit conversions": https://solidity.readthedocs.io/en/latest/types.html#address

lendersToContracts[msg.sender] = address(new LenderRegistration(...));

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.