> For the complete documentation index, see [llms.txt](https://docs.armchain.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.armchain.org/node-operators/fakenet.md). Agents can also search and read this documentation through its [MCP server](https://docs.armchain.org/~gitbook/mcp).

# Fakenet

Fakenet is Armchain's built-in local development network. Think of it as Armchain's equivalent of Hardhat Network or Ganache. It runs a private chain with auto-generated validators, pre-funded accounts, and fast block times, all with a single command.

## Overview

Fakenet provides:

* **Instant setup**: No genesis file, single command to launch
* **Deterministic keys**: Auto-generated validator keys for reproducibility
* **Fast parameters**: 3-second empty block skip, 10-minute epochs
* **Full feature set**: All consensus, EVM, and PQC features active
* **Pre-funded accounts**: Validators start with 1 billion ARM each

## Quick Start

### Single Validator (PoA-like)

Single validator acting as a standalone block producer:

```bash
# Build the client
cd armchain-client
make armnode

# Run single-validator fakenet
./build/armnode --fakenet 1/1 \
  --http \
  --http.addr 0.0.0.0 \
  --http.port 4000 \
  --http.api eth,web3,net,personal,txpool,arm,dag,debug,admin \
  --http.corsdomain "*" \
  --ws \
  --ws.addr 0.0.0.0 \
  --ws.port 4500 \
  --ws.api eth,web3,net,arm \
  --allow-insecure-unlock
```

Your local RPC is now available at `http://localhost:4000`.

### Multi-Validator Network

More realistic test setup with multiple validators:

```bash
# Terminal 1 - Validator 1 of 3
./build/armnode --fakenet 1/3 --port 3001 --http --http.port 4001 --http.api eth,web3,net,personal,admin,arm,dag

# Terminal 2 - Validator 2 of 3
./build/armnode --fakenet 2/3 --port 3002 --http --http.port 4002 --http.api eth,web3,net,personal,admin,arm,dag

# Terminal 3 - Validator 3 of 3
./build/armnode --fakenet 3/3 --port 3003 --http --http.port 4003 --http.api eth,web3,net,personal,admin,arm,dag
```

Then connect the nodes to each other:

```bash
# Get enode URL from validator 1
curl -s http://localhost:4001 -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"admin_nodeInfo","params":[],"id":1}' | jq -r '.result.enode'

# Add peer to validator 2
curl -s http://localhost:4002 -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"admin_addPeer","params":["ENODE_URL"],"id":1}'
```

### Non-Validator Node

To run a non-validator node (sync only) in a fakenet:

```bash
./build/armnode --fakenet 0/3 --port 3000 --http --http.port 4000
```

Use `0` as the validator ID to run as a non-validator.

## Using the Demo Scripts

The `demo/` directory contains convenience scripts for running a multi-node fakenet:

```bash
cd armchain-client/demo

# Start a 3-validator network
./start.sh

# Stop all nodes
./stop.sh

# Clean chain data (reset everything)
./clean.sh
```

### Demo Configuration

The demo scripts use these port assignments:

| Validator   | P2P Port | HTTP RPC Port | WebSocket Port |
| ----------- | -------- | ------------- | -------------- |
| Validator 1 | 3001     | 4001          | 4501           |
| Validator 2 | 3002     | 4002          | 4502           |
| Validator 3 | 3003     | 4003          | 4503           |

## Fakenet Parameters

Fakenet uses relaxed parameters for fast development:

| Parameter            | Fakenet          | Devnet        |
| -------------------- | ---------------- | ------------- |
| Empty Block Skip     | 3 seconds        | 1 minute      |
| Max Epoch Duration   | 10 minutes       | 4 hours       |
| Max Epoch Gas        | 300,000,000      | 1,500,000,000 |
| Gas Power Allocation | 1000× base       | 1× base       |
| Validator Password   | `"fakepassword"` | User-defined  |
| Hard Forks           | London + LLR     | London + LLR  |

## Working with Fakenet Accounts

### Pre-funded Validator Accounts

Each fakenet validator is pre-funded with **1 billion ARM** (1e27 wei). Access them via the console:

```bash
# Attach to the node
./build/armnode --datadir /path/to/datadir attach

# In the console:
> eth.accounts
["0xVALIDATOR_ADDRESS"]

> eth.getBalance(eth.accounts[0])
1e+27

# Unlock account for sending transactions
> personal.unlockAccount(eth.accounts[0], "fakepassword")
true
```

### Creating Test Accounts

```bash
# Via console
> personal.newAccount("testpassword")
"0xNEW_ACCOUNT_ADDRESS"

# Via RPC
curl -X POST http://localhost:4000 \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"personal_newAccount","params":["testpassword"],"id":1}'
```

### Sending Test Transactions

```bash
# Via console
> eth.sendTransaction({
    from: eth.accounts[0],
    to: "0xRECIPIENT",
    value: web3.toWei(100, "ether")
  })

# Via RPC
curl -X POST http://localhost:4000 \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc":"2.0",
    "method":"eth_sendTransaction",
    "params":[{
      "from": "0xVALIDATOR_ADDRESS",
      "to": "0xRECIPIENT",
      "value": "0x56BC75E2D63100000"
    }],
    "id":1
  }'
```

## Deploying Contracts to Fakenet

### With Hardhat

```javascript
// hardhat.config.js
module.exports = {
  solidity: "0.8.24",
  networks: {
    "armchain-local": {
      url: "http://localhost:4000",
      chainId: 55,
      accounts: [process.env.PRIVATE_KEY],
    },
  },
};
```

```bash
npx hardhat run scripts/deploy.js --network armchain-local
```

### With the Armchain Ethers SDK

```typescript
import { JsonRpcProvider, Wallet, parseEther } from "@armchain-ethersv6/ethers";

const provider = new JsonRpcProvider("http://localhost:4000");
const wallet = new Wallet(FAKENET_PRIVATE_KEY, provider);

// Deploy a contract
const factory = new ContractFactory(abi, bytecode, wallet);
const contract = await factory.deploy();
await contract.waitForDeployment();

console.log("Deployed at:", await contract.getAddress());
```

## Resetting Fakenet

To start fresh:

```bash
# Stop the node (Ctrl+C)

# Delete chain data
rm -rf ~/.armnode/  # or your custom --datadir

# Restart
./build/armnode --fakenet 1/1 --http --http.port 4000 ...
```

Or if using the demo scripts:

```bash
cd demo/
./stop.sh
./clean.sh
./start.sh
```

## Common Use Cases

| Use Case               | Configuration                                                                  |
| ---------------------- | ------------------------------------------------------------------------------ |
| Quick contract testing | Single validator: `--fakenet 1/1`                                              |
| Consensus testing      | Multi-validator: `--fakenet 1/3`, `2/3`, `3/3`                                 |
| Frontend development   | Single validator with CORS: `--http.corsdomain "*"`                            |
| API testing            | Enable all APIs: `--http.api eth,web3,net,personal,txpool,arm,dag,debug,admin` |
| Load testing           | Increase gas power, multiple validators                                        |

## Limitations

* **Not for production**: Keys are deterministic and publicly known
* **No persistence guarantees**: Chain data may be lost between restarts if not backed up
* **Network isolation**: Fakenet nodes can only connect to other fakenet nodes with the same validator count
* **No real staking**: Validators are auto-registered with equal stakes

## Further Reading

* [Quickstart](https://docs.armchain.org/get-started/quickstart.md): Deploy contracts to fakenet
* [Network Configuration](https://docs.armchain.org/get-started/network-configuration.md): All network details
