Polkadot JS CLI
If you don't want to use the Polkadot JS UI to interact with the Pontem Network, you can use the Polkadot JS Command Line Interface (CLI).
Polkadot JS provides tools for Substrate based blockchains, including a CLI.
  1. 1.
    Make sure you have Node.js installed to use the npm package manager.
  1. 1.
    use npm to install the Polkadot JS CLI:
1
yarn global add @polkadot/api-cli
Copied!
Run help to learn more about the CLI:
1
polkadot-js-api --help
Copied!
To configure endpoint use parameter --ws, e.g.: --ws ws://127.0.0.1:9944, for the Pontem Network testnet use --ws wss://testnet.pontem.network/ws.

Metadata

Because Polkadot CLI works with different Parachains, you have to provide metadata required by the Pontem Parachain node:
  1. 1.
    Create a JSON file titled 'types' where you will put the metadata
1
touch ./types.json
Copied!
  1. 1.
    Put the JSON code below inside the 'types.json' file:
1
{
2
"AuthorId":"[u8;32]",
3
"Balance":"u64",
4
"Bond":{
5
"owner":"AccountId",
6
"amount":"Balance"
7
},
8
"Collator2":{
9
"id":"AccountId",
10
"bond":"Balance",
11
"nominators":"Vec<AccountId>",
12
"top_nominators":"Vec<Bond>",
13
"bottom_nominators":"Vec<Bond>",
14
"total_counted":"Balance",
15
"total_backing":"Balance",
16
"state":"CollatorStatus"
17
},
18
"Candidate":{
19
"bond":"Balance",
20
"fee":"Perbill",
21
"id":"AccountId",
22
"nominators":"Vec<Bond>",
23
"state":"ValidatorStatus",
24
"total":"Balance"
25
},
26
"CollatorSnapshot":{
27
"bond":"Balance",
28
"nominators":"Vec<Bond>",
29
"total":"Balance"
30
},
31
"Estimation":{
32
"gas_used":"u64",
33
"status_code":"u64"
34
},
35
"ExitQ":{
36
"candidate_schedule":"Vec<(AccountId, RoundIndex)>",
37
"candidates":"Vec<AccountId>",
38
"nominator_schedule":"Vec<(AccountId, Option<AccountId>, RoundIndex)>",
39
"nominators_leaving":"Vec<AccountId>"
40
},
41
"InflationInfo":{
42
"annual":"RangePerbill",
43
"expect":"RangeBalance",
44
"round":"RangePerbill"
45
},
46
"MoveStructTag":{
47
"address":"AccountId",
48
"module":"Text",
49
"name":"Text"
50
},
51
"MoveTypeTag":{
52
"Address":"",
53
"Bool":"",
54
"Signer":"",
55
"Struct":"MoveStructTag",
56
"U128":"",
57
"U64":"",
58
"U8":"",
59
"Vector":"MoveTypeTag",
60
"_enum":[
61
"Bool",
62
"U8",
63
"U64",
64
"U128",
65
"Address",
66
"Signer",
67
"Vector",
68
"Struct"
69
]
70
},
71
"Nominator":{
72
"nominations":"Vec<Bond>",
73
"total":"Balance"
74
},
75
"Nominator2":{
76
"nominations":"Vec<Bond>",
77
"revocations":"Vec<AccountId>",
78
"scheduled_revocations_count":"u32",
79
"scheduled_revocations_total":"Balance",
80
"status":"NominatorStatus",
81
"total":"Balance"
82
},
83
"NominatorAdded":{
84
"_enum":{
85
"AddedToBottom":"Null",
86
"AddedToTop":"Balance"
87
}
88
},
89
"OrderedSet":"Vec<Bond>",
90
"ParachainBondConfig":{
91
"account":"AccountId",
92
"percent":"Percent"
93
},
94
"Range":"RangeBalance",
95
"RangeBalance":{
96
"ideal":"Balance",
97
"max":"Balance",
98
"min":"Balance"
99
},
100
"RangePerbill":{
101
"ideal":"Perbill",
102
"max":"Perbill",
103
"min":"Perbill"
104
},
105
"RegistrationInfo":{
106
"account":"AccountId",
107
"deposit":"Balance"
108
},
109
"RoundIndex":"u32",
110
"RoundInfo":{
111
"current":"RoundIndex",
112
"first":"BlockNumber",
113
"length":"u32"
114
},
115
"ValidatorStatus":{
116
"_enum":{
117
"Active":"Null",
118
"Idle":"Null",
119
"Leaving":"RoundIndex"
120
}
121
},
122
"CollatorStatus":{
123
"_enum":{
124
"Active":"Null",
125
"Idle":"Null",
126
"Leaving":"RoundIndex"
127
}
128
},
129
"NominatorStatus":{
130
"_enum":{
131
"Active":"Null",
132
"Leaving":"RoundIndex"
133
}
134
}
135
}
Copied!

Account creation

You can create a new account using The Subkey tool.
To use the Subkey, you'll first need to make sure you have Substrate build dependencies. Use the following commands to install both the dependencies and Subkey:
1
# Use `--fast' to get the dependencies without having to install the Substrate and Subkey binary
2
curl https://getsubstrate.io -sSf | bash -s -- --fast
3
# Install `subkey`, at a specific version
4
cargo install --force subkey --git https://github.com/paritytech/substrate --version 2.0.1 --locked
Copied!
To generate a key use the following command:
1
subkey generate
Copied!
Next, let's query the new account after you create it,:
1
polkadot-js-api query.system.account <address> --ws wss://testnet.pontem.network/ws --types ./types.json
Copied!
Replace <address> with your generated account address ('SS58 Address' in the output from the previous command), e.g. gkQ5K6EnLRgZkwozG8GiBAEnJyM6FxzbSaSmVhKJ2w8FcK7ih.

Transactions

In this documentation we describe how to send the execute script and the publishModule module transactions using CLI.
🧙‍♂️ Read Move VM pallet documentation to learn how to build your first modules and scripts.
For this, you'll need an account with a balance (if you're using a local network use the default accounts), if you're using the Pontem testnet network, create a new account and fund it using our FAUCET.
These next steps require having the Dove tool installed. Therefore, these next steps assume you already compiled your modules/scripts

Module

To deploy a compiled module run the following command:
1
polkadot-js-api tx.mvm.publishModule @<module.mv> <gas> --seed <seed> --types ./types.json --ws <ws-address>
Copied!
Replace parameters:
  • <module.mv> - compiled module file (.mv extension).
  • <gas> - amount of gas.
  • <seed> - account seed. Can be replaced with "//Bob" or "//Alice" in case of local nodes.
  • <ws-address> - node websocket endpoint.
After deploying, you'll see the result of the transaction execution with a JSON output similar to this:
1
{
2
"publishModule": {
3
"dispatchInfo": {
4
"weight": "181,818",
5
"class": "Normal",
6
"paysFee": "Yes"
7
},
8
"events": [
9
{
10
"phase": {
11
"ApplyExtrinsic": "1"
12
},
13
"event": {
14
"method": "ModulePublished",
15
"section": "mvm",
16
"index": "0x0801",
17
"data": [
18
"gkQ5K6EnLRgZkwozG8GiBAEnJyM6FxzbSaSmVhKJ2w8FcK7ih"
19
]
20
},
21
"topics": []
22
},
23
{
24
"phase": {
25
"ApplyExtrinsic": "1"
26
},
27
"event": {
28
"method": "ExtrinsicSuccess",
29
"section": "system",
30
"index": "0x0000",
31
"data": [
32
{
33
"weight": "181,818",
34
"class": "Normal",
35
"paysFee": "Yes"
36
}
37
]
38
},
39
"topics": []
40
}
41
],
42
"status": {
43
"InBlock": "0xc0a26c9676e0f585bb1bde9a812a3f6e238bc41cadbc4204e3acd9b3244d28a6"
44
}
45
}
46
}
Copied!

Script

🧙‍♂️ Use Dove to compile a script with arguments using the tx command. Use this on files with .mvt extension.
To deploy a compiled script transaction, run the following command:
1
polkadot-js-api tx.mvm.execute @<script.mvt> <gas> --seed <seed> --types ./types.json --ws <ws-address>
Copied!
Replace parameters:
  • <script.mvt> - compiled script transaction file (.mvt extension).
  • <gas> - amount of gas.
  • <seed> - account seed. Can be replaced with "//Bob" or "//Alice" in case of local node.
  • <ws-address> - node websocket endpoint.

RPC

See RPC documentation to see how to send requests to RPC.

More

See JS tools documentation and also help:
1
polkadot-js-api --help
Copied!
Last modified 12d ago