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, 2019 in Blockchain by Kumar
3,118 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, 2019 by Omkar
• 69,220 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,100 points
1,396 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
1,852 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
1,901 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,423 views
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
• 69,220 points
1,437 views
0 votes
1 answer

Is the msg.sender address changed while passing to another contract as a parameter?

I tried your contracts in Remix, but ...READ MORE

answered Oct 10, 2018 in Blockchain by Omkar
• 69,220 points
1,342 views
0 votes
2 answers

Why is network already up to date while trying to deploy a contract on truffle?

I guess you have ganache running already ...READ MORE

answered Apr 24, 2018 in Blockchain by Shashank
• 10,400 points
4,536 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP