substrate

How do we use topics in events?

我们两清 提交于 2021-02-11 14:56:31
问题 I am trying to use deposit_event_indexed method when depositing an event with a specific topic so that I can use something like the polkadot.js' api.query.system.eventTopics to fetched indexed events. However, I get the following error 63 | | Self::deposit_event_indexed(&eventHashArray, RawEvent::TestIndexedEvent()); | | ^^^^^^^^^^^^^^^^^^^^^ function or associated item not found in `Module<T>` I am also quite new to rust, so from my understanding, according to the doc, this method is part of

Fast forward time when writing Substrate Runtime Test

拥有回忆 提交于 2021-02-10 18:44:53
问题 I am writing an auction type application with Substrate runtime. In writing test case, how can I fast forward the blockchain time (what's retrieved from <timestamp::Module<T>>::get() ) so I can reach the auction closing time and test the closing logic? Thanks. 回答1: You can just use Timestamp::set_timestamp to change the timestamp to whatever value you want. e.g. Timestamp::set_timestamp(42); You can check the tests for srml-timestamp for examples https://github.com/paritytech/substrate/blob

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

Substrate error - consider giving `accuracy` a type

我的未来我决定 提交于 2021-01-29 10:38:55
问题 I ran into the same error, initially I tried with default nightly-2020-10-05, then nightly-2020-10-01 and nightly-2020-10-06... but nothing is working. Steps followed to downgrade the nightly are : rustup uninstall nightly rustup install nightly- rustup target add wasm32-unknown-unknown --toolchain nightly- WASM_BUILD_TOOLCHAIN=nightly- cargo build --release I have tried on both Windows and Ubuntu 18.04 environment. But every time I get the same error. consider giving accuracy a type 回答1:

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

Possibility of private variables in substrate storage

六月ゝ 毕业季﹏ 提交于 2021-01-05 11:46:42
问题 Is it possible to have private variables stored in substrate storage, specifically in the following forms and access them in private functions? #[derive(Encode, Decode, Default, Clone, PartialEq, Debug)] pub struct MyStruct { id: Hash, // the `id` is public // 1. Can this be a private variable not returned by API / to client? private_var: u64, } decl_storage! { trait Store for Module<T: Trait> as MyModule { // 2. Can this be private storage used only within module function implementation, but

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