polkadot-js

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

Extrinsic failed when invoke HashMap/BTreeMap insert() in ink! contract via Polkadot JS api

风格不统一 提交于 2020-06-28 09:23:28
问题 I got an issue when invoke a contract call from Polkadot JS api. If the function include HashMap insert() or BTreeMap insert() in contract, when call it via api, I'll get: {"ApplyExtrinsic":1} [ An extrinsic failed.] {"index":"0x0001","data":[{"Other":null},{"weight":10000000000,"class":"Normal","paysFee":"Yes"}]} Event won't be triggered correctly. But if I use HashMap/ BTreeMap get() or contains_key(), I can get event data correctly. Here's my contract code in lib.rs: /* Using the standard

Extrinsic failed when invoke HashMap/BTreeMap insert() in ink! contract via Polkadot JS api

妖精的绣舞 提交于 2020-06-28 09:22:34
问题 I got an issue when invoke a contract call from Polkadot JS api. If the function include HashMap insert() or BTreeMap insert() in contract, when call it via api, I'll get: {"ApplyExtrinsic":1} [ An extrinsic failed.] {"index":"0x0001","data":[{"Other":null},{"weight":10000000000,"class":"Normal","paysFee":"Yes"}]} Event won't be triggered correctly. But if I use HashMap/ BTreeMap get() or contains_key(), I can get event data correctly. Here's my contract code in lib.rs: /* Using the standard