Skip to content

Instantly share code, notes, and snippets.

View brenzi's full-sized avatar

brenzi

View GitHub Profile
@brenzi
brenzi / test_substrate_rpc.py
Created March 24, 2019 09:42
python substrate RPC
import requests
import json
#url = "https://substrate-rpc.parity.io/"
url = "http://127.0.0.1:9944/"
headers = {'content-type': 'application/json'}
payload = {
"method": "chain_getRuntimeVersion",
@brenzi
brenzi / gist:6bd6a430806a85e2edae4b7fd82f9d83
Last active April 2, 2019 21:56
generating and sending an extrinsic using ws
// send a transaction
let nonce = 0;
let tx = Transfer {
amount: 42,
nonce,
from: AccountKeyring::Alice.into(),
to: AccountKeyring::Bob.into(),
};
let signature = AccountKeyring::from_public(&tx.from).unwrap().sign(&tx.encode()).into();
let xt = Extrinsic::Transfer(tx, signature).encode();
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);
@brenzi
brenzi / gist:59b510e5a03dd0dc9053770b918c6e88
Created April 25, 2019 16:07
listening to and decoding substrate events
println!("Got message: {}", msg);
let retstr = msg.as_text().unwrap();
let value: serde_json::Value = serde_json::from_str(retstr).unwrap();
match value["id"].as_str() {
Some(idstr) => { },
_ => {
// subscriptions
println!("no id field found in response. must be subscription");
println!("method: {:?}", value["method"].as_str());
match value["method"].as_str() {
@brenzi
brenzi / gist:936ceab317e350507ae4cb7d6ec4434f
Created May 16, 2019 14:02
raw Externalities HashMap write
pub type SgxExternalities = HashMap<Vec<u8>, Vec<u8>>;
...
let mut ext = SgxExternalities::new();
...
//custom struct
@brenzi
brenzi / examples_keystore.rs
Last active February 6, 2020 21:10
keystore playground
use primitives::crypto::Pair;
use std::path::PathBuf;
use keystore::Store;
use app_crypto::{AppKey, AppPublic, AppPair, ed25519, sr25519};
use primitives::crypto::{Ss58Codec};
fn main() {
2020-02-23 17:44:12.053 tokio-runtime-worker-2 INFO substrate Imported #18954 (0x9763…7d63)
2020-02-23 17:44:12.053 tokio-runtime-worker-10 DEBUG txpool Pool Status: Status { ready: 0, ready_bytes: 0, future: 0, future_bytes: 0 }
2020-02-23 17:44:12.929 tokio-runtime-worker-3 DEBUG txpool [0x4ab1e17a55ae5c6ccbc9e6022a23d511ba0edec74edc87ab65b863ff34176af8] Importing to ready
2020-02-23 17:44:12.929 tokio-runtime-worker-3 DEBUG txpool Pool Status: Status { ready: 1, ready_bytes: 144, future: 0, future_bytes: 0 }
2020-02-23 17:44:13.158 tokio-runtime-worker-8 DEBUG txpool [0x2e29eb5810d1ddbb7c741709ebdb41de7530103ae64acbfe3a8af28ad4451c44] Importing to ready
2020-02-23 17:44:13.158 tokio-runtime-worker-8 DEBUG txpool Pool Status: Status { ready: 2, ready_bytes: 288, future: 0, future_bytes: 0 }
2020-02-23 17:44:13.349 tokio-runtime-worker-10 DEBUG txpool [0x9de73bd4d2d6aacb91fc4be5bc5694df97034fd0530d0c5a822c12a404719e88] Importing to ready
2020-02-23 17:44:13.349 tokio-runtime-worker-10 DEBUG txpool Po
./target/release/substratee-node --dev -lexecutor=trace
2020-04-21 08:08:00.499 main WARN sc_cli::commands::runcmd Running in --dev mode, RPC CORS has been disabled.
2020-04-21 08:08:00.499 main INFO sc_cli::commands::runcmd SubstraTEE Node
2020-04-21 08:08:00.499 main INFO sc_cli::commands::runcmd version 0.6.0-f26ecb9-x86_64-linux-gnu
2020-04-21 08:08:00.499 main INFO sc_cli::commands::runcmd by Supercomputing Systems AG <info@scs.ch>, 2017-2020
2020-04-21 08:08:00.499 main INFO sc_cli::commands::runcmd Chain specification: Development
2020-04-21 08:08:00.499 main INFO sc_cli::commands::runcmd Node name: lying-ghost-7137
2020-04-21 08:08:00.499 main INFO sc_cli::commands::runcmd Roles: AUTHORITY
2020-04-21 08:08:02.340 main INFO sc_client::client Initializing Genesis block/state (state: 0x598b…9d8e, header-hash: 0xe7ef…3b8c)
2020-04-21 08:08:02.340 main INFO afg Loading GRANDPA authority set from genesis on what appears to be first startup.
./target/release/substratee-node purge-chain --dev
Are you sure to remove "/home/abrenzikofer/.local/share/substratee-node/chains/dev/db"? [y/N]: y
"/home/abrenzikofer/.local/share/substratee-node/chains/dev/db" removed.
abrenzikofer@devsgx02:~/substrate-node-template-fork$ clear
abrenzikofer@devsgx02:~/substrate-node-template-fork$ ./target/release/substratee-node --dev -ltrace
2020-04-21 11:14:30.933 main WARN sc_cli::commands::runcmd Running in --dev mode, RPC CORS has been disabled.
2020-04-21 11:14:30.934 main INFO sc_cli::commands::runcmd SubstraTEE Node
2020-04-21 11:14:30.934 main INFO sc_cli::commands::runcmd version 0.6.0-f26ecb9-x86_64-linux-gnu
2020-04-21 11:14:30.934 main INFO sc_cli::commands::runcmd by Supercomputing Systems AG <info@scs.ch>, 2017-2020
@brenzi
brenzi / chain-spec-dev
Last active April 21, 2020 09:47
chain-spec-dev
./target/release/substratee-node build-spec --dev
2020-04-21 11:43:36 Building chain spec
{
"name": "Development",
"id": "dev",
"bootNodes": [
"/ip4/127.0.0.1/tcp/30333/p2p/QmacT1i1phoNpXBQsFccy6ELok1tcuvNga1rakQH6KoSid"
],
"telemetryEndpoints": null,
"protocolId": null,