Last active
April 6, 2019 21:40
-
-
Save brenzi/9e38ae3f5b3e33da8066b237b579fb95 to your computer and use it in GitHub Desktop.
getStorage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn state_getStorage(&mut self, module: &str, storage_key_name: &str, param: Vec<u8>) { | |
let mut key = module.as_bytes().to_vec(); | |
key.append(&mut vec!(' ' as u8)); | |
key.append(&mut storage_key_name.as_bytes().to_vec()); | |
key.append(&mut param.clone()); | |
println!("will query storage for: {:?}", key); | |
let mut keyhash = hex::encode(twox_128(&key)); | |
keyhash.insert_str(0, "0x"); | |
println!("with storage key: {}", keyhash); | |
let jsonreq = json!({ | |
"method": "state_getStorage", | |
"params": [keyhash], | |
"jsonrpc": "2.0", | |
"id": REQUEST_GET_STORAGE.to_string(), | |
}); | |
println!("sending extrinsic: {}", jsonreq.to_string()); | |
self.out.send(jsonreq.to_string()).unwrap(); | |
} | |
.... | |
let accountid = AccountId::from(AccountKeyring::Alice); | |
self.state_getStorage("System", "AccountNonce", accountid.encode()) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
result: