Crates.io | sub-script |
lib.rs | sub-script |
version | 0.8.0 |
source | src |
created_at | 2022-05-20 14:34:11.520184 |
updated_at | 2022-05-23 13:21:50.940107 |
description | Scripting tool for Substrate chains |
homepage | https://github.com/PolymeshAssociation/sub-script |
repository | https://github.com/PolymeshAssociation/sub-script |
max_upload_size | |
id | 590315 |
size | 292,180 |
A simple scripting interface for Substrate nodes. It uses Rhai for the scripting engine.
USER.<UserName>
.schema.json
file. No recompile needed.// Use Alice for mocking cdd.
let alice = USER.Alice;
// Generate a test user. Key generated from "//Test123" seed.
let user = USER.Test123;
// Mock Cdd for user and make sure they have some POLYX.
let res = alice.submit(TestUtils.mock_cdd_register_did(user));
if res.is_success {
// New account send them some POLYX.
alice.submit(Balances.transfer(user, 5.0));
}
// Generate another test user. Key generated from "//Key1" seed.
let key = USER.Key1; // Don't mock cdd for this user.
// Add JoinIdentity authorization for `key` to join `user`.
let res = user.submit(Identity.add_authorization(#{
Account: key
}, #{
JoinIdentity: #{
asset: #{ These: ["ACME"] },
extrinsic: #{ Whole: () },
portfolio: #{ Whole: () },
}
}, ()));
if res.is_success {
// call successful.
} else {
// call failed.
print(`failed: ${res.result}`);
}
// Process all events emitted by the call.
for event in res.events {
print(`EventName: ${event.name}`);
print(` Args: ${event.args}`);
}
// Process events matching prefix 'Identity.Auth'.
for event in res.events("Identity.Auth") {
print(`EventName: ${event.name}`);
print(` Args: ${event.args}`);
}
See other examples scripts in ./scripts/
folder.