Create an Account with the Flow CLI

How to create a Flow account from the command line

The Flow CLI provides a command to submit an account creation transaction to any Flow Access API. There are two options how to create an account, you can use the interactive mode which guides you through the process and creates the account for you or by using the manual process which requires a pre-existing account on the network you chose.

Interactive Mode

Creating the account in interactive mode prompts you for an account name and network selection. After you enter the required information the account will be created for you and saved to flow.json. If account creation is done on testnet or mainnet the account key will be saved to a separate key file, which will also be put in .gitignore. You can read more about key security here.

πŸ’‘ Please note that the account creation process can take up to a minute so please be patient.

1
flow accounts create
2
3
Enter an account name: mike
4
βœ” Testnet
5
6
πŸŽ‰ New account created with address 0x77e6ae4c8c2f1dd6 and name mike on Testnet network.
7
8
Here’s a summary of all the actions that were taken:
9
- Added the new account to flow.json.
10
- Saved the private key to mike.pkey.
11
- Added mike.pkey to .gitignore.

Manual Mode

Manual mode requires you to have a pre-existing account on the network which you will have to provide as a signer. That account must be added to flow.json for the command to work. You also have to generate a key pair, we suggest using the flow keys generate command, which you can read more about here.

1
# Create an account on Flow Testnet
2
> flow accounts create \
3
--key a69c6986e846ba6d0....1397f5904cd319c3e01e96375d5777f1a47010 \
4
--signer my-testnet-account
5
6
Address 0x01cf0e2f2f715450
7
Balance 10000000
8
Keys 1
9
10
Key 0 Public Key a69c6986e846ba6d0....1397f5904cd319c3e01e96375d5777f1a47010
11
Weight 1000
12
Signature Algorithm ECDSA_P256
13
Hash Algorithm SHA3_256
14
15
Contracts Deployed: 0

In the above example, the flow.json file would look something like this:

1
{
2
"accounts": {
3
"my-testnet-account": {
4
"address": "a2c4941b5f3c7151",
5
"key": "12c5dfde...bb2e542f1af710bd1d40b2"
6
}
7
}
8
}

Flags

Public Key

  • Flag: --key
  • Valid inputs: a hex-encoded public key in raw form.

Specify the public key that will be added to the new account upon creation.

Key Weight

  • Flag: --key-weight
  • Valid inputs: number between 0 and 1000
  • Default: 1000

Specify the weight of the public key being added to the new account.

When opting to use this flag, you must specify a --key-weight flag for each public --key flag provided.

Public Key Signature Algorithm

  • Flag: --sig-algo
  • Valid inputs: "ECDSA_P256", "ECDSA_secp256k1"
  • Default: "ECDSA_P256"

Specify the ECDSA signature algorithm for the provided public key. This option can only be used together with the --key flag.

Flow supports the secp256k1 and P-256 curves.

Public Key Hash Algorithm

  • Flag: --hash-algo
  • Valid inputs: "SHA2_256", "SHA3_256"
  • Default: "SHA3_256"

Specify the hash algorithm that will be paired with the public key upon account creation.

Signer

  • Flag: --signer
  • Valid inputs: the name of an account defined in flow.json.

Specify the name of the account that will be used to sign the transaction and pay the account creation fee.

Contract

  • Flag: --contract
  • Valid inputs: String with format name:filename, where name is name of the contract as it is defined in the contract source code and filename is the filename of the contract source code.

Specify one or more contracts to be deployed during account creation.

Include Fields

  • Flag: --include
  • Valid inputs: contracts

Specify fields to include in the result output. Applies only to the text output.

Host

  • Flag: --host
  • Valid inputs: an IP address or hostname.
  • Default: 127.0.0.1:3569 (Flow Emulator)

Specify the hostname of the Access API that will be used to execute the command. This flag overrides any host defined by the --network flag.

Network Key

  • Flag: --network-key
  • Valid inputs: A valid network public key of the host in hex string format

Specify the network public key of the Access API that will be used to create a secure GRPC client when executing the command.

Network

  • Flag: --network
  • Short Flag: -n
  • Valid inputs: the name of a network defined in the configuration (flow.json)
  • Default: emulator

Specify which network you want the command to use for execution.

Filter

  • Flag: --filter
  • Short Flag: -x
  • Valid inputs: a case-sensitive name of the result property.

Specify any property name from the result you want to return as the only value.

Output

  • Flag: --output
  • Short Flag: -o
  • Valid inputs: json, inline

Specify the format of the command results.

Save

  • Flag: --save
  • Short Flag: -s
  • Valid inputs: a path in the current filesystem.

Specify the filename where you want the result to be saved

Log

  • Flag: --log
  • Short Flag: -l
  • Valid inputs: none, error, debug
  • Default: info

Specify the log level. Control how much output you want to see during command execution.

Configuration

  • Flag: --config-path
  • Short Flag: -f
  • Valid inputs: a path in the current filesystem.
  • Default: flow.json

Specify the path to the flow.json configuration file. You can use the -f flag multiple times to merge several configuration files.

Version Check

  • Flag: --skip-version-check
  • Default: false

Skip version check during start up to speed up process for slow connections.