6

How use payable function using interface of browser solidity IDE Remix ? http://ethereum.github.io/browser-solidity/#version=soljson-v0.4.11+commit.68ef5810.js

enter image description here

2 Answers 2

7

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.

2
  • Thanks for the answer. My question is then, how and where the received Ether is stored?
    – user153465
    Aug 9, 2017 at 15:35
  • It is stored at the contract address.
    – Bryan
    Jan 27, 2022 at 0:42
3

Update 2022:

I recently tried to use a payable function in Remix and could not find the Value input described in previous SCBuergel's answer. Remix changed its interface and move the Gas Limit and Value inputs.

As of today (Oct 2022), this inputs are located at the top of the left sidebar. At some point I was confused and thought they were only for the deploy section but then I realized that it is for the whole interaction. They moved all the transaction/wallet features to the top.

enter image description here

1
  • I can confirm, It works
    – Alejo Dev
    Mar 10, 2023 at 3:02

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.