I am writing a solidity public function that changes the value of state variable and then returns it.

pragma solidity >=0.4.22 <0.6.0;

contract white_label {

    uint currentId = 1;

    function uploaded() public returns(uint){
        return(currentId - 1);

This functions returns value exactly as expected when run in Javascript VM on Remix but when the contract is deployed on Ropsten Testnet, no value is returned from the function

2 Answers 2


This function is non-constant (neither pure nor view), so the returned-value can be fetched by on-chain calls (contract functions), but not by off-chain calls (web3 functions).


  1. If you don't need to call this function from the on-chain, then you may as well get rid of the return-value.
  2. If you need to call this function from the off-chain, then you have two ways for obtaining the return-value:
    • Emit an event which contains this value.
    • Implement a view function which returns the value of currentId, and call it after you call function uploaded

You cannot get a return value from a transaction this way. Transactions, to the best of my knowledge on Ropsten, return the TX hash. If you want the value, you need to ask for it after the block confirms.

Indeed there are exceptions.

If another functions calls this one (in your sample), that function will get the return value. And outside of the actual blockchain (like in your dev environment), you can get that return value.

But the blockchain itself does not return anything but a TX hash when you run a transaction.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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