polkadot

How to encode the hex string representation of an account id in Substrate using Rust?

感情迁移 提交于 2021-02-10 18:35:50
问题 Given a hex representation: 0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d , we can get the AccountId it represents using keyring.encodeAddress() using JavaScript. However, what is the corresponding function in Rust? AccountId is the address of the Substrate user's address. For eg, 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY is the account id of Alice, from the Substrate's dev chain. 回答1: Within rust, you should not really start with the hex representation, you want

Use custom types (Substrate FRAME pallet + Polkadot/Substrate frontend)

ⅰ亾dé卋堺 提交于 2021-01-24 08:45:12
问题 Scenario: You are developing a FRAME pallet for a custom Substrate node that uses custom types within Storage or Events. To interact with your custom Substrate node, you use the Polkadot/Substrate frontend Problem: When you query the storage that contains your custom type , the frontend returns "unknown" as the value When you submit an extrinsic to be included in a block that should lead to the emission of an event using the custom type , the Polkadot/Substrate frontend seems to get stuck

How does Polkadot's VRF achieve randomness to shuffle validators?

只谈情不闲聊 提交于 2020-02-06 06:38:45
问题 Contrary to Ethereum which uses RANDAO (possibly enhanced with VDF), in Polkadot, a verifiable random function (VRF) is used to shuffle validators and select potential block proposers for certain slots. Where does the randomness come from, i.e. how does the randomness work specifically? 回答1: A verifiable random function is a function that, in pseudocode, can be expressed like so: (RESULT, PROOF) = VRF(SECRET, INPUT) That is, for some secret and some input (which can be public), the result is