[Ethereum] How use payable function with browser solidity


How use payable function using interface of browser solidity IDE Remix ?

enter image description here

Best Answer

A payable function like in the following contract

pragma solidity ^0.4.0;
contract testPay {
    function pay() payable {

can be used just like a normal function call by clicking the button. Additionally, you can send Ether to the smart contract by filling out the Value field on the top, e.g. here I sent along 1 Ether enter image description here

Once you click the button, not only your function will be called but also the contract will receive 1 Ether. Note that the default units are Ether not Wei.

Related Topic