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.
Asked
Active
Viewed 1,135 times
4
jrbedard
- 524
- 1
- 6
- 15
Dennis Peterson
- 1,936
- 13
- 15
-
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 06: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 06:40
1 Answers
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
Roland Kofler
- 11,638
- 3
- 44
- 83