天道酬勤,学无止境

polkadot-js

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

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 library if we run the tests module, or if we use a std feature flag within our code. Otherwise the

2021-09-24 06:21:43    分类:问答    substrate   polkadot-js   rust-ink

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

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.

2021-09-07 13:30:30    分类:问答    rust   substrate   polkadot   polkadot-js