Anvil Default Accounts
Relevant source files
The following files were used as context for generating this wiki page:
Anvil Default Accounts are the set of pre-configured Ethereum identities used by the walletless provider to facilitate deterministic End-to-End (E2E) testing. These accounts are derived from the standard Anvil mnemonic and serve as the default signing authority for write operations within the virtual EIP-1193 provider.
In the context of this project, these accounts allow developers to simulate wallet interactions without requiring external browser extensions. The provider uses these accounts to sign transactions and messages locally before forwarding the results to an Anvil RPC node.
Sources: src/constants.ts:12-16, README.md:12-25, src/provider.ts:101-115
Account Specifications and Derivation
The project defines 10 default test accounts that are deterministically generated from the default Anvil mnemonic: "test test test test test test test test test test test junk". Each account consists of a public Ethereum address and a corresponding 66-character hex private key.
Default Account List
| Index | Address | Private Key |
|---|---|---|
| 0 | 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 | 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 |
| 1 | 0x70997970C51812dc3A010C7d01b50e0d17dc79C8 | 0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d |
| 2 | 0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC | 0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a |
| 3 | 0x90F79bf6EB2c4f870365E785982E1f101E93b906 | 0x7c852118294e51e653712a81e05800f419141751be58f605c371e15141b007a6 |
| 4 | 0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65 | 0x47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a |
| 5 | 0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc | 0x8b3a350cf5c34c9194ca85829a2df0ec3153be0318b5e2d3348e872092edffba |
| 6 | 0x976EA74026E726554dB657fA54763abd0C3a0aa9 | 0x92db14e403b83dfe3df233f83dfa3a0d7096f21ca9b0d6d6b8d88b2b4ec1564e |
| 7 | 0x14dC79964da2C08b23698B3D3cc7Ca32193d9955 | 0x4bbbf85ce3377467afe5d46f804f221813b2bb87f24d81f60f1fcdbf7cbf4356 |
| 8 | 0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f | 0xdbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97 |
| 9 | 0xa0Ee7A142d267C1f36714E4a8F75612F20a79720 | 0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6 |
Sources: src/constants.ts:17-64
Account Management Logic
The system employs a resolution strategy to transform various input types into a valid viem Account object. This is primarily handled by the resolveAccount function.
Input Types for Account Selection
The SigningAccountInput type allows users to specify an account via:
- Numeric Index: An integer from 0 to 9 referencing
ANVIL_ACCOUNTS. - Address String: A 42-character hex string representing an Ethereum address (must exist in the Anvil default list).
- Hex Private Key: A 66-character hex string used to create a
PrivateKeyAccount. - Account Object: A direct
viemAccount object for custom impersonation.
Sources: src/provider.ts:31-40, src/provider.ts:47-84
Account Resolution Flow
The following diagram illustrates how the provider resolves an input to an active signing account:
The resolveAccount function ensures that only valid, supported accounts are used for cryptographic operations.
Sources: src/provider.ts:47-84
Programmatic Interaction
The E2EProvider exposes specific methods to manipulate the active signing account during runtime, which is critical for testing multi-user scenarios.
Account Control Methods
setSigningAccount(account: SigningAccountInput): Updates the internalwalletClientand emits theaccountsChangedevent.eth_requestAccounts: Returns the current active account and emits aconnectevent if it's the first request.eth_accounts: Returns an array containing the address of the current active account.
Sources: src/provider.ts:494-498, src/provider.ts:384-391, src/provider-controls.ts:80-108
State Synchronization
When a signing account is switched, the provider performs an internal update to ensure consistency across its components:
The internal state synchronization ensures that subsequent eth_sendTransaction or personal_sign calls use the newly selected identity.
Sources: src/provider.ts:477-491, src/provider.ts:494-498, test/provider.spec.ts:503-518
Implementation Details
The default account configuration is centralized in src/constants.ts and utilized by the provider factory in src/provider.ts.
Key Code Structures
// From src/constants.ts
export const DEFAULT_ANVIL_PRIVATE_KEY: Hex =
"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80";
// From src/provider.ts
const initialAccount: PrivateKeyAccount | Account =
typeof accountConfig === "string"
? privateKeyToAccount(accountConfig as Hex)
: accountConfig;
By default, the provider initializes with the first Anvil account (index 0) if no specific account is provided in the E2EProviderConfig.
Sources: src/constants.ts:74-76, src/provider.ts:133-136
Summary
Anvil Default Accounts provide a predictable and robust foundation for local Ethereum development and testing within the walletless ecosystem. By mapping standard Anvil identities to a virtual provider, the system enables complex testing workflows—such as switching between multiple pre-funded accounts—without the overhead of manual wallet management or external dependencies.