Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update account create docs #2517

Merged
merged 36 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
0f1816f
Update command: 'account create'
kkawula Sep 24, 2024
125655c
Update command: 'account create'
kkawula Sep 24, 2024
98a295c
Adjust code blocks
kkawula Sep 24, 2024
39de826
Update up to command: 'account list'
kkawula Sep 25, 2024
60872d8
Update docs
kkawula Sep 25, 2024
6dcc828
Update starkli docs
kkawula Sep 25, 2024
7fe65b5
Change bullets to pargraphs
kkawula Sep 30, 2024
1fda6e8
Adjust code blocks
kkawula Sep 30, 2024
d9d3af2
Removed unnecessary output
kkawula Sep 30, 2024
601301e
Update docs
kkawula Sep 30, 2024
26f5e76
Update link
kkawula Sep 30, 2024
908efbd
Add 'Advanced Use Cases' section
kkawula Sep 30, 2024
b6cf03f
Merge branch 'master' into kkawula/2508-update-account-create-docs
kkawula Sep 30, 2024
76aba5e
Update docs
kkawula Sep 30, 2024
f8e5def
Update docs
kkawula Oct 1, 2024
2c50937
Update docs
kkawula Oct 1, 2024
1c1097b
Update docs
kkawula Oct 1, 2024
9081c6a
Add uppercases
kkawula Oct 1, 2024
7bdee5d
Change paragraph order
kkawula Oct 1, 2024
45aee71
Merge branch 'master' into kkawula/2508-update-account-create-docs
kkawula Oct 1, 2024
d209f44
Add link in heading
kkawula Oct 8, 2024
03219b8
Restructure paragraphs
kkawula Oct 8, 2024
15db129
Upadate headings
kkawula Oct 8, 2024
2f1b4ea
Restructure paragraphs
kkawula Oct 8, 2024
6c081a9
Update docs
kkawula Oct 8, 2024
4afffc1
Rename paragraph title
kkawula Oct 14, 2024
0b6cd0d
Update 'account list' paragraph
kkawula Oct 14, 2024
eccda98
Update 'account delete' paragraph
kkawula Oct 14, 2024
1b1a99b
Update docs
kkawula Oct 14, 2024
13a85d9
Apply suggestions from code review
kkawula Oct 14, 2024
a1acf63
Merge branch 'master' into kkawula/2508-update-account-create-docs
kkawula Oct 14, 2024
5a3973b
Rename 'account add' to 'account import'
kkawula Oct 14, 2024
28d2e6f
Update docs
kkawula Oct 14, 2024
b9cbe58
Add 'account create' output
kkawula Oct 15, 2024
3c9d438
Revert "Add 'account create' output"
kkawula Oct 15, 2024
83cb705
Update docs
kkawula Oct 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
181 changes: 82 additions & 99 deletions docs/src/starknet/account.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,46 +16,46 @@ To remove an account from the accounts file, you can use `sncast account delete

## Examples

### General Example
### Creating an Account

Do the following to start interacting with the Starknet:

- create account with the `sncast account create` command
#### Create account with the `sncast account create` command

```shell
```shell
$ sncast \
account create \
--url http://127.0.0.1:5050 \
--name some-name
account create \
--url http://127.0.0.1:5050 \
--name some-name

Account successfully created. Prefund generated address with at least 432300000000 tokens. It is good to send more in the case of higher demand, max_fee * 2 = 864600000000
command: account create
max_fee: 0x64a7168300
address: 0x7a949e83b243068d0cbedd8d5b8b32fafea66c54de23c40e68b126b5c845b61
add_profile: --add-profile flag was not set. No profile added to snfoundry.toml
address: 0x34ae54182d04754d8043189afd315a808d4bea1a63862b3b05aa78b37756d7b
max_fee: 180527346330500
message: Account successfully created. Prefund generated address with at least <max_fee> STRK tokens or an equivalent amount of ETH tokens. It is good to send more in the case of higher demand.

To see account creation details, visit:
account: https://starkscan.co/tx/0x7a949e83b2...
account: https://starkscan.co/search/contract/34ae54182d04754d8043189afd315a808d4bea1a63862b3b05aa78b37756d7b
```

You can also pass common `--accounts-file` argument with a path to (existing or not existing) file where you want to save account info.
For a detailed CLI description, see [account create command reference](../appendix/sncast/account/create.md).

For a detailed CLI description, see [account create command reference](../appendix/sncast/account/create.md).
See more advanced use cases below or jump directly to the section [here](#advanced-use-cases).

#### Prefund generated address with tokens

- prefund generated address with tokens

To deploy an account in the next step, you need to prefund it with either STRK or ETH tokens (read more about them [here](https://docs.starknet.io/architecture-and-concepts/economics-of-starknet/)).
You can do it both by sending tokens from another starknet account or by bridging them with [StarkGate](https://starkgate.starknet.io/).
To deploy an account in the next step, you need to prefund it with either STRK or an equivalent amount of ETH tokens (read more about them [here](https://docs.starknet.io/architecture-and-concepts/economics-of-starknet/)).
You can do it both by sending tokens from another starknet account or by bridging them with [StarkGate](https://starkgate.starknet.io/).

>💡 **Info**
> When deploying on a Sepolia test network, you can also fund your account with artificial tokens via the [Starknet Faucet](https://starknet-faucet.vercel.app)

- deploy account with the `sncast account deploy` command
>![image](images/starknet-faucet-sepolia.png)
kkawula marked this conversation as resolved.
Show resolved Hide resolved
#### Deploy account with the `sncast account deploy` command

```shell
$ sncast \
account deploy
--url http://127.0.0.1:5050 \
account deploy \
--url http://127.0.0.1:5050 \
--name some-name \
--fee-token strk \
--max-fee 9999999999999
Expand All @@ -64,62 +64,40 @@ command: account deploy
transaction_hash: 0x20b20896ce63371ef015d66b4dd89bf18c5510a840b4a85a43a983caa6e2579

To see invocation details, visit:
transaction: https://starkscan.co/tx/0x20b20896ce...
```

Note that you don't have to pass `url`, `accounts-file` and `network` parameters if `add-profile` flag
was set in the `account create` command. Just pass `profile` argument with the account name.
transaction: https://starkscan.co/search/0x20b20896ce...
```

For a detailed CLI description, see [account deploy command reference](../appendix/sncast/account/deploy.md).
For a detailed CLI description, see [account deploy command reference](../appendix/sncast/account/deploy.md).

> 💡 **Info**
> You can also choose to pay in Ether by setting `--fee-token` to `eth`.

### `account create` With Salt Argument
## Managing Accounts

Salt will not be randomly generated if it's specified with `--salt`.
If you created an account with `sncast account create` it by default it will be saved in `~/.starknet_accounts/starknet_open_zeppelin_accounts.json` file which we call `default accounts file` in the following sections.

```shell
$ sncast \
account create \
--name some-name \
--salt 0x1

Account successfully created. Prefund generated address with at least 432300000000 tokens. It is good to send more in the case of higher demand, max_fee * 2 = 864600000000
command: account create
max_fee: 0x64a7168300
address: 0x7a949e83b243068d0cbedd8d5b8b32fafea66c54de23c40e68b126b5c845b61

To see account creation details, visit:
account: https://starkscan.co/tx/0x7ad0d6e449...
```

### `account delete`

Delete an account from `accounts-file` and its associated Scarb profile.
### [`account import`](../appendix/sncast/account/import.md)

To import an account to the `default accounts file`, use the `account import` command.
```shell
$ sncast \
--accounts-file my-account-file.json \
account delete \
--name some-name \
--network alpha-sepolia

Do you want to remove account some-name from network alpha-sepolia? (Y/n)
Y
command: account delete
result: Account successfully removed
account import \
--url http://127.0.0.1:5050 \
--name my_imported_account \
--address 0x3a0bcb72428d8056cc7c2bbe5168ddfc844db2737dda3b4c67ff057691177e1 \
--private-key 0x2 \
--type oz
```

For a detailed CLI description, see [account delete command reference](../appendix/sncast/account/delete.md).

### `account list`

### [`account list`](../appendix/sncast/account/list.md)
List all accounts saved in `accounts file`, grouped based on the networks they are defined on.
cptartur marked this conversation as resolved.
Show resolved Hide resolved

```shell
$ sncast --accounts-file my-account-file.json account list
Available accounts (at <current-directory>/my-account-file.json):
$ sncast account list
```

```
Available accounts (at /Users/<username>/.starknet_accounts/starknet_open_zeppelin_accounts.json):
- user0
public key: 0x2f91ed13f8f0f7d39b942c80bfcd3d0967809d99e0cc083606cbe59033d2b39
network: alpha-sepolia
Expand All @@ -130,25 +108,24 @@ legacy: false

- user1
[...]
```

To show private keys too, run with --display-private-keys or -p
You can specify a custom location for the accounts file with the `--accounts-file` or `-f` flag.
There is also possibility to show private keys with the `--display-private-keys` or `-p` flag.

$ sncast --accounts-file my-account-file.json account list --display-private-keys
Available accounts (at <current-directory>/my-account-file.json):
- user0
private key: 0x1e9038bdc68ce1d27d54205256988e85
public key: 0x2f91ed13f8f0f7d39b942c80bfcd3d0967809d99e0cc083606cbe59033d2b39
network: alpha-sepolia
address: 0x4f5f24ceaae64434fa2bc2befd08976b51cf8f6a5d8257f7ec3616f61de263a
type: OpenZeppelin
deployed: false
legacy: false
### [`account delete`](../appendix/sncast/account/delete.md)

- user1
[...]
Delete an account from `accounts-file` and its associated Scarb profile. If you pass this command, you will be asked to confirm the deletion.

```shell
$ sncast account delete \
--name some-name \
--network alpha-sepolia
```

### Custom Account Contract
### Advanced Use Cases

#### Custom Account Contract

By default, `sncast` creates/deploys an account using [OpenZeppelin's account contract class hash](https://starkscan.co/class/0x00e2eb8f5672af4e6a4e8a8f1b44989685e668489b0a25437733756c5a34a1d6).
It is possible to create an account using custom openzeppelin, argent or braavos contract declared to starknet. This can be achieved
Expand All @@ -158,29 +135,37 @@ with `--class-hash` flag:
$ sncast \
account create \
--name some-name \
--url http://127.0.0.1:5050 \
--class-hash 0x00e2eb8f5672af4e6a4e8a8f1b44989685e668489b0a25437733756c5a34a1d6
```

Account successfully created. Prefund generated address with at least 432300000000 tokens. It is good to send more in the case of higher demand, max_fee * 2 = 864600000000
command: account create
max_fee: 0x64a7168300
address: 0x7a949e83b243068d0cbedd8d5b8b32fafea66c54de23c40e68b126b5c845b61
#### [`account create`](../appendix/sncast/account/create.md) With Salt Argument

To see account creation details, visit:
account: https://starkscan.co/tx/0x7a949e83b2...
Instead of random generation, salt can be specified with `--salt`.

```shell
$ sncast \
account deploy \
--name some-name \
--max-fee 864600000000
account create \
--url http://127.0.0.1:5050 \
--name some-name \
--salt 0x1
```

command: account deploy
transaction_hash: 0x20b20896ce63371ef015d66b4dd89bf18c5510a840b4a85a43a983caa6e2579
#### Additional features provided with `account import/create`

To see invocaton details, visit:
transaction: https://starkscan.co/tx/0x20b20896ce...
```
##### Specifying [`--accounts-file`](../appendix/sncast/account/create.md#create)

### Using Keystore and Starkli Account
Account information such as `private_key`, `class_hash`, `address` etc. will be saved to the file specified by `--accounts-file` argument,
if not provided, the `default accounts file` will be used.


##### Specifying [`--add-profile`](../appendix/sncast/account/create.md#--add-profile-name)

When the `--add-profile` flag is used, you won't need to include the `--url` or `--accounts-file` parameters
(the latter being necessary if your account information was stored in a custom file).
Simply use the `--profile` argument followed by the account name in subsequent requests.

#### Using Keystore and Starkli Account

Accounts created and deployed with [starkli](https://book.starkli.rs/accounts#accounts) can be used by specifying the [`--keystore` argument](../appendix/sncast/common.md#--keystore--k-path_to_keystore_file).

Expand All @@ -189,26 +174,24 @@ Accounts created and deployed with [starkli](https://book.starkli.rs/accounts#ac

```shell
$ sncast \
--keystore path/to/keystore.json \
--account path/to/account.json \
--keystore keystore.json \
--account account.json \
declare \
--url http://127.0.0.1:5050 \
--contract-name my_contract
--contract-name my_contract \
--fee-token eth
```

### Creating an Account With Starkli-Style Keystore
#### Creating an Account With Starkli-Style Keystore

It is possible to create an openzeppelin account with keystore in a similar way [starkli](https://book.starkli.rs/accounts#accounts) does.

```shell
$ sncast \
--keystore my_key.json \
--account my_account.json \
account create
--url http://127.0.0.1:5050 \

To see account creation details, visit:
transaction: https://starkscan.co/tx/...
account create \
--url http://127.0.0.1:5050
```

The command above will generate a keystore file containing the private key, as well as an account file containing the openzeppelin account info that can later be used with starkli.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading