Solidity – TypeError: Literal String WALLET_ADDRESS Not Implicitly Convertible to Type Address

remixsolidity

Anyone know what this error means in Remix – Solidity IDE?

address public constant WALLET = "A_WALLET_ADDRESS";

TypeError: Type literal_string "A_WALLET_ADDRESS" 
is not implicitly convertible to expected type address.

Best Answer

It turns out the address constant did not want a quoted string

The solution was: address public constant WALLET = A_WALLET_ADDRESS;

If anyone can explain why, ill gladly accept the answer :)

I imagine its due to the strict type checking of Solidity variables. Giving "0xValidAddress" fails as its type is "string" whereas 0xValidAddress passes the type check as a valid Ethereum address, therefore is allowed to pass on

Related Topic