Skip to main content

Questions tagged [hash]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
4 votes
2 answers
70 views

Alternative to BlakeTwo256 for WASM Compatibility in a no_std Environment in Rust

I'm developing a Rust script that I need to convert to WebAssembly (WASM). In this script, I'm using the BlakeTwo256 hasher, which is imported from the sp_runtime crate. However, I'm unable to compile ...
Deepak Chaudhary's user avatar
0 votes
0 answers
19 views

How to verify merkle root with batch root and its adjacent_leaves inside a pallet?

I am using below code to create Merkle Root. pub type MmrRootHash = H256; pub fn create_merkle_root(leaves: Vec<MmrRootHash>) -> MmrRootHash { sp_runtime::traits::BlakeTwo256::...
Boleng's user avatar
  • 557
1 vote
1 answer
16 views

how to create merkle root of given hashes inside a pallet

I need to create merkle root of given hashes. pub type MmrRootHash = H256; pub fn create_merkle_root(leaves: Vec<MmrRootHash>) -> MmrRootHash { .. } Is there any library ...
Boleng's user avatar
  • 557
0 votes
0 answers
23 views

Uncaught runtime errors: [u8;16]:: Expected input with 16 bytes (128 bits), found 21 bytes

I created a value id by this: let encoded_payload = (owner.clone(), task_description.clone()).encode(); let id = frame_support::Hashable::blake2_128(&encoded_payload);// hashvalue of combined ...
MinhK's user avatar
  • 125
1 vote
1 answer
141 views

Decode event data

I am learning to use polkadotjs api, I am trying to send a system.remarkWithEvent and then get the event that this created and decode de output to verify that the remark is there. The sending of the ...
Valentin Fernandez's user avatar
3 votes
1 answer
59 views

How I use Database Snapshot Services correct

I want use Database Snapshot Services, because making genesis to last block takes too much time.... so I used POLKACHU site, the code is. " curl -o - -L https://snapshots.polkachu.com/snapshots/...
jay p's user avatar
  • 61
4 votes
1 answer
77 views

Why doesn't Substrate implement a CSPRNG (Cryptographically Secure Pseudorandom Number Generator)?

In the Rust documentation here it says that the hashing function that a Rust HashMap uses is SipHash. It says SipHash can provide resistance to DoS attacks involving hash tables, not that it will, ...
Luke Schoen's user avatar
  • 2,346
3 votes
2 answers
35 views

How to check if a `StorageMap` changed after the last access?

I am currently trying to iterate over a storage map over multiple blocks. For this I need to ensure that the StorageMap was not modified. My plan is to derive a hash from the current StorageMap and ...
Chralt's user avatar
  • 543
4 votes
1 answer
95 views

private key rotation

There's any private key rotation using substrate ? i ask this question regarding a did implementation, step are : hash a data and signe it with an account another account should be able to verify ...
lsroudi's user avatar
  • 65
2 votes
1 answer
61 views

TwoX128 hash for rpc.state.metadata pallet names not being a prefix for storage key

Following this tutorial: https://www.shawntabrizi.com/substrate/querying-substrate-storage-via-rpc/ we should have that a pallet named "Members" should have prefix "...
mr_bovo's user avatar
  • 171
3 votes
1 answer
149 views

Is it expected that sp_core::blake2_256 gives a different result from sp_runtime::traits::BlakeTwo256?

There are (at least) two different functions for calculating a Blake2 256 hash in the Substrate codebase. More surprising is that they give different hashes for the same message. Is this intended? ...
JoshOrndorff's user avatar
  • 1,211
1 vote
1 answer
106 views

Democracy proposal not enacted

First of all I am working on Polkadot-v0.9.29. I am struggling to understand the right way to format a pallet call before submitting it as a proposal to the democracy pallet. Let's the pallet call be ...
Kazunobu Ndong's user avatar
1 vote
1 answer
105 views

H256 to_string() function does not return complete string

I have a H256 value which is an extrinsic returned hash 0x8d19a2e575d583b8812418c71be304f16a978cfac2bfad54afcad824cb4d3471 but when i convert this to String using .to_string() it does not return ...
Rusty Pythonic Script's user avatar
1 vote
1 answer
209 views

How to use keccak256 sha256 in ink smart contracts?

I want to hash string using sha256 and then store it inside of my ink smart contract. I tested this code in Rust and it works out for me: use crypto::sha2::Sha256; use crypto::digest::Digest; let ...
nanoman's user avatar
  • 11
2 votes
2 answers
696 views

Convert a H256 string to H256

I have a hash string "0xf8dd02cc2a3174933fac4e87d7f6360c3cc67167db105b28d0bc434a60674e49". How can i convert back to H256. I used function below but it return difference H256 ...
Huy Duan Tran's user avatar
0 votes
1 answer
165 views

What is the best practice for storing a hash?

I am about to make the decision on how to store some hash value inside the blockchain. A hash value is the best practice to minimise the size of the blockchain, but still allows people to verify ...
Chralt's user avatar
  • 543
2 votes
1 answer
88 views

`sp_core::hash::H256::random()` not found

Trying to generate random 256 bytes hash-like data. But compiler tells error[E0599]: no function or associated item named `random` found for struct `H256` in the current scope --> /home/poh/...
broomrider's user avatar
4 votes
2 answers
389 views

StorageHasher: Blake2 vs Twox

When creating a StorageMap, a hashing algorithm needs to be chosen for the StorageHasher. frame_support provides a few options: Identity Blake2_128 Blake2_128Concat Blake2_256 Twox64Concat Twox128 ...
Bernardo Rodrigues's user avatar
0 votes
1 answer
436 views

What is the best way to find the genesis hash for a chain?

My understanding is the following terms which are used in different contexts and applications all refer to the same thing: "genesis hash", "network key", "chain id". I ...
Alex Sed's user avatar
  • 590
1 vote
1 answer
127 views

ink_env::ecdsa_recover is not returning the right public key

I am having an issue trying to verify ecdsa signature in ink! for my test. I am generating the signature this way const keyring = new Keyring({type: 'ecdsa'}); const pair = keyring.addFromUri('//...
dharjeezy's user avatar
  • 419
4 votes
1 answer
225 views

Can't get transaction hash from signAndSend of Polkadot.js

I'm new and I'm trying to get the transaction hash but I'm only getting undefined. I used this tutorial and this and below is my code. const txHash = await polkadot.tx.balances .transfer('5F1pZe........
ratib90486's user avatar
0 votes
1 answer
53 views

Hash for an authorize-enact runtime upgrade?

Attempting a parachain runtime upgrade using .runtimes.compact.subwasm.parachain_authorize_upgrade_hash and .runtimes.compact.wasm from the [email protected] output. Enacting the runtime upgrade ends ...
user1813's user avatar
  • 103
6 votes
2 answers
696 views

Why could we find the same transaction hash in 3 different blocks?

We found that this transaction 0xf35238b1ef440e2a04576c8264ca8288100091a3d4c71069f0336c72078f366b was included into the following three different blocks : 10219793 10219254 10218427 Could you ...
dominique's user avatar
  • 1,718
2 votes
1 answer
122 views

How to obtain the transaction hash of each transaction

Getblock through RPC method. I can only see the block hash. But I want a hash for each transaction. What should I do?
Andy's user avatar
  • 73
0 votes
1 answer
60 views

Is there anyway to receive a transaction hash from a transaction that was signed by the keyring?

I am creating an application and signing an extrinsic with a keypair using the keyring. I was wondering if I can receive the transaction hash somehow after it has been signed
polkadot76534's user avatar
8 votes
1 answer
237 views

Generating a Storage Key when making an RPC request

I'm trying to make an RPC call to a Substrate node, but I can't generate a proper Storage Key. The Module and Method parts are fine, the problem is the Twox64Concat part. The sp_core::twox_64 of value ...
Amir Boziev's user avatar
6 votes
3 answers
557 views

How to convert Public key (hex) to SS58 Address in JavaScript / Polkadot-JS?

I have a Public key (hex) and would like to convert it to an SS58 Address. What is the right function to use? I found the docs here with an code-sniped: https://substrate-developer-hub.github.io/docs/...
SiAlDev's user avatar
  • 91
6 votes
1 answer
53 views

How to create XOR Hashes in Substrate

Say you have two account ids Aid(A) and Aid(B) and you want to combine them.e.g. XOR( Aid(A), Aid(B) ). Basically, I want to achieve this; T::Hashing::hash_of(&(idA, idB)) == T::Hashing::hash_of(&...
Burak's user avatar
  • 903