4

Using the Solidity online compiler set to its own JavaScript VM, calling any function with ether in msg.value throws an exception. I don't see a way to add an ether balance to an address.

  • The second tab (the one next to the gear), allows a Value to be specified when a function is invoked. Does that help? May need to invoke a dummy function that will send the ether to a desired address first. – eth Oct 23 '16 at 6:30
  • Exactly, and if I put a non-zero value in that field, the VM always throws an exception. The only reason I can think of is that the account has no eth, though in that case I don't know how it's paying gas. I've tried it with as little as one wei...throws with that, doesn't throw with zero. And I can't find anywhere that tells how much eth each account has. – Dennis Peterson Oct 23 '16 at 6:40
2

Since Solidity 4.0 you have to mark your functions with the modifier payable in order to take Ether. This is a security measure, to avoid unwanted payments that happened often, for example with theDAO contract.

payable for functions: Allows them to receive Ether together with a call.
- from Solidity Documentation - Modifiers

When doing so, you will be able to invoking the browser-solidity transaction with an Ether charge and it will not throw an exception anymore.

Keep an eye on the current changes because Solidity is moving quickly as the entire Ethereum system does: https://github.com/ethereum/solidity/blob/develop/Changelog.md

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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