Setting up an account

Prerequisites

Install Starkli

Ensure that the below command is working properly on your system:

starkli  --version

If the above commands fail, please check Setting up your environment.

Set the required environment variables

In order to create an account you will need to ensure that a Signer has been created and the appropriate environment variable has been set. Follow these instructions for more information.

Complete your smart wallet set up

Ensure that you have completed the steps outlined in the previous section, Setting up a smart wallet.

Starkli sends out transactions through accounts. Starknet natively supports account abstraction and all accounts are smart contracts. Therefore, there are many "flavors" of accounts. Starkli refers to these "flavors" as variants. Currently, the only supported variant is OpenZeppelin’s account contract implementation.

Accounts can be created and managed through the starkli account command. Variant-specific commands are available under starkli account <VARIANT>.

Creating an account

For account creation see the Creating an Account Descriptor section within "Setting up a smart wallet".

Deploying an account

Once you have an account file, you can deploy the account contract with the starkli account deploy command.

This command sends a DEPLOY_ACCOUNT transaction, which requires the account to be funded with some ETH for paying for the transaction fee. For more information on funding your wallet see here.

To deploy your account, run the following command:

starkli account deploy ~/.starkli-wallets/deployer/account.json

This command requires a signer. If you receive an error after running this command, ensure you have the STARKNET_KEYSTORE environment variable set as per these instructions.

When run, the command shows:

  • The address where the contract will be deployed.

  • Instructions for the user to fund the account before proceeding.

Here’s an example command output:

The estimated account deployment fee is 0.000011483579723913 ETH. However, to avoid failure, fund at least:
    0.000017225369585869 ETH
to the following address:
    0x01cf4d57ba01109f018dec3ea079a38fc08b789e03de4df937ddb9e8a0ff853a
Press [ENTER] once youve funded the address.

You have now successfully deployed a new account to Starknet.

Fetching an account

Account fetching allows you to recreate the account file from onchain data alone.

This could be helpful when:

  • The account file is lost; or

  • Migrating an account from another tool/application.

The starkli account fetch command creates an account file using just the address provided:

starkli account fetch <ADDRESS> --output ~/.starkli-wallets/deployer/account.json

Running the command above creates the account file at ~/.starkli-wallets/deployer/account.json.