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
67 views
Could you please mention the solidity version?
version is 0.5.0

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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
• 65,840 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
• 16,450 points
30 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
29 views
0 votes
1 answer
0 votes
1 answer

How do I get the total amount sent to an address?

If you are using web3JS you can ...READ MORE

answered Jul 18, 2018 in Blockchain by Johnathon
• 9,050 points
20 views
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
63 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
• 65,840 points
28 views
0 votes
1 answer
0 votes
2 answers

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.