[Ethereum] Remix How Do I Get a Value Returned From A Function In Solidity

remixsolidity

How do I get a return value in solidity?

I'm using some test code in remix, but I don't understand where the output is displayed.

my code is as follows:

pragma solidity ^0.4.17;

contract Test {
    function getValue(string something) public returns (uint) {
        return 123;
    }
}

when I call the getValue method with a string "testing123" (quote marks required), I expected the function to return 123.

the properties returned on Remix are:

decoded input:

-

decoded output

{ "string something": "testing123" }

I have read the documentation but I may not be understanding some part of it. Any help is appreciated.

Best Answer

I did copy paste your code and it works fine (although there are some warnings!). Once you deployed the contract (with the deploy button) you can call your function with the getValue button.

enter image description here

You should see the result in the bottom gray box. It shouws the whole transaction and also the decoded output.

enter image description here

UPDATE

According to the yellow paper:

enter image description here

Essentially the output is used only when the message call is performed by the execution of a contract code. Otherwise, i.e. when the message call is due to a transaction (that triggers the execution) the output should be ignored, as reported.

Related Topic