Questions tagged [scale-codec]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
3 votes
2 answers
23 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 ...
Mateusz Nowakowski's user avatar
0 votes
0 answers
16 views

What is the usecase of `PassBy` trait bound

While working on types between Runtime and Host functions, types going from Runtime to host function requires a PassBy trait bound while types going from Host function to Runtime does not need that ...
vedhavyas's user avatar
  • 155
0 votes
1 answer
95 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 ...
btwiuse's user avatar
  • 271
3 votes
0 answers
43 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(...
ruarua's user avatar
  • 31
0 votes
1 answer
69 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 ...
The Quantum Physicist's user avatar
1 vote
2 answers
12 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 ...
JoshOrndorff's user avatar
  • 1,105
5 votes
0 answers
74 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?
rust.dev's user avatar
  • 509
3 votes
1 answer
56 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&...
Aramik M's user avatar
7 votes
0 answers
76 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 ...
Farcaller's user avatar
  • 148
2 votes
1 answer
51 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 ...
Simson's user avatar
  • 1,100
2 votes
2 answers
104 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&...
Oleg Kalenik's user avatar
0 votes
1 answer
157 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',...
forgetso's user avatar
  • 1,462
0 votes
1 answer
58 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 ...
user3563's user avatar
2 votes
1 answer
40 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, ...
Amiya Behera's user avatar
2 votes
2 answers
85 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 ...
Bryan Chen's user avatar
2 votes
1 answer
51 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?
Sacha Lansky's user avatar
  • 2,610
0 votes
1 answer
138 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", ...
lucgerrits's user avatar
2 votes
1 answer
76 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' ...
Emmanuel Thomas's user avatar
2 votes
1 answer
294 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 ...
Bread's user avatar
  • 95
3 votes
1 answer
62 views

Scale codec f64 support

What is the reason that the SCALE codec does not support Encode and Decode of f64 types?
Mathis Wellmann's user avatar
2 votes
1 answer
61 views

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

Using scale, an enum can be written like this: #[derive(Debug, Clone, PartialEq, Eq, Encode, Decode)] pub enum Block { #[codec(index = 101)] V1(BlockV1), } The #[codec(index = 101)], the 101 ...
The Quantum Physicist's user avatar
4 votes
1 answer
431 views

Decoding events with Rust

If I make a request to get events in a particular block using web UI, I get a nice human-readable response: I've made an RPC call to get the same data { "id": 1, "jsonrpc":...
Amir Boziev's user avatar
3 votes
1 answer
299 views

Ink cannot derive SpreadLayout and SpreadAllocate for simple struct and enum

When developing Ink! smart contracts I found that SpreadLayout and SpreadAllocate cannot be derived for simple structs or enums that are members variables of the contract and I have to implement the ...
mastro's user avatar
  • 217
3 votes
1 answer
85 views

Can SCALE compact encoding be used with `Option<T>`? If so, how exactly?

I can't find anything on how to use the compact encoding of integers with Option<...>. Is this possible? And to elaborate, if I do something like this: #[pallet::call] ... { fn ...
mkl's user avatar
  • 420
4 votes
1 answer
214 views

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

How can I decode an extrinsic or event dynamically in rust? (I want to be able to decode across all parachains) A lot of the heavy lifting seems to be frame-metadata and scale-info. There's a desub ...
Squirrel's user avatar
  • 3,759
2 votes
1 answer
44 views

How can we use struct instead of tuple in pallet storage?

I am working on a pallet in which there is storage in which I am using a tuple. Can we use a struct instead of a tuple in the storage of pallet? if yes is there any reference to how we can use it?
Pankaj's user avatar
  • 1,896
6 votes
1 answer
119 views

How does `#[codec(mel_bound())]` work?

When declaring types, with generic parameters, to be stored in runtime storage, it’s common to see this pattern #[derive(Encode, Decode, MaxEncodedLen, TypeInfo)] pub struct MyItem<TypeA, TypeB> ...
Angelo's user avatar
  • 501
12 votes
1 answer
271 views

PolkadotJS how to properly setup api for custom RPC invocation

I'm playing around with custom RPC endpoints exposed from my substrate node, but I'm encountering an issue when trying to call it with polkadotjs. Initially, my endpoint only accepted a single ...
Tony's user avatar
  • 527
6 votes
2 answers
227 views

What is the role of `#[scale_info(skip_type_params(T))]`?

#[derive(Encode,Decode,TypeInfo) #[scale_info(skip_type_params(T))] Pub struct Asset<T:Config> { Id:### Name:## } So in the above example if you don't include the second macro. The compiler ...
Mrisho Lukamba's user avatar
7 votes
1 answer
57 views

Backward compatible changes in the runtime

If I add a new field to a struct that is not stored in storage but used as a parameter to an extrinsic, will it break decoding if a node with the changed runtime is syncing (i.e. executing older ...
Nahu's user avatar
  • 337
7 votes
2 answers
72 views

Reason for yanked `parity-scale-codec` versions 3.0-3.1.1?

I noticed that the parity-scale-codec versions 3.0.0, 3.1.0 and 3.1.1 have been yanked: https://crates.io/crates/parity-scale-codec/versions. The changelog of the crate doesn't contain any information ...
cmichi's user avatar
  • 2,755
10 votes
2 answers
563 views

What are the Steps for Encoding an Extrinsic in Substrate?

Substrate introduces some unique concepts such as unsigned transactions and signed extensions. What are the steps for encoding an extrinsic in Substrate? What are the specific details that relate to ...
Dan Forbes's user avatar
1 vote
1 answer
111 views

How to solve 'Invalid transaction version'?

use std::any::Any; use std::io; use subxt::*; use subxt::{ClientBuilder,DefaultConfig, DefaultExtra}; use subxt::codec::Decode; use crate::sp_runtime::OpaqueExtrinsic; use sp_runtime::{ generic::{ ...
PaperFrog's user avatar
  • 495
5 votes
1 answer
129 views

What is the difference between Metadata and FRAME-Metadata?

What is the difference between Metadata and Metadata Type Definitions in Substrate? Also, when I do the state_getMetadata RPC call I get the metadata. It is rather long. Is there a way to cache this ...
PaperFrog's user avatar
  • 495
15 votes
3 answers
588 views

Why do I need to use SCALE codec?

SCALE codec is used to encode and decode data for Substrate runtimes. Why is it the top choice in Substrate and can I implement my own SCALE library?
Sacha Lansky's user avatar
  • 2,610