Error while sending an address to functions

0 votes

I am new to solidity and I have written some functions by referring to blogs and documentation. In one function, I must pass an address to send tokens to it. I have written the code for it but when I run it, I get the following error:

Invalid type for argument in a function call. Invalid implicit conversion from address to address payable request

Here is my code:

address admin;

function endSale() public {

 require(msg.sender == admin);

 selfdestruct(admin);

}

How to solve this?

Jan 23 in Blockchain by Kumar
179 views
Could you please mention the solidity version?
version is 0.5.0

1 answer to this question.

0 votes

In solidity 0.5.0 (and above) there are two datatypes for address: address and payable address. In these versions of solidity, you can send tokens only to address declared as payable, so change the address to address payable and it should work.

address payable admin;
answered Jan 23 by Omkar
• 67,660 points

Related Questions In Blockchain

0 votes
1 answer

Error in sending value to an Ethereum Smart Contract.

It is stated in Solidity 4.0 documentation ...READ MORE

answered Jul 23, 2018 in Blockchain by Perry
• 17,020 points
69 views
0 votes
1 answer

Error while trying to create dir if missing: mkdir /var/hyperledger: permission denied

The following commands should help: sudo mkdir -p ...READ MORE

answered Jul 6, 2018 in Blockchain by Christine
• 15,790 points
91 views
0 votes
1 answer
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
169 views
0 votes
1 answer
0 votes
1 answer

Solidity geth: Error encountered during contract execution [Bad instruction]

recipes is a dynamic storage array. You need ...READ MORE

answered Oct 15, 2018 in Blockchain by Omkar
• 67,660 points
100 views
0 votes
1 answer
0 votes
2 answers