Can't get Sophia contract variable value


#1

Hey all,
I’m trying to get Sophia contract state value, but call always returns that “0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000E0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E00000000000000000000000000000000000000000000000000000000000000000”

Contract is deployed and mined.

Contract code:

contract Counter =
type state = { value : string }
public function init(val) : state = { value = val }
public function get() = state.value
public stateful function set(val) : state = { value = val }

Any ideas?
Thanks!


#2

Hey @lcsavov,

Our devs will get back to you as soon as possible.

Thank you for your question,
The AE Team


#4

@zzy, Still not.
Post must be at least 20 characters.


#5

I did not manage to reproduce your contract state (I tried both on version 0.18.0 and 0.17.0), though let me see how I can help.

In the contract code you specified, I read type state = { value : string }: I assume you tried with epoch version 0.17.0. Could you please try on epoch version 0.18.0? It has a relevant fix in the user API:

Enables HTTP path /contract/decode-data to decode return values from Sophia contract calls.

I put together an overview on how I understand you are using the contract, meant to work on epoch version 0.18.0. Notice in particular the call to the decode_data API. You find the overview in this temporary commit (this is a temporary commit: a more stable reference to that file - though with a different sample contract - is available here ).

The Sophia data memory layout is documented here.

Regards,
Sergei Evdokimov