In Browser Solidity, there's a "Transaction" tab (paper plane icon). You can choose one of two addresses, and a value. But there's no "send" button or anything of the sort. What is this section supposed to do?
3 Answers
By putting a non-zero value in the "value" field, you instruct the IDE to send that much (simulated) Ether along with any transaction it makes.
The equivalent of the "send" button that you are looking for is to simply put a value in the "value" field and then hit the (fallback) button. This will behave as if you simply sent a transaction to the contract with some Ether and no data.
- 37,046
- 10
- 91
- 118
create a simple contract
contract testMSGVALUEinBrowser{ uint lastSent; function test() public returns (uint lastSent) { lastSent = msg.value; return lastSent; } function get() constant returns( uint){ return lastSent; } }Click the transaction tab
Click the create red button
Enter a number in the transaction Value field (1234 in the example)
Click the test button that will trigger the test function, you can see it has sent 1234 Ether
Click the get blue button, it retrieves the value sent properly
- 2,299
- 1
- 15
- 28
- 4,640
- 5
- 24
- 55
-
Make sure you set the Value field back to 0 before clicking the blue button. I got a bit confused when I was first using this and it kept showing double the amount I put in. – Tjaden Hess May 19 '16 at 23:08
-
I'm not seeing those buttons. Just trying to run the basic ballet contract. http://imgur.com/a/g1Omt ... appreciate any comments. – mowliv Aug 11 '16 at 21:13
I want to to make a tiny correction to the answer that begins with "create a simple contract". As it is shown, doesn't work at 2016-08-17.
The following does work at this date (browser-solidity/#version=0.3.6):
contract lastSentValue{
uint lastSent;
function set() public returns (uint) {
lastSent = msg.value;
return lastSent;
}
function get() public constant returns( uint){
return lastSent;
}
}
- 61
- 1
- 6
