Watch Resources
THIS TUTORIAL IS OUT OF DATE, WE WILL PUBLISH NEW VERSION ONCE MERGING OF RESOURCE VIEWER INTO DOVE HAPPENS.
move-resource-viewer allows you to watch resources stored inside a blockchain node. First of all, install move-resource-viewer using our documentation.
Compile using dove and deploy Storage module:
1
module Store {
2
resource struct U64 {val: u64}
3
resource struct Address {val: address}
4
resource struct VectorU8 {val: vector<u8>}
5
6
public fun store_u64(account: &signer, val: u64) {
7
let foo = U64 {val: val};
8
move_to<U64>(account, foo);
9
}
10
11
public fun store_address(account: &signer, val: address) {
12
let addr = Address {val: val};
13
move_to<Address>(account, addr);
14
}
15
16
public fun store_vector_u8(account: &signer, val: vector<u8>) {
17
let vec = VectorU8 {val: val};
18
move_to<VectorU8>(account, vec);
19
}
20
}
Copied!
Once the module published, let's store a number using a script:
1
script {
2
use {{sender}}::Store;
3
4
fun store_num(account: &signer, a: u64) {
5
Store::store_u64(account, a);
6
}
7
}
Copied!
Use resource viewer to see stored value:
1
move-resource-viewer -a <address> -q "<address>::Store::U64" --api="ws://127.0.0.1:9944" -o=output.json
2
cat ./output.json
Copied!
Important: replace with your address.
To see resource we need to provide address stored resource and path of resources. In our case path is <address>::Store::U64, because we deployed Store using our address, there is U64 resource inside the module.
You will see something like (if stored value is 10):
1
{
2
"height": "0xc02a5689b6120fa495e6a5606b279c7a4b200f2fb5e4d0edec6969578d81ecef",
3
"result": {
4
"is_resource": true,
5
"type": {
6
"address": [...],
7
"module": "Store",
8
"name": "U64",
9
"type_params": []
10
},
11
"value": [
12
{
13
"id": "val",
14
"value": {
15
"U64": 10
16
}
17
}
18
]
19
}
20
}
Copied!
More easy way to try resource viewer, just to check PONT balance (be sure you have PONT tokens in VM space):
1
move-resource-viewer -a <address> -q "0x1::Account::Balance<0x1::PONT::T>" --api="ws://127.0.0.1:9944" -o=output.json
2
cat ./output.json
Copied!
Last modified 3mo ago
Copy link