Skip to content

Commit

Permalink
Adapt But careful sentence
Browse files Browse the repository at this point in the history
  • Loading branch information
haerdib committed Dec 5, 2023
1 parent 40c43e2 commit 5e97453
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,4 @@ _In alphabetical order_

3. Q: I want to retrieve a state from a substrate node via the api-client, but I do not get the expected value respective the decoding fails. How come?

A: When specifying your own state query, you must provide the return type of the state you're trying to retrieve. This is because the api-client only gets bytes from the node and must be able to deserialize these properly. That is not possible without knowing the type to decode to. This type may be for example a simple `u64` for retrieving the `Balance` of an account. But careful: Often, but depending on the pallet configuration, the node returns an additional `Option`. So it's rather an `Option<u64>` than a simple `u64`. Possible pallet configurations are `OptionQuery`, `ResultQuery` and `ValueQuery` (see the [substrate docs "Handling query return values"](https://docs.substrate.io/build/runtime-storage/) for more information). Please check your pallet configuration and adapt the expected return type accordingly in the api-client. And always remember to match the type to your Runtime! If you're fetching events for example, ensure it's the event type provided by your node runtime, not by any other.
A: When specifying your own state query, you must provide the return type of the state you're trying to retrieve. This is because the api-client only gets bytes from the node and must be able to deserialize these properly. That is not possible without knowing the type to decode to. This type may be for example a simple `u64` for retrieving the `Balance` of an account. But careful: Depending on the pallet configuration, the node might return an `Option`. So it's rather an `Option<u64>` than a simple `u64`. Possible pallet configurations are `OptionQuery`, `ResultQuery` and `ValueQuery` (see the [substrate docs "Handling query return values"](https://docs.substrate.io/build/runtime-storage/) for more information). Please check your pallet configuration and adapt the expected return type accordingly in the api-client. And always remember to match the type to your Runtime! If you're fetching events for example, ensure it's the event type provided by your node runtime, not by any other.

0 comments on commit 5e97453

Please sign in to comment.