Skip to content

Commit 09345d9

Browse files
committed
Add account creation docs
1 parent b36dd78 commit 09345d9

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

docs/build/tools/emulator/index.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ keywords:
2525
- local blockchain
2626
- E2E testing
2727
- off-chain mocking
28+
- precreate accounts
29+
- num-accounts
2830
---
2931

3032
The Flow Emulator is a lightweight tool that emulates the behavior of the real Flow network for local development and testing.
@@ -114,6 +116,7 @@ This starts a local Flow network with:
114116
- `--service-sig-algo <ECDSA_P256|ECDSA_secp256k1>`: Service key signature algo (default `ECDSA_P256`)
115117
- `--service-hash-algo <SHA3_256|SHA2_256>`: Service key hash algo (default `SHA3_256`)
116118
- `--min-account-balance <decimal>`: Minimum account balance or account creation cost
119+
- `--num-accounts <int>`: Number of accounts to precreate and fund at startup (default `0`)
117120
- `--contracts`: Deploy common contracts on start
118121
- `--contract-removal`: Allow contract removal for development (default true)
119122
- `--init`: Initialize a new account profile
@@ -125,6 +128,50 @@ This starts a local Flow network with:
125128
- **Snapshots**
126129
- `--snapshot`: Enable snapshots in the emulator
127130

131+
## Precreated Accounts
132+
133+
The Flow Emulator supports precreating and funding multiple accounts automatically when the emulator starts up. This feature streamlines development workflows by eliminating the need to manually create test accounts for each emulator session.
134+
135+
### Usage
136+
137+
Use the `--num-accounts` flag to specify the number of accounts to precreate:
138+
139+
```bash
140+
flow emulator --num-accounts 5
141+
```
142+
143+
Or via environment variable:
144+
145+
```bash
146+
FLOW_NUMACCOUNTS=5 flow emulator
147+
```
148+
149+
### Account Details
150+
151+
**Funding**: Each precreated account is automatically funded with **1000.0 FLOW tokens**. The funding amount is currently fixed and not configurable.
152+
153+
**Keys**: All precreated accounts use the **same public key as the service account**. This simplifies development by allowing you to use the same private key across all accounts. The service account private key (displayed at startup) can be used to sign transactions for any precreated account.
154+
155+
**Account Addresses**: Accounts are created sequentially at emulator startup. Account addresses and the shared private key are displayed in the console when the emulator starts.
156+
157+
### Example Output
158+
159+
When starting the emulator with `--num-accounts 3`:
160+
161+
```
162+
Available Accounts
163+
==================
164+
(0) 0x01cf0e2f2f715450 (1000.0 FLOW)
165+
(1) 0x179b6b1cb6755e31 (1000.0 FLOW)
166+
(2) 0xf3fcd2c1a78f5eee (1000.0 FLOW)
167+
168+
Private Keys
169+
==================
170+
(0) 0x<SERVICE_PRIVATE_KEY>
171+
(1) 0x<SERVICE_PRIVATE_KEY>
172+
(2) 0x<SERVICE_PRIVATE_KEY>
173+
```
174+
128175
## Examples
129176

130177
```bash
@@ -158,6 +205,12 @@ flow emulator --coverage-reporting
158205
# Change the gRPC and REST API ports
159206
flow emulator --port 9000 --rest-port 9001
160207

208+
# Precreate 5 accounts for testing
209+
flow emulator --num-accounts 5
210+
211+
# Precreate accounts with persistence enabled
212+
flow emulator --num-accounts 3 --persist
213+
161214
# For a complete list of available flags, run:
162215
flow emulator --help
163216
```

0 commit comments

Comments
 (0)