Skip to content

Commit

Permalink
feat: adds how to setup keystore
Browse files Browse the repository at this point in the history
  • Loading branch information
uF4No committed May 23, 2024
1 parent 952c2aa commit 9377bd7
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 3 deletions.
20 changes: 19 additions & 1 deletion templates/quickstart/foundry/factory/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,28 @@ $ forge snapshot
$ anvil
```

### Private key setup

It's recommended to use Foundry keystore to store your development account private key.

1. Export your account private key.
2. Create a keystore and import your private key by running:

```shell
cast wallet import myKeystore interactive
# enter your PK when prompted and provide a password
```

> Note that `myKeystore` can be any name.
This will return an address (keystore address), **copy it for later use**.

3. When running `cast` commands that require a private key, use `--account myKeystore --sender <KEYSTORE_ADDRESS>` instead of `--private-key <PRIVATE_KEY>`. This will require you to enter the keystore password you provided before.

### Deploy

```shell
$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key>
$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --account myKeystore --sender <KEYSTORE_ADDRESS>
```

### Cast
Expand Down
20 changes: 19 additions & 1 deletion templates/quickstart/foundry/hello-zksync/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,28 @@ $ forge snapshot
$ anvil
```

### Private key setup

It's recommended to use Foundry keystore to store your development account private key.

1. Export your account private key.
2. Create a keystore and import your private key by running:

```shell
cast wallet import myKeystore interactive
# enter your PK when prompted and provide a password
```

> Note that `myKeystore` can be any name.
This will return an address (keystore address), **copy it for later use**.

3. When running `cast` commands that require a private key, use `--account myKeystore --sender <KEYSTORE_ADDRESS>` instead of `--private-key <PRIVATE_KEY>`. This will require you to enter the keystore password you provided before.

### Deploy

```shell
$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key>
$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --account myKeystore --sender <KEYSTORE_ADDRESS>
```

### Cast
Expand Down
20 changes: 19 additions & 1 deletion templates/quickstart/foundry/testing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,24 @@ $ tree . -d -L 1
└── test
```

### Private key setup

It's recommended to use Foundry keystore to store your development account private key.

1. Export your account private key.
2. Create a keystore and import your private key by running:

```shell
cast wallet import myKeystore interactive
# enter your PK when prompted and provide a password
```

> Note that `myKeystore` can be any name.
This will return an address (keystore address), **copy it for later use**.

3. When running `cast` commands that require a private key, use `--account myKeystore --sender <KEYSTORE_ADDRESS>` instead of `--private-key <PRIVATE_KEY>`. This will require you to enter the keystore password you provided before.

### Compiling contracts

We can build the project with `forge build --zksync`:
Expand All @@ -204,7 +222,7 @@ Compiled Successfully
In case missing libraries are detected during the compilation, we can deploy them using the following command:

```bash
forge create --deploy-missing-libraries --private-key <PRIVATE_KEY> --rpc-url <RPC_URL> --chain <CHAIN_ID> --zksync
forge create --deploy-missing-libraries --account myKeystore --sender <KEYSTORE_ADDRESS> --rpc-url <RPC_URL> --chain <CHAIN_ID> --zksync
```

After deployment is done, the configuration file will be updated and contracts will be automatically compiled again.
Expand Down

0 comments on commit 9377bd7

Please sign in to comment.