Skip to main content
7 votes

How to decode extrinsic at json-RPC call's data(byte code)

You can use @polkadot-js and do something like this: const wsProvider = new WsProvider('wss://rpc.polkadot.io'); const api = await ApiPromise.create({ provider: wsProvider }); const exampleBlockNumber ...
Bruno's user avatar
  • 8,315
7 votes
Accepted

How to decode extrinsic at json-RPC call's data(byte code)

As mentioned in the wiki page https://wiki.polkadot.network/docs/build-node-interaction, some return values (like extrinsics) are SCALE encoded and you need to decode them by using the metadata. You ...
dominique's user avatar
  • 1,683
7 votes
Accepted

Migrate keytype of StorageMap without breakin API

First of all, there's a misunderstanding here. Defining something like #[pallet::storage] pub type MyMap = StorageMap<_, Blake2_128Concat, KeyTypeOld, V>; #[pallet::storage] pub type MyMapNew = ...
kianenigma's user avatar
  • 2,799
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
4 votes
Accepted

Implications of invalid encoded extrinsic calls

Great question! What are the security implications of panicking inside the WASM when an extrinsic can not get decoded successfully? Before a transaction enters the tx pool the tx is validated using ...
Daan van der Plas's user avatar
4 votes
Accepted

How can I decode an extrinsic or event dynamically in rust?

Regarding dynamic event decoding, this is something that cargo-contract does. It is not easily reusable at the moment but feel free to copy the code and use it for inspiration. Start here. The other ...
Andrew Jones's user avatar
4 votes

What is the difference between check_extrinsic and uncheck_extrinsic?

UncheckedExtrinsic is the format in which the outside is sending the extrinsic to the node. This extrinsic is aware of the full structure, meaning it knows how to decode the Call signature etc. The ...
bkchr's user avatar
  • 11.5k
3 votes

How does the encoded transaction in `Transact` turn into decoded transaction `call` when executing instructions in XCM?

Every XCM contains a type parameter Call that allows you to specify exactly what the type of the Call is. Thus, if you want to turn into a specific Call type, you have to ensure that your XCM type ...
Keith Yeung's user avatar
  • 2,121
3 votes
Accepted

What is the difference between check_extrinsic and uncheck_extrinsic?

The correct way to work with data coming from a substrate node is to use a tool or library that uses the Metadata to decode rpc responses correctly, as shown here: https://docs.substrate.io/v3/runtime/...
Joshua Mir's user avatar
3 votes

How to solve 'Invalid transaction version'?

For the sake of answering this question (though I have replied to you elsewhere already on this topic); The transaction format is not just a simple SCALE encoding of some details. In rust pseudocode, ...
jsdw's user avatar
  • 1,335
2 votes
Accepted

Is there a way to know what event it is without decoding the encoded extinsisc?

No, there is currently not a way to know which extrinsics would emit which event types, or what those events would mean. FRAME provides a fully customizable programming environment, which means that a ...
Shawn Tabrizi's user avatar
  • 16.1k
2 votes

How to decode an error that happened in a proxy.proxy call

Thanks a lot forgetso for your help. this definitely got me on the right track. For some reason, the asModule didn't work. I had subsequent TS errors such as toNumber is not a function. I had to use ...
Tbaut's user avatar
  • 253
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

Remove undecodable storage keys from StorageDoubleMap

if the original issue is coming from decoding keys in the iter_keys of StorageDoubleMap, I would manually iterate all the keys and try to decode them. Also, in your current code, in unhashed::get::<...
dastansam's user avatar
  • 576
1 vote
Accepted

How to construct the data structure with correct values for their attributes within a Pallet for data submitted by a polkadotJS app

JS encode: const registry = new TypeRegistry(); const someNameInstance = registry.createType('{"current_fraction":"u32"}', { current_fraction: 123 }); const encoded = ...
AurevoirXavier's user avatar
  • 10.6k
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 decode an error that happened in a proxy.proxy call

I think you need to strip the trailing zeroes from the error code and decode the error as follows: const mod = dispatchError.asModule const error = api.registry.findMetaError( ...
forgetso's user avatar
  • 1,514
1 vote

Decode preimages Bounded Dispatchable Call on a client side

The Bounded that you got there already is decoded. What you want to do now is to decode the content of the Bounded<Call>. I just tried that locally and it did not work but could work with your ...
Oliver Tale-Yazdi's user avatar
1 vote

Decoding extrinsic hex into readable form in Rust

You need to confirm the Type first. Then: use parity_scale_codec::Decode; #[derive(Debug, Decode)] struct MockExtrinsicType { .. } let extrinsic = MockExtrinsicType::decode(&mut &*...
AurevoirXavier's user avatar
  • 10.6k
1 vote

How does the encoded transaction in `Transact` turn into decoded transaction `call` when executing instructions in XCM?

first byte: pallet id, second byte: call position in the order defined on the pallet, third byte and onwards: arguments encoded in SCALE, and put in the order defined on the fn parameters definition (...
Juan Ignacio Rios's user avatar

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