Links

Creating new accounts

New accounts can be created using account new. This generates a new key pair and adds them to the keystore directory in the datadir. To create a new account in the default data directory:
$ geth account newl
This returns the following to the terminal:
Your new account is locked with a password. Please give a password. Do not forget this password.
Passphrase:
Repeat Passphrase:
Address: {168bc315a2ee09042d83d7c5811b533620531f67}
It is critical to backup the account password safely and securely as it cannot be retrieved or reset.
Note: If the password provided on account creation is lost or forgotten, there is no way to retrive it and the account will simply stay locked forever. The password MUST be backed up safely and securely! IT IS CRITICAL TO BACKUP THE KEYSTORE AND REMEMBER PASSWORDS
The newly generated key files can be viewed in <datadir>/keystore/. The file naming format is UTC--<date>--<address> where date is the date and time of key creation formatted according to UTC 8601 with zero time offset and seconds precise to eight decimal places. address is the 40 hexadecimal characters that make up the account address without a leading 0x, for example:
UTC--2022-05-19T12-34-36.47413510Z--0b85e5a13e118466159b1e1b6a4234e5f9f784bb

Listing Accounts

Listing all existing accounts is achieved using the account list command. If the keystore is located anywhere other than the default location its path should be included with the keystore flag. For example, if the datadir is some-dir:
geth account list --keystore some-dir/keystore
This command returns the following to the terminal for a keystore with two files:
Account 0: {5afdd78bdacb56ab1dad28741ea2a0e47fe41331} keystore:///tmp/mykeystore/UTC--2017-04-28T08-46-27.437847599Z--5afdd78bdacb56ab1dad28741ea2a0e47fe41331
Account 1: {9acb9ff906641a434803efb474c96a837756287f} keystore:///tmp/mykeystore/UTC--2017-04-28T08-46-52.180688336Z--9acb9ff906641a434803efb474c96a837756287f
The ordering of accounts when they are listed is lexicographic, but is effectively chronological based on time of creation due to the timestamp in the file name. It is safe to transfer the entire keystore directory or individual key files between Ethereum nodes. This is important because when accounts are added from other nodes the order of accounts in the keystore may change. It is therefore important not to rely on account indexes in scripts or code snippets.