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.


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


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.

  • that works for me too in the javascript vm environment, but i am trying to do this on the injected web3 environment with Metamask on ropsten. do you know why that wouldn't be working? – X0r0N May 30 '18 at 20:50
  • With a private local network (i.e. with web3) I have exactly your output "-". – Briomkez May 30 '18 at 21:11
  • no problem. is this some kind of bug on remix? i think the example contract looks too simple to have any bug. – X0r0N May 30 '18 at 21:14
  • Please take a look to my update. – Briomkez May 30 '18 at 21:16
  • thanks. i am fluent in english, but i am struggling to understand the wording from the yellow paper. solidity is not my expertise, are you able to explain why the example i created does not work? – X0r0N May 30 '18 at 21:23

Did you try to add the


modifier like so ? (also it's better if you do something of your string ;) :

pragma solidity ^0.4.17;

contract Test {

    function getValue(string something) public view returns (string, uint) {
        return (something, 123);

works like a charm on remix.


It might be because web3 sends transactions to methods that do not have the view or the constant modifier, instead of making a call.

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.