Course06: How to Use Ontology CLI (1)
At 2018-11-15 By zhaoyue

How to Use Ontology CLI (1)

Version 0.1

Click here to view the course video

1. What is Ontology CLI

Ontology CLI is an Ontology node command line client for starting and managing Ontology nodes, managing user wallets, sending transactions, and deploying and invoking smart contracts.

Function list: 1. Start and manage Ontology nodes 2. Wallet management 3. Asset management 4. Query information of the blockchain 5. Smart contract deployment and invocation 6. Block import and export 7. Build, sign, and send a transaction 8. Generate multi-signature address 9. Multi-sign to a transaction 10. Display transaction information

For more detailed information, please refer to Ontology CLI Instruction.

2. Start and manage Ontology nodes

2.1 How to install Ontology

You can download the latest Ontology binary file with

curl https://dev.ont.io/ontology_install | sh

2.2 Parameters

System parameters:

Ontology CLI has a lot of startup parameters for configuring some of the Ontology node's behavior. Use ./Ontology -help to see all startup parameters supported by the Ontology CLI node. If Ontology CLI is started without any parameters, it will access the Ontology main network as a synchronous node by default.

./ontology

--config The config parameter specifies the file path of the genesis block for the current Ontolgy node.

--loglevel The loglevel parameter is used to set the log level the Ontology outputs.

--data-dir The data-dir parameter specifies the storage path of the block data. The default value is "./Chain".

Account parameters:

--wallet, -w The wallet parameter is used to specify the wallet file path when the Ontology node starts. The default value is "./wallet.dat".

--account, -a The account parameter is used to specify the account address when the Ontology node starts. If the account is null, it uses the wallet default account.

--password, -p The password parameter is used to specify the account password when Ontology node starts.

Transaction parameters:

--gasprice The gasprice parameter is used to set the lowest gasprice of the current node transaction pool to accept transactions. Transactions below this gasprice will be discarded. The default value is 500(0 in testmode).

--gaslimit The gaslimit parameter is used to set the gaslimit of the current node transaction pool to accept transactions. Transactions below this gaslimit will be discarded. The default value is 20000.

2.3 Node deployment

MainNet synchronization node deployment:

./ontology

TestNet synchronization node deployment:

./ontology --networkid 2

PrivateNet node (single-node) deployment:

Before initializing a PrivateNet, you need a wallet file - wallet.dat. (wallet.dat can be generated by ./ontology account add -d)

./ontology --testmode

3. Wallet management

Wallet management commands can be used to add, view, modify, delete, and import account. You can use ./Ontology account --help command to view help information of wallet management command.

3.1 Wallet management

Default account: Each wallet has a default account, which is generally the first account added. The default account cannot be deleted, you can modify the default account by ./Ontology account set command.

wallet parameters:

--signature-scheme,s The signature-scheme parameter is used to specify the key signature scheme.

--default The default parameter uses the system's default key scheme.

--label Label is used to set labels for newly created accounts for easy and fast use of accounts.

--wallet The wallet parameter specifies the wallet file path. If the wallet file does not exist, a new wallet file will be automatically created.

--ontid The parameter is used to create ONT ID instead of account.

Add an account

./ontology account add --default

View account info

./ontology account list

Modify account info

./ontology account set

Delete an account

/ontology account del <address|index|label>

Import an account

./ontology account import -s=./source_wallet.dat

4. Asset management

Asset management commands can check account balance, ONT/ONG transfers, extract ONG, and view unbound ONG.

Check Your Account Balance

./Ontology asset balance <address|index|label>

Transfer parameters:

--wallet, -w Wallet specifies the transfer-out account wallet path. The default value is: "./wallet.dat".

--gasprice The gasprice parameter specifies the gas price of the transfer transaction.

--gaslimit The gaslimit parameter specifies the gas limit of the transfer transaction.

--asset The asset parameter specifies the asset type of the transfer. ont indicates the ONT and ong indicates the ONG. The default value is ont.

--from The from parameter specifies the transfer-out account address.

--to The to parameter specifies the transfer-in account address.

--amount The amount parameter specifies the transfer amount.

Transfer asset

./ontology asset transfer --from=<address|index|label> --to=<address|index|label> --amount=XXX --asset=ont

Authorize transfer: A user may authorize others to transfer money from his account, and he can specify the transfer amount when authorizing the transfer.

./Ontology asset approve --from=<address|index|label> --to=<address|index|label> --amount=XXX --asset=ont

Check Authorized Transfer Balance

./ontology asset allowance --from=<address|index|label> --to=<address|index|label>
Please feel free to give any suggestion
Contact: Yue Zhao 
Wechat: 16621171248
Email: messixaviinsta0303@163.com