Introduction to CLI
Introduction to the CLI#
The aelf-command tool is a Command Line Interface (CLI) for interacting with an aelf node. This guide shows you its key features and how to use them.
Features#
Installation#
To install the aelf-command tool globally, use npm:
1npm install aelf-command -g
Using aelf-command#
First Step#
Create a new account or load an existing account using a private key or mnemonic.
Create a New Wallet
1aelf-command create
Example output:
1Your wallet info is:2Mnemonic: great mushroom loan crisp ... door juice embrace3Private Key: e038eea7e151eb451ba2901f7...b08ba5b76d8f2884Public Key: 0478903d96aa2c8c0...6a3e7d810cacd136117ea7b13d2c9337e1ec88288111955b76ea5Address: 2Ue31YTuB5Szy7cnr3SCEGU2gtGi5uMQBYarYUR5oGin1sys6H6✔ Save account info into a file? … no / yes7✔ Enter a password … **8✔ Confirm password … **9✔10Account info has been saved to "/Users/young/.local/share/aelf/keys/2Ue31YTuB5Szy7cnr...Gi5uMQBYarYUR5oGin1sys6H.json"
Load Wallet from Private Key
1aelf-command load e038eea7e151eb451ba2901f7...b08ba5b76d8f288
Example output:
1Your wallet info is:2Private Key: e038eea7e151eb451ba2901f7...b08ba5b76d8f2883Public Key: 0478903d96aa2c8c0...6a3e7d810cacd136117ea7b13d2c9337e1ec88288111955b76ea4Address: 2Ue31YTuB5Szy7cnr3SCEGU2gtGi5uMQBYarYUR5oGin1sys6H5✔ Save account info into a file? … no / yes6✔ Enter a password … **7✔ Confirm password … **8✔9Account info has been saved to "/Users/young/.local/share/aelf/keys/2Ue31YTuB5Szy7cnr...Gi5uMQBYarYUR5oGin1sys6H.json"
Show Wallet Info
1aelf-command wallet -a 2Ue31YTuB5Szy7cnr3SCEGU2gtGi5uMQBYarYUR5oGin1sys6H
Example output:
1Your wallet info is:2Private Key: e038eea7e151eb451ba2901f7...b08ba5b76d8f2883Public Key: 0478903d96aa2c8c0...6a3e7d810cacd136117ea7b13d2c9337e1ec88288111955b76ea4Address: 2Ue31YTuB5Szy7cnr3SCEGU2gtGi5uMQBYarYUR5oGin1sys6H
Examples#
Interactive Console
1aelf-command console -a 2Ue31YTuB5Szy7cnr3SCEGU2gtGi5uMQBYarYUR5oGin1sys6H2✔ Enter the URI of an AElf node: http://127.0.0.1:80003✔ Enter the password you typed when creating a wallet … **4✔ Succeed!5Welcome to aelf interactive console. Ctrl + C to terminate the program. Double tap Tab to list objects67╔═══════════════════════════════════════════════════════════╗8║ ║9║ NAME | DESCRIPTION ║10║ AElf | imported from aelf-sdk ║11║ aelf | the instance of an aelf-sdk, connect to ║12║ | http://127.0.0.1:8000 ║13║ _account | the instance of an AElf wallet, address ║14║ | is ║15║ | 2Ue31YTuB5Szy7cnr3SCEGU2gtGi5uMQBYarYUR… ║16║ | 5oGin1sys6H ║17║ ║18╚═══════════════════════════════════════════════════════════╝
Default Parameters
1aelf-command console2✔ Enter the URI of an AElf node: http://127.0.0.1:80003✔ Enter a valid wallet address, if you don't have, create one by aelf-command create … 2Ue31YTuB5Szy7cnr3SCEGU2gtGi5uMQBYarYUR5oGin1sys6H4✔ Enter the password you typed when creating a wallet … **5✔ Succeed!6Welcome to aelf interactive console. Ctrl + C to terminate the program. Double tap Tab to list objects78╔═══════════════════════════════════════════════════════════╗9║ ║10║ NAME | DESCRIPTION ║11║ AElf | imported from aelf-sdk ║12║ aelf | the instance of an aelf-sdk, connect to ║13║ | http://13.231.179.27:8000 ║14║ _account | the instance of an AElf wallet, address ║15║ | is ║16║ | 2Ue31YTuB5Szy7cnr3SCEGU2gtGi5uMQBYarYUR… ║17║ | 5oGin1sys6H ║18║ ║19╚═══════════════════════════════════════════════════════════╝
Help#
To get help, use:
1aelf-command -h
Output example:
1Usage: aelf-command [command] [options]23Options:4-v, --version output the version number5-e, --endpoint <URI> The URI of an aelf node. Eg: http://127.0.0.1:80006-a, --account <account> The address of aelf wallet7-p, --password <password> The password of encrypted keyStore8-d, --datadir <directory> The directory that contains the aelf related files. Defaults to {home}/.local/share/aelf9-h, --help output usage information1011Commands:12call [contract-address|contract-name] [method] [params] Call a read-only method on a contract.13send [contract-address|contract-name] [method] [params] Execute a method on a contract.14get-blk-height Get the current block height of specified chain15get-chain-status Get the current chain status16get-blk-info [height|block-hash] [include-txs] Get a block info17get-tx-result [tx-id] Get a transaction result18console Open a node REPL19create [options] [save-to-file] Create a new account20wallet Show wallet details which include private key, address, public key and mnemonic21load [private-key|mnemonic] [save-to-file] Load wallet from a private key or mnemonic22proposal [proposal-contract] [organization] [expired-time] Send a proposal to an origination with a specific contract method23deploy [category] [code-path] Deprecated! Please use `aelf-command send` , check details in aelf-command `README.md`24config <flag> [key] [value] Get, set, delete or list aelf-command config25event [tx-id] Deserialize the result returned by executing a transaction26dapp-server [options] Start a dAPP SOCKET.IO server
To get help for a sub-command, such as call, use:
1aelf-command call -h
Output example:
1Usage: aelf-command call [options] [contract-address|contract-name] [method] [params]23Call a read-only method on a contract.45Options:6-h, --help output usage information78Examples:910aelf-command call <contractName|contractAddress> <method> <params>11aelf-command call <contractName|contractAddress> <method>12aelf-command call <contractName|contractAddress>13aelf-command call
For the interactive console:
1aelf-command console -h
Output example:
1Usage: aelf-command console [options]23Open a node REPL45Options:6-h, --help output usage information78Examples:910aelf-command console
Edited on: 16 July 2024 05:03:12 GMT+0