6

I am quite new to solidity, and I have not managed to find a solution for this problem.

I am passing the function an address but it says the following: "Invalid type for argument in function call. Invalid implicit conversion from address to address payable request."

address admin;

function endSale() public {
 require(msg.sender == admin);
 selfdestruct(admin);
}

3 Answers 3

1

Elsewhere in the contract, find address admin; and declare it as address payable admin;.

Alternatively, selfdestruct(msg.sender); because require(msg.sender == admin); ensures they are the same and msg.sender should be payable.

8

As of Solidity 0.5.0, there are two different address types in solidity: address and address payable.

You can only transfer funds to an address payable.

Therefore, your problem will be fixed by making admin an address payable:

address payable admin;
0
4

You can cast to address payable with this code:

selfdestruct(address(uint160(admin)));

Solidity 0.6.x update:

selfdestruct(payable(admin));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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