0

I'm learning smart contract, and I have a problem compiling one it gives me this error message:

Error: Type literal_string "0x5c15741c7abb1b0e8fb0bd41b5ed8c17219926a1" is not implicitly convertible to expected type address. address multisig = "0x5c15741c7abb1b0e8fb0bd41b5ed8c17219926a1";

I have tried to me it looks like that, we shouldn't hard code the contract address?

here is the code of the line causing trouble :

address multisig = "0x5c15741c7abb1b0e8fb0bd41b5ed8c17219926a1";

thank you for your help!

1

Explicit declaration as an address

You'll want to explicitly define the address instead of trying to force cast a string as an address.

To do this simply use the address() operator to make an address type value from the hexadecimal representation of the address.

Example:

address multisig = address(0x5c15741c7abb1b0e8fb0bd41b5ed8c17219926a1);
  • If this answered your question, please mark it as the correct answer. If not let me know so I can further assist. – norganna Apr 2 '18 at 3:04
0

The proper way to initialize an address is to not use quotes

address a = 0x5c15741c7abb1b0e8fb0bd41b5ed8c17219926a1;

But this generates a warning, solidity want addresses with the mixed case checksum

address b = 0x5c15741C7ABb1b0E8FB0BD41b5ed8c17219926A1;

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.