Solidity: casting address to address payable

0 votes

I have written a solidity program in which one function has an address that I have to send tokens to. I read somewhere that to send tokens to an address, it should be declared as payable. I am not able to figure out how to do it. I tried direct casting:

address payable variable_name;

It is not working for me. Please help.

Jan 23 in Blockchain by Kunal
593 views

1 answer to this question.

0 votes

I don’t see why direct casting isn’t working, maybe some permission issues. Anyways, you can cast address using different ways. Try this:

address addr = 0x****;
address payable wallet = address(uint160(addr));

Let me know if it works.

answered Jan 23 by Omkar
• 67,660 points

Related Questions In Blockchain

0 votes
1 answer

How to get all address and send ethers in solidity using a loop?

I found a similar code somewhere: contract  Holders{ uint ...READ MORE

answered Jul 31, 2018 in Blockchain by digger
• 26,550 points
237 views
+1 vote
2 answers

How to convert INT to STRING in Solidity?

Look at the following code : function uintToString(uint ...READ MORE

answered Jun 27, 2018 in Blockchain by Christine
• 15,790 points
1,175 views
0 votes
1 answer

How to set web3 solidity variable value?

The setLog transaction has not yet been mined by ...READ MORE

answered Jul 6, 2018 in Blockchain by Christine
• 15,790 points
155 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
103 views
0 votes
0 answers

Error: Unexpected token o in JSON at position 1

I have been working with Interacting a ...READ MORE

Mar 6 in Blockchain by saeedi
• 120 points

edited Mar 6 by Omkar 502 views
+3 votes
3 answers

How to validate bitcoin address?

I found these 2 scripts online: Javascript: <html> <head> <script type="text/javascript" ...READ MORE

answered Aug 17, 2018 in Blockchain by slayer
• 29,170 points
946 views
0 votes
2 answers

How to check if bitcoin address is valid?

For Java, have a look at the ...READ MORE

answered Aug 20, 2018 in Blockchain by Omkar
• 67,660 points
398 views