I read this where it has a function deposit() as below, without any parameter. We are supposed to send a value to msg.value but how do you do that in Remix as I can't find one text field for deposit under the Deployed Contracts section. I only know how for JS. Here's a sshot.

/// @return The balance of the user after the deposit is made
function deposit() public payable returns (uint) {
    // Use 'require' to test user inputs, 'assert' for internal invariants
    // Here we are making sure that there isn't an overflow issue
    require((balances[msg.sender] + msg.value) >= balances[msg.sender]);

    balances[msg.sender] += msg.value;
    // no "this." or "self." required with state variable
    // all values set to data type's initial value by default

    LogDepositMade(msg.sender, msg.value); // fire event

    return balances[msg.sender];

1 Answer 1


In the following example you see the Value field which is the field in remix where you can pass ETH amount to contracts when deploying them or to contract methods. As you can see you can pass in the value in different conversions ( Wei, Gwei, ETH, etc ).

P.S. I never knew why they left this confusing UX on remix, tbh every contract method should have his own Value field, but unfortunately it's not how it is.

enter image description here

  • Oh gee, I feel embarrassed...lol. Thank you so much buddy.
    – vagef53574
    Commented Jan 10, 2022 at 10:29

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.