Creating an account
Overview
In order to create a new account, you need to deploy an account contract.
Instead of manually deploying an account through Protostar, you can consider using a wallet provider. Please note that the Protostar team doesn't verify the safety or compatibility of these wallets.
There are multiple account contracts to choose from, and it is the end user responsibility to find an account that works for them. Some examples of already existing account contracts are OpenZeppelin and ArgentX.
You can read more about accounts in Starknet here.
There are two ways of deploying a new account contract:
- sending
DEPLOY_ACCOUNT
transaction - using already deployed account contract and deploying new one via the Universal Deployer Contract
If you do not have access to any existing account on Starknet, you will most likely have to use the DEPLOY_ACCOUNT
transaction.
Sending DEPLOY_ACCOUNT
transaction
Protostar supports
sending DEPLOY_ACCOUNT
transactions.
Prerequisites
You must know a class_hash
of already declared account contract. It will be used to create an
instance of your account.
Contract used for DEPLOY_ACCOUNT
transaction define __validate_deploy__
entrypoint to support creation
through DEPLOY_ACCOUNT
transaction.
Precalculating the address
First, calculate the address of the account you will be deploying
using protostar calculate-account-address
command.
protostar calculate-account-address \
--account-address-salt .. \ # provide a valid integer for salt
--account-class-hash 0x1234 \
--account-constructor-input 1 2 3 4
Address: 0x1234
Depending on your account contract used, input expected by the constructor will vary.
Prefund the calculated address
Transfer enough funds to the calculated address to cover the cost of DEPLOY_ACCOUNT
transaction.
For Starknet testnet you can use this faucet to obtain testnet ETH. For mainnet, you will have to bridge enough tokens from other networks. See token bridges for more details.
Deploy the account
Once funds has been transferred to the address, run protostar deploy-account
command.
protostar deploy-account \
--account-address-salt .. \ # provide a valid integer for salt
--account-class-hash 0x1234 \
--account-constructor-input 1 2 3 4 \
--network testnet \
--max-fee 10 \ # provide a valid max-fee in WEI
--private-key-path ./.pkey
Transaction hash: 0x060e83c1de4e6ec2cec20239943fd19402f4e23cc88c62afed63f63f6fad4063
Once the transaction gets accepted, your account will be available to use at the address you calculated in previous step using the credentials you provided when sending the transaction.