Skip to main content
10 votes
Accepted

Convert any address to accountId (in hex)

You have a couple of options. First, if you already have an initialized API in your app - const ADDR = "5DTNtGF2DmZ7QwGxg6n1xWzF6cEokNyNre7mUqpVuozrLxu3" // create a type from this const id ...
Luna's user avatar
  • 321
6 votes
Accepted

Compact SCALE decoding

Here is a description of SCALE compact-encoding. As you mentioned in your question, there are basically 4 variants indicated by the flags from the 2 least-significant bits. Effectively when decoding ...
Jaco's user avatar
  • 5,865
4 votes
Accepted

Decoding `democracy.Voted`

The aye (bool) & conviction (enum) is encoded together as a single byte. The top-most bit indicated the true/false, the remaining bits indicates the conviction. You can look here for the specific ...
Jaco's user avatar
  • 5,865
4 votes
Accepted

Decoding Polkadot/Kusama transactions in Rust

Also, Subxt doesn't currently have a means to decode transactions, but you can obtain the bytes for each transaction back currently eg: let extrinsics = api.blocks().at(hash).await?.body().await?....
jsdw's user avatar
  • 1,335
3 votes

Why SCALE vs RLP?

I am not an expert of RLP, but it does not seem these two things are that comparable. From RLP docs: The purpose of RLP is to encode arbitrarily nested arrays of binary data, and RLP is the primary ...
Shawn Tabrizi's user avatar
  • 16k
3 votes

How to create a tuple type using polkadot.js api

Tuple types are specified in the same way they are in Rust, i.e. (AccountId, u32) will yield a tuple with AccountId and u32. These are all string values, i.e. MyTuple: "(AccountId, u32)", ...
Barto's user avatar
  • 584
3 votes

Scale Codec for Dart

https://docs.substrate.io/v3/advanced/scale-codec/ is really enough to implement it completely. Otherwise, here is TypeScript implementation we use at subsquid.io, which will be probably easier to ...
Eldar's user avatar
  • 31
2 votes
Accepted

Scale codec f64 support

Basically this question boils down to: Can you use floating point numbers or math in the Runtime? While SCALE could deterministically encode and decode floating point types, the runtime can't ...
Squirrel's user avatar
  • 3,849
2 votes

Scale codec: Is there a way to extract an enum's arm's codec index value?

No there is no way to extract these information from a type. I think in your case you should just add a function to Block get_version.
bkchr's user avatar
  • 11.3k
2 votes
Accepted

Does changing an enum require a storage migration? What about `Error` and `Event`

A storage migration is needed whenever the encoded representation of the storage changes. In the case of an enum, it is represented as one byte. In the original enum: Enum::V0 == 0x00 Enum::V1 == 0x01 ...
Shawn Tabrizi's user avatar
  • 16k
2 votes

Decoding Polkadot/Kusama transactions in Rust

Subxt currently exposes only the bytes of the extrinsic to users. We plan on adding support for decoding to a concrete type generated by the subxt macro. In the meanwhile, polkadot-introspector here ...
Alexandru Vasile's user avatar
1 vote

No metadata hash in transaction

The change is not yet implemented. It is coming up in #4274. From what i understood: The metadata hash can be optionally appended at the end. This keeps backwards compatibility with existing signers ...
Oliver Tale-Yazdi's user avatar
1 vote
Accepted

Scalecodec: How can I get the equivalent of Decode in Python, instead of DecodeAll?

There is kwarg you can pass to the decode() function, so it won't check the remaining bytes: decode(check_remaining=False). I don't have much context of your use-case, but I assume you have added a ...
Arjan's user avatar
  • 151
1 vote

Decoding Polkadot/Kusama transactions in Rust

For anyone that stumbles upon this now, it has been implemented in subtx since posting the question in https://github.com/paritytech/subxt/pull/929. Example code: use subxt::OnlineClient; use subxt::...
Szymig's user avatar
  • 225
1 vote

How to provide argument to storage call in subxt?

Solved by importing SumTreeName #[subxt::subxt(runtime_metadata_path = "./artifacts/metadata.scale")] pub mod polkadot {} let client = subxt::client::OnlineClient::<PolkadotConfig>:...
Amiya Behera's user avatar
1 vote

Convert any address to accountId (in hex)

There is also the /accounts/{address}/validate endpoint in Sidecar which takes a ss58 or hex (from a u8 array) formatted address and returns the following information : isValid ss58Prefix network ...
dominique's user avatar
  • 1,683
1 vote

How to decode RPC results using Python's Scale library

Is there a specific reason why you manually want to decode raw SCALE-data? Because SCALE is without context, you need the exact type definition of the storage function and even specific runtime where ...
Arjan's user avatar
  • 151

Only top scored, non community-wiki answers of a minimum length are eligible