I wrapped a smart-contract generated in remix into a Java Project. Im trying to get the two values that return me this function.

function getValues(address _a) external returns(bool, uint32) {
    uint32 n= data[_a].number;
    return (true, n);

The problem is that the returned value is a TransactionReceipt. How can I recover bouth value; The boolean and the uint??


The problem is that the returned value is a transaction-receipt. How can I recover both values?

Add view to the function declaration, and the returned value will be a tuple (bool, uint32).

Otherwise (if there's something that you're not telling us about the function, for which it cannot be declared view), you'll need to emit an event with the return values, and fetch it from the transaction-receipt.

  • 1
    Thankyou for the answer. understood. Im going to open a new question because I dont know how to recover values of a event from web3j, if you can help me – UnexpectedCharacter Mar 4 at 8:38
  • @UnexpectedCharacter: So what's wrong with this answer? – goodvibration Mar 4 at 9:37
  • I change the function visibility adding view to the function. When I wrapped the contract to a java class the error persist. And I have to manage the TransactionReceipt instead of a tuple T<boolean, BigInteger> – UnexpectedCharacter Mar 4 at 9:39
  • 1
    @UnexpectedCharacter: Are you sure that you have compiled (or rebuilt) the contract? – goodvibration Mar 4 at 9:42
  • Yes I check and is done. Still returning TransactionReceipt – UnexpectedCharacter Mar 4 at 9:49

The function can be made view and then you can use call from web3. This won't make a transaction but will just execute the function on the node you are connected to. The result will be the values that you expect.

Hope this helps

  • Thankyou for the help !! – UnexpectedCharacter Mar 4 at 8:42
  • I change the function and I add the view. But When I wrapp the contract to a Java class. Still telling me that I have a TransactionRecepit return. Any idea? – UnexpectedCharacter Mar 4 at 9:34
  • can you post your java script code?. remember you need to update the ABI in your code and use call with your contract method. – Jaime Mar 4 at 10:48
  • I´m not using web3js. The library is the web3j. I think that the call method is not implemented – UnexpectedCharacter Mar 4 at 11:03
  • i tell that because in the documentation I can´t find – UnexpectedCharacter Mar 4 at 11:03

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.