Move Resource Viewer is a tool to query LCS resources data from blockchain nodes storage (i.e. dnode or diem) and represent them in JSON or human readable format.
- The viewer makes a request to the blockchain node by a sending specific query (address + resource type).
- The viewer send another request to node and query resource type layout.
- The viewer restores resources using response data and type layout.
Requirements:
Using cargo:
cargo install --git https://github.com/dfinance/move-tools.git move-resource-viewerjson-schema- adds option to export json schema for output formatdfinance_address- support DFinance node & address formatlibra_address- support Libra/Diem address formatps_address- support Substrate node & ss58 address format
Add shousen features as list to the command line:
cargo install --git https://github.com/dfinance/move-tools.git move-resource-viewer \
--no-default-features \
--features="feature, feature, feature"For example To build Resource Viewer for Polkadot/Substrate use:
--no-default-features --features="ps_address"Query the user's ETH balance:
move-resource-viewer -a wallet1n9w22mvaq7uuswr4j53usd0spd2mznphq3q3zp \
-q "0x1::Account::Balance<0x1::ETH::T>" \
--api="https://rest.testnet.dfinance.co" \
-o=output.json
# optional block number: --height 42
# Optionally add --json-schema schema.json
# or just --json-schema -
# It exports schema for output format to specified file (schema.json)
# In case of `-` as path, it just prints schema to stdout.-a/--accountcan be in Dfinance bech32 or hex0x…{16-20 bytes}encoding formats-q/--queryresource type-path, e.g.:0x1::Account::Balance<0x1::XFI::T>0x1::Account::Balance<0x1::Coins::ETH>- In general:
0xDEADBEEF::Module::Struct< 0xBADBEEF::Mod::Struct<...>, ... > - Inner address can be omitted, it's inherited by parent:
0xDEADBEEF::Module::Struct<Mod::Struct>expands to0xDEADBEEF::Module::Struct<0xDEADBEEF::Mod::Struct> - Query can ends with index
[42]forvec-resources
- Output options:
-o/--outputfs-path to output file-j/--jsonsets output format to json. Can be omitted if output file extension is.json, so then json format will be chosen automatically.--json-schemaadditional json-schema export, fs-path to output schema file.
For more info check out --help.
Additionally if Resource Viewer was built with ps_address feature,
ss58-addresses are acceptable for --account and --query parameters.
Two output formats supported:
- Move-like text
- JSON
The structure of the output in JSON is described in the scheme, which can be obtained by calling with the --json-schema parameter.
resource 00000000::Account::Balance<00000000::Coins::BTC> {
coin: resource 00000000::Dfinance::T<00000000::Coins::BTC> {
value: 1000000000u128
}
}{
"is_resource": true,
"type": {
"address": "0000000000000000000000000000000000000001",
"module": "Account",
"name": "Balance",
"type_params": [
{
"Struct": {
"address": "0000000000000000000000000000000000000001",
"module": "Coins",
"name": "BTC",
"type_params": []
}
}
]
},
"value": [
{
"id": "coin",
"value": {
"Struct": {
"is_resource": true,
"type": {
"address": "0000000000000000000000000000000000000001",
"module": "Dfinance",
"name": "T",
"type_params": [
{
"Struct": {
"address": "0000000000000000000000000000000000000001",
"module": "Coins",
"name": "BTC",
"type_params": []
}
}
]
},
"value": [
{
"id": "value",
"value": {
"U128": 1000000000
}
}
]
}
}
}
]
}