# Get Started

#### Prerequisites

* **Node.js** 18 or higher
* **npm** or **yarn**
* (Optional) **Solana CLI** for local dev and key management

#### Installation

**Option A: Global install (recommended for CLI use)**

```bash
npm install -g @eternallabs/netauth
```

Then run the CLI from anywhere:

```bash
netauth --help
netauth agent register my-agent
```

**Option B: Local / project install**

```bash
git clone https://github.com/eternal-labs/net-auth.git
cd net-auth
npm install
```

Use the CLI via npm script:

```bash
npm run netauth -- --help
```

#### Configuration

1. Copy the example environment file:

   ```bash
   cp .env.example .env
   ```
2. Edit `.env` with your values:

   | Variable         | Description                                                      | Required                              |
   | ---------------- | ---------------------------------------------------------------- | ------------------------------------- |
   | `SOLANA_RPC_URL` | Solana RPC endpoint (e.g. `https://api.mainnet-beta.solana.com`) | Yes (for live)                        |
   | `NETWORK`        | `mainnet-beta`, `devnet`, or `testnet`                           | No (default: mainnet-beta)            |
   | `ENCRYPTION_KEY` | Secret used to encrypt wallet private keys                       | **Yes** (for wallet creation)         |
   | `PORT`           | HTTP port for the API server                                     | No (default: 3000)                    |
   | `X402_ENDPOINT`  | x402 protocol endpoint                                           | No (optional; fallback used if unset) |
   | `X402_API_KEY`   | API key for x402 service                                         | No (if using x402 endpoint)           |
3. **Important**: Without `ENCRYPTION_KEY`, the server will not start (wallet creation requires it). The CLI can still show help without it.

#### Running the Server

**Development (with watch):**

```bash
npm run dev
```

**Production:**

```bash
npm run build
npm start
```

The API is available at `http://localhost:3000` (or your configured `PORT`). Health check:

```bash
curl http://localhost:3000/health
```

#### Quick Start Flow

1. Start the server (with `ENCRYPTION_KEY` set).
2. Register two agents:

   ```bash
   netauth agent register alice
   netauth agent register bob
   ```
3. Check balance:

   ```bash
   netauth agent balance alice --sol
   ```
4. Send a payment:

   ```bash
   netauth payment send alice bob 0.1 --sol --memo "First payment"
   ```
5. View history:

   ```bash
   netauth payment history alice
   ```

***


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.netauthpay.com/getting-started/get-started.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
