Manage accounts by CLI
The Starcoin node has a built-in decentralized wallet that allows users to manage their accounts through account api and commands.
When the node starts, a default account is automatically created with an empty password. The default account can be changed via account commands. The following commands require a connection to the console, see How working with the Starcoin console.
- Create account
starcoin% account create -p <MY-PASSWORD>
- Show account
starcoin% account show 0xf096a2a61d3042774187a462a5394537
addressis the address of the account.
is_defaultindicates whether the account is the default account. Many commands that require an account address parameter, if user not passed it, the command will use the default account address. If the node has enable the miner client, the default account will also be used for miner client.
is_readonlyindicates whether the account is the read-only account. The private key of the read-only account is not hosted in the node wallet.
public_keyis the public key corresponding to the address of the account.
receipt_identifieris receipt identifier.
auth_keyis the authentication key.
Note that creating an account only creates a pair of keys in the starcoin node, and does not update the state of the chain. So
sequence_numberare still empty at this point. All the above information is public information.
- List account
starcoin% account list
- View or change the default account
To view the default account address:
starcoin% account default
0xf096a2a61d3042774187a462a5394537 to the default address:
starcoin% account default 0xf096a2a61d3042774187a462a5394537
- Export and import account
In order to avoid losing your assets due to disk corruption and other reasons, it is important to backup your private key.
Execute the following command:
starcoin% account export 0xf096a2a61d3042774187a462a5394537 -p <MY-PASSWORD>
To export the private key of
Execute the following command:
starcoin% account import -i <PRIVATE-KEY> -p <MY-PASSWORD> 0xf096a2a61d3042774187a462a5394537
This will import the
0xf096a2a61d3042774187a462a5394537 account. This command can also be used to import the account to a different node and used to do node migration.
- Import read-only account
If you do not want to host the private key in the node wallet, but just want to view the account, or use the account as a mining account, you can import the read-only account with the public key:
starcoin% account import-readonly -i <PUBLIC-KEY>
Then set the account as the default account.
- Remove account
starcoin% account remove 0xf096a2a61d3042774187a462a5394537 -p <MY-PASSWORD>
If it is a read-only account, you do not need to pass the
-p option. Deleting an account only deletes the account from the node wallet and does not affect the account on the chain.
- Lock and unlock account
starcoin% account lock 0xf096a2a61d3042774187a462a5394537
-d can specify the time when the account is kept unlocked, and the default value is 300 seconds.
starcoin% account unlock 0xf096a2a61d3042774187a462a5394537 -p <MY-PASSWORD> -d 300