How do I get the return value when calling a smart contract method? I use concordium_rust_sdk and client.send_block_item()
but I do not understand how to retrieve the data that I am returning from my smart contract.
The return value is not possible to retrieve from the transaction.
You can get the return value if you invoke_instance
instead, which executes the operation and returns the result, rather than committing a transaction. This is typically what you want for view functions.
Is that your use-case?
Ha, just now I found it out myself. Ok, thanks, then I am on the right track.
Hey there, some clarification is needed on this.
Suppose I have a method “update” to a contract that changes state. I want to get the return value of that call. When I now invoke the contract, using the block that I get from the wait_until_finalized
function, the state is already changed. Therefore, I cannot use the same contract method “update”. I must rather define a separate view method for getting the return value. Is that right?
Could I alternatively use an earlier block and use the “update” method?
You could use the parent block of the block your transaction ends up in.
But a more common thing would be to have a separate “view” function for viewing your state, and you use that one after the call if you need to view the state.