Questions tagged [scale-codec]
The scale-codec tag has no usage guidance.
70 questions
0
votes
1
answer
5
views
Issues with Dependency Version Mismatch and Rust Toolchain Version for Frontier polkadot-v1.8.0 Branch
Problem Description I cloned the polkadot-v1.8.0 branch of the Frontier repository and am attempting to build the Substrate chain using Cargo. However, I'm encountering issues with mismatched library ...
1
vote
2
answers
23
views
How to use `setStorage` in Polkadot JS Apps? Entries cannot be decoded after setting
I need to manually change the storage entry of a storage map which does not have a setter function. Unfortunately, after calling setStorage($STORAGE_KEY, $NEW_VALUE) the corresponding storage cannot ...
0
votes
1
answer
35
views
How `metadata_ir::RuntimeApiMethodParamMetadataIR` derives `Encode` without deriving `Encode` on `scale_info::MetaType`
I found metadata_ir::RuntimeApiMethodParamMetadataIR derives the parity_scale_codec::Encode, but I didn't find the underlying scale_info::MetaType(T::Type) derive the Encode trait. What did I miss?
...
0
votes
2
answers
17
views
SCALE encoding how to get 29 bits in 4 bytes
i am trying to understand the SCALE encoding spec in the jam spec, where it says you can fit 29 bits plus a prefix.
2^21 ≤ x < 2^29, where the prefix is 0b1110, and takes up the left most 4 bits, ...
1
vote
1
answer
29
views
How to check the ordering of extrinsic payload for SCALE encoding in polkadot-sdk?
Below is something which I found in the polkadot-js api code
describe('ExtrinsicPayload', (): void => {
it('has a sane inspect', (): void => {
// we don't expect this to fail, however it ...
1
vote
0
answers
33
views
DOT, KSM transfer sign payload order
I want to know the scale codec order for sign payload cause currently I can't transfer WND, KSM right now
currently my codec order is
method call -> era -> nonce -> tip -> specVer -> ...
3
votes
0
answers
39
views
Why is the index of a pallet a u32(usize) instead of u8 when queried?
I'm implementing a flow where I first ask what index a pallet has with the QueryPallet xcm instruction, and then construct a call to use with Transact.
I see that to construct manually an encoded call ...
2
votes
1
answer
44
views
how to decode extrinsic data inside a pallet | Frontier
i have a pallet that prints extrinsic data (bytes and hex) of every extrinsic inside every block, how can i print it like an human readable object ("from", "to" ecc..)?
that's my ...
0
votes
1
answer
33
views
KSM, WND transfer transaction fail, but DOT success
I used the same program, the same fullnode version, and the same Substrate API sidecar version to submit transfer transactions for DOT, KSM, and WND. Only DOT was successful. Two months ago, DOT, KSM, ...
0
votes
2
answers
67
views
No metadata hash in transaction
I see from the RFC (https://github.com/polkadot-fellows/RFCs/blob/main/text/0078-merkleized-metadata.md#inclusion-in-an-extrinsic) that it's possible to not provide the hash when crafting a polkadot ...
0
votes
1
answer
39
views
How can I properly use scale::Decode to get consistent results?
I'm trying to process a result from a contract call using what's here. It works totally fine when I'm trying to get a u32 result from an ink_e2e test. E.g.
// -- Snip --
let number_of_items = client
...
1
vote
1
answer
21
views
Remove undecodable storage keys from StorageDoubleMap
I want to remove keys from the storage which cannot be decoded by using unhashed. I know there are undecodable keys because when counting the number of storage keys via MyStorage::<T>::iter_keys(...
0
votes
1
answer
29
views
How to construct the data structure with correct values for their attributes within a Pallet for data submitted by a polkadotJS app
Client App creates an Input as follows using polkadotJS to submit to Substrate Module as follows
import { ApiPromise, WsProvider } from '@polkadot/api';
const { Keyring } = require('@polkadot/keyring')...
1
vote
0
answers
51
views
How to decode contract storage returned data
How do i decode this Hex string to String. It is storage data returned from a contract, using Polkadot-JS.
{
Ok: {
flags: [],
data: '...
3
votes
2
answers
36
views
Is there any way to extract "method" and "params" of unchecked extrinsic using ScaleCode/TypeInfo traits?
I'm wondering if there is any way to extract information about method and parameter of Extrinsic(Unchecked/CheckedExtrinsic) using TypeInfo and Scale codec.
In polkadotJs there is toString method on ...
1
vote
0
answers
29
views
How do I scale decode a Vec<u8> within an ink smart contract?
This is within my smart contract's module:
// THIS IS BEING USED: use ink::prelude::vec::Vec;
#[ink(message)]
pub fn test_encoding(&mut self) -> Result<u32, ...
0
votes
1
answer
259
views
How to properly decode a SCALE-encoded string using polkadot-js?
Using @polkadot-js/api, one can encode a string aabbcc into 0x18616162626363
> u8aToHex(api.createType('String', "aabbcc").toU8a())
"0x18616162626363"
I know that SCALE ...
3
votes
0
answers
53
views
After using set_code_hash to upgrade contract, when decode on the new Storage,why there wont has error of "Not enough data to fill buffer"
I'm learning how to upgrade ink! contract,and have some question:
Eg:old contractA, storage define is
#[ink(storage)
pub struct MyContract {
a: u32,
}
new contractB,storage define is
#[ink(...
0
votes
1
answer
121
views
Scalecodec: How can I get the equivalent of Decode in Python, instead of DecodeAll?
When using the Python script:
timestamp = ScaleDecoder.get_decoder_class('Timestamp', ScaleBytes(timestamp_bytes_array)).decode()
it seems that the decoder expects the size of the array to be exactly ...
1
vote
2
answers
15
views
What is the purpose of the `contracts_runtime.scale` file in the `cargo-contracts` repository?
Cargo Contract is a popular tool for developing ink! contracts.
This tool is known to work well with the substrate contracts node, and I thought it should work with other chains that support pallet ...
5
votes
0
answers
98
views
I want to use Parity SCALE codec in Solidity? Is there any implementation of scale codec to decode bytes?
I want to decode bytes on the Solidity side that was decoded with scale codec.
Is the any implementation of scale codec (decode) on the Solidity side?
3
votes
1
answer
132
views
What is Dev Mode? And how can I use it?
I heard there is something called Dev Mode in Substrate for pallet development.
What is Dev Mode? And how can I use it?
5
votes
4
answers
211
views
Decoding Polkadot/Kusama transactions in Rust
I would like to inspect transactions (extrinsics) in a given block to potentially:
Find different types of transactions and their parameters
Look through all transactions included in the block and ...
4
votes
1
answer
80
views
Implications of invalid encoded extrinsic calls
We are seeing the following error whenever an invalidly encoded but properly signed extrinsic is submitted in our substrate based chain.
{
"jsonrpc": "2.0",
"error&...
7
votes
0
answers
96
views
Why do clients have to hardcode the extra types in the registry?
Context: I'm experimenting with an H160-address based substrate and I'm doing it from scratch (it's not a moon* or frontier template fork).
It's reasonably trivial to make changes to the substrate ...
0
votes
2
answers
107
views
How to decode an error that happened in a proxy.proxy call
I'd like to show my users if an error occurred while doing a proxy.proxy call.
While I know how to decode a system.ExtrinsicFailed, as this is well documented, I have difficulties finding the correct ...
2
votes
1
answer
55
views
Stable scale encoded events from ink contract
How to obtain a stable encoding of emitted events from a smart contract?
I have a smart contract which emits events when these events are later fetched from the chain:
#[ink(event)]
pub struct ...
2
votes
2
answers
142
views
Decode preimages Bounded Dispatchable Call on a client side
I'm using Bounded trait from preimages frame that allows to store dispatchable calls, e.g. similar to the one that is used in pallet-democracy:
pub type CallOf<T> = <T as frame_system::Config&...
2
votes
1
answer
55
views
function or associated item not found in `std::vec::Vec<u8>` when using MaxEndodedLen
I have a struct definition as follows
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo, MaxEncodedLen)]
pub struct Songs {
pub name: Vec<u8>,
pub cast: Vec<u8>,...
0
votes
1
answer
197
views
How do we work with polkadot-js enums in TypeScript?
I used typegen to generate my types from definitions.
Definition
Person: {
status: 'Status',
balance: 'u128',
},
Status: {
_enum: ['Active',...
0
votes
1
answer
73
views
How to get human-readable ASTR balance in Golang
This question is continued from How to get ASTR balance via json rpc.
I understood calculating StorageKey from Publickey is needed.
It seems that calculating StorageKey and decoding rpc-json responses ...
2
votes
1
answer
51
views
How to provide argument to storage call in subxt?
In polkadotjs I have following code:
const opts = [{"UniqueIdenfier1":[0,"challengeprofile"]}]
let data = api.query.templateModule.periodName(
...opts,
...
2
votes
2
answers
96
views
Implement MaxEncodedLen for Nested Origin
orml-authority implements a mechanism to allow origin to dispatch calls after and only after a delay. This is implemented using a pallet origin DelayedOrigin.
The DealyedOrigin references the original ...
2
votes
1
answer
71
views
Reading arguments in chain extension
I have a question about reading data in a chain extension. To be precise, I'm concerned about methods Environment<_,_,_,S: BufIn>::read*. Do I understand correctly, that every such function ...
0
votes
1
answer
111
views
Decoding extrinsic hex into readable form in Rust
I am running the substrate-dev node. Made a transaction using Polkadot-explorer. After fetching the block using subxt I am getting extrinsic hex as:
...
2
votes
1
answer
73
views
What's the difference between `transaction_version` and `EXTRINSIC_FORMAT_VERSION`?
Substrate has the concept of a transaction_version and an EXTRINSIC_FORMAT_VERSION. What are these used for and when are they changed?
2
votes
1
answer
275
views
The trait Deserialize is not implemented for a Get<u32> constant
I am implementing the MaxEncodedLen trait for my pallet. I have this struct in a separate crate. I use this struct as my GenesisConfig, which is why it derives serde::Serialize and serde::Deserialize :...
2
votes
1
answer
80
views
Why SCALE vs RLP?
What are the differences between SCALE and RLP serialization beyond little-endian vs big-endian encoding? If both are length-encoded, what might make one better than the other?
3
votes
1
answer
76
views
Decoding `democracy.Voted`
I'm having trouble decoding a democracy.Voted event on Polkadot - for example: https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Frpc.polkadot.io#/explorer/query/...
0
votes
1
answer
167
views
Create hex encoded call (for XCM transact call) in javascript?
I'm trying to create the encoded element for an XCM V0 transact call such as:
const message = {
V0: {
Transact: {
originType: "Native",
...
2
votes
1
answer
103
views
Does changing an enum require a storage migration? What about `Error` and `Event`
Say I have instances of this enum stored on-chain:
enum Enum {
V0,
V1,
}
And suppose now that I change the enum in some way:
enum Enum {
V0,
V2,
V1,
}
This is what the substrate ...
0
votes
0
answers
178
views
Polkadot Explorer: decode storage system.events [closed]
I was doing some testing and sent a transaction on a custom substrate chain. On the polkadot explorer, the block which held the transaction had an error. The transaction completed; however, the ...
2
votes
3
answers
844
views
Convert any address to accountId (in hex)
How can i convert an address of the form "5DTNtGF2DmZ7QwGxg6n1xWzF6cEokNyNre7mUqpVuozrLxu3" to hex using polkadotjs packages?
Here is the context:
I have multiples array of datas, containing ...
2
votes
1
answer
94
views
How to create a tuple type using polkadot.js api
I am trying to create a tuple. I know we can create an enum by defining the type as
MyEnum: {
_enum: {
'account': String,
'accountId': 'u128'
...
0
votes
1
answer
165
views
How to decode RPC results using Python's Scale library
I'm trying to get the chain state information from substrate using RPC for IdentityOf of any Accountid
Upon succesfull request, I get the following result:
{
"jsonrpc": "2.0",
...
5
votes
1
answer
190
views
Migrate keytype of StorageMap without breakin API
Assume we have a StorageMap MyMap of which we want to extend the type of the decoded keys from KeyTypeOld to an enum including the old type as well as a new one.
Before
pub type MyMap = StorageMap<...
2
votes
1
answer
377
views
How to decode an unsigned transaction using polkadot.js
If I have some unsigned transaction, eg 0x040300865ea... and I wanted to decode it into a format like:
method: "balances",
section: "transfer":
...
Is there a way to do that using ...
3
votes
2
answers
228
views
How does the encoded transaction in `Transact` turn into decoded transaction `call` when executing instructions in XCM?
let message_call = call.take_decoded().map_err(|_| XcmError::FailedToDecode)?;
https://github.com/paritytech/polkadot/blob/master/xcm/xcm-executor/src/lib.rs#L342
I got this code above and tried to ...
3
votes
1
answer
73
views
Scale codec f64 support
What is the reason that the SCALE codec does not support Encode and Decode of f64 types?
4
votes
1
answer
209
views
Compact SCALE decoding
In this answer the compact decoding for 1 byte and multi-byte versions have been detailed. I did a sample implementation based on that information and it does what it is supposed to, at least for the ...