So I have a rust contract that has a storage mapper for an arbitrary value. I store it based on a identifier which is an u64
.
#[view(getVersion)]
#[storage_mapper("someValue")]
fn get_value(&self, identifier:u64) -> SingleValueMapper<u64>
When I query this using the API or erdJs I always get
{
"statusCode": 400,
"code": "user error",
"message": "storage decode error: input too short"
}
What am I doing wrong?
So what I was doing wrong here was not the code of the contract itself but rather I was calling a query for a value that was not stored.
I was trying to reach a value that was not set in my case. For example I had these values
1 -> 100
2 -> 200
3 -> 300
5 -> 500
notice how identifier "4" does not have any reference stored. So I was trying to query this view for the identifier "4" and therefore I was getting a storage decode error
because the storage was empty for that value.