Setting up a StarkNet account¶
Follow the installation instructions for the
cairo-lang package in Setting up the environment.
Setting up the network¶
In this tutorial we will use the StarkNet CLI (command line interface) to interact with StarkNet.
In order to instruct the CLI to work with the StarkNet testnet you may either
--network=alpha-goerli flag to every command, or simply set the
environment variable as follows:
Choosing a wallet provider¶
Unlike Ethereum, which distinguishes between Externally Owned Accounts (EOA) and contracts, StarkNet doesn’t have this distinction. Instead, an account is represented by a deployed contract that defines the account’s logic – most notably the signature scheme that controls who can issue transactions from it.
To interact with StarkNet, you will need to deploy an account contract.
In this tutorial, we will use a slightly modified version of OpenZeppelin’s standard
for EOA contract (at the moment, the signature is computed differently).
STARKNET_WALLET environment variable as follows:
Creating an account¶
Run the following command to create an account:
The output should resemble:
Sent deploy account contract transaction. NOTE: This is a modified version of the OpenZeppelin account contract. The signature is computed differently. Contract address: ... Public key: ... Transaction hash: ...
You may also specify a name for your account using
--account=my_account if you want to
maintain multiple accounts. If not specified, the default account (named
__default__) is used.
STARKNET_WALLET environment variable instructs the StarkNet CLI to use your account
starknet invoke and
starknet call commands.
If you want to do a direct call to a contract, without passing through your account contract,
you can pass the
--no_wallet argument to the CLI, which overrides the
Warning: Using the builtin wallet providers that are part of the
not secure (for example, the private key may be kept unencrypted and without backup
in your home directory).
You should only use them if you’re not overly concerned with losing access to your accounts
(for example, for testing purposes).
Transferring Goerli ETH to the account¶
In order to execute transactions on StarkNet, you’ll need to have ETH in your L2 account (for paying transaction fees).
You can acquire L2 ETH in the following ways:
Use the StarkNet Faucet to get small amounts of ETH directly to the account you have just created. This should suffice for simple transactions.
Use the StarkNet L2 bridge (coming soon) to transfer your existing Goerli L1 ETH to and from the L2 account.