0
constructor(
    uint _biddingTime,
    address payable _beneficiary
) public {
    beneficiary = _beneficiary;
    auctionEndTime = now + _biddingTime;
}

This code is from the contract SimpleAuction in the solidity documentation. https://solidity.readthedocs.io/en/v0.6.4/solidity-by-example.html

What does a payable parameter mean?

2 Answers 2

2

In this example:

constructor(
    uint _biddingTime,
    address payable _beneficiary
)

address payale

casts _beneficiary as Type: address payable

In Solidity an address can be payable which attaches the .send() and .transfer() methods. Otherwise, it's the same as address _beneficiary.

A constructor, or other function, can also have the payable modifier which is sort of what I thought the question was about, because on the title.

contructor(Type arg, Type arg) public payable { ...

With that usage, one can send Ether with the deployment transaction and it will add to the deployed contract's balance.

Hope it helps.

0

In example you mentioned address payable _beneficiary means that _beneficiary can receive ethers. With having payable keyword now _beneficiary.send(etherAmount) and _beneficiary.transfer(etherAmount) can be used in the contract logic.

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.