5

https://solidity.readthedocs.io/en/latest/solidity-by-example.html#simple-open-auction

pragma solidity ^0.4.22;    
contract SimpleAuction {
    address payable public beneficiary;

What exactly does payable mean here? Are there non-payable addresses? Should one always explicitly declare state variables of type address like so?

2 Answers 2

1

A payable address means it can receive Eth. It is similar to a payable modifier. The functions which have a payable modifier can send and receive eth.

payable(address).transfer(amount)
-1

I tried to compile the entire code. It doesn't go past that line. Payable shouldn't be declared with the name variable else you are getting

'Expected identifier but got 'payable' at address payable public beneficiary;'

I assume it's just an error. If you remove 'payable' in line 7 and line 35 the code works fine, else it doesn't compile.

1
  • I find it weird, that an example in the documentation is wrong. However, it is possible that it is also a deprecated feature .. I will take a look to the GitHub repository
    – Briomkez
    Commented Sep 23, 2018 at 5:27

Your Answer

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

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