Create an account

How to create and import accounts using aut

Overview

This how to covers the import and generation of new accounts using aut. Accounts are created as Ethereum keystore files using the Web3 Secret Storage Definition, an encrypted file format that provides secure storage for an account’s private key.

Warning

The use of hardware wallets or other key-management tools may be more secure than encrypted files. Operators may choose to make use of such tools with Autonity.

For simplicity this guide will assume the use of password-protected keyfiles on testnet. Ensure that your keystore file is backed up and stored securely according to your security policy at all times; remember the password phrase you used to create it! If you do not remember the password, you will not be able to decrypt this private key file and may lose any funds associated with this account.

Create account using aut

The following command will generate a keyfile with a default generated name, in the keystore (which can be specified with the --keyfile flag, or by adding a keyfile = <path> entry to the .autrc file).

aut account new
Password for new account:
Confirm account password:
0x905824A6924F1564348Dac9709b3113AFb7c8C77  ~/.autonity/keystore/UTC--2023-01-20T09-45-05.360588000Z--905824a6924f1564348dac9709b3113afb7c8c77

A custom keyfile can be specified using the --keyfile flag:

mkdir keystore
aut account new --keyfile ./keystore/alice.key
Password for new account:
Confirm account password:
0x0592486A2491F653484Dac709b91331AF7Cb7c87  keystore/alice.key
Note

To see all options available for account creation, run aut account new --help. See also aut account list for working with key-stores.

Import account using aut

An account can be created from an existing private key using aut:

  1. Create a plain text file that contains the private key in hexadecimal format. For example, copy your private key into a file named alice.priv

  2. Import the key using the import-private-key command:

    aut account import-private-key ./alice.priv
    Password for new account:
    Confirm account password:
    0xd4EdDdE5D1D0d7129a7f9C35Ec55254f43b8E6d4  ~/.autonity/keystore/UTC--2023-01-20T09-45-05.360588000Z--d4eddde5d1d0d7129a7f9c35ec55254f43b8e6d4

The --keyfile and --keystore flags can be used as with aut account new to control the location of the resulting keyfile.

Other aut account commands

aut account command group

Run aut account --help to see all commands:

Command Description
balance Print the current balance of the given account.
import-private-key Read a plaintext private key file (as hex-string), …
info Print information about the given account.
list List accounts in keyfiles or in a Trezor device.
new Create a new key and write it to a keyfile.
reveal-private-key Print the private key from the specified keyfile to …
sign-message Use the private key in the given keyfile to sign …
signtx Sign a transaction using the given keyfile.
verify-signature Verify that the signature in SIGNATURE_FILE is …

If you need help, you can chat to us on Autonity Discord Server!