# Wallet CLI

Use it when you need to:

* Spin up wallets on-demand for backends or minting policies.
* Automate tests that require fresh addresses.
* Handle keys and addresses straight from the terminal (no GUI).

{% hint style="danger" %}
**Security Best Practices & Environment**

This tool generates private keys offline. The security of the keys depends **entirely on the environment** where you run the tool.

* **For Production Keys (e.g., Treasury, Policy IDs):** To generate keys that will secure significant value, you **should** use a dedicated, **air-gapped machine** that has never been and will never be connected to the internet. Store the output securely offline.
* **For Development/Testing:** Using your regular development machine is acceptable for temporary wallets that will not hold significant value.
* **NEVER** use a personal or primary wallet's seed phrase with this tool. This avoids exposing your main wallet's keys.
  {% endhint %}

### Features

* **Offline:** No internet needed.
* **Script-Ready:** Single binary, perfect for CI/CD or bash scripts.
* **Configurable:** 12/24 words, with an optional passphrase for mnemonic wallets.
* **Portable:** Use the `--seed` flag to restore an existing wallet, or use a newly generated phrase in other standard wallet apps (Eternl, Lace, etc.).

### Getting Started

You can get the **latest compiled version** from the official releases page:

[**Download Latest Release**](https://github.com/Cardano-Forge/cardano-wallet-cli/releases)

Alternatively, you can build it directly from the source code.

#### Build from Source

Source code requires [Deno](https://deno.land/) to be installed on your system.

```bash
git clone https://github.com/Cardano-Forge/cardano-wallet-cli.git
cd cardano-wallet-cli/
deno compile --allow-read --allow-write --output cardano-wallet src/mod.ts
```

***

### Wallet Types Explained

This tool can generate two fundamental types of wallets, which in turn determine the kinds of addresses you can create.

The type of wallet you generate determines which keys are created and, therefore, which types of addresses you can use.

| Wallet Type                | Keys Generated         | Address Types Available                                                                   | How to Generate                        |
| -------------------------- | ---------------------- | ----------------------------------------------------------------------------------------- | -------------------------------------- |
| **Mnemonic (HD) Wallet**   | Payment & Staking Keys | <p><strong>Base Address</strong> (for staking)<br><strong>Enterprise Address</strong></p> | Use the `--mnemonic` or `--seed` flag. |
| **Single Key-Pair Wallet** | Payment Key Only       | **Enterprise Address** only                                                               | Default behavior (no flags).           |

* **Base Address:** The standard address for users who want to receive funds and participate in staking. It combines both a payment and a staking key.
* **Enterprise Address:** A simpler address that only uses a payment key and does not include staking rights. This makes it ideal for specific use cases:
  * **Exchanges and Custodians:** To hold customer funds without participating in staking, providing transparency.
  * **Smart Contracts & Scripts:** For programmatic wallets that need to hold funds or native tokens but do not require staking capabilities.
  * **Automated Services:** For backend systems that generate addresses for payments or other automated tasks.

### Usage and Examples

#### Command-Line Options

| Flag         | Description                                                   | Required                      | Default |
| ------------ | ------------------------------------------------------------- | ----------------------------- | ------- |
| `--name`     | The base name for the output wallet file (e.g., `my-wallet`). | Yes                           | -       |
| `--mnemonic` | If present, creates a mnemonic (HD) wallet.                   | No                            | -       |
| `--seed`     | A 12 or 24-word mnemonic phrase to restore a wallet.          | No                            | -       |
| `--bits`     | Set mnemonic length. Use `128` for 12 words, `256` for 24.    | No                            | `256`   |
| `--password` | An optional password to secure the mnemonic wallet.           | No (but strongly recommended) | -       |

#### Examples

**1. Create a 24-Word Mnemonic Wallet (Base Address)**

```bash
./cardano-wallet --name=main-wallet --mnemonic
```

**2. Create a 12-Word Mnemonic Wallet (Base Address)**

```bash
./cardano-wallet --name=quick-wallet --mnemonic --bits=128
```

**3. Restore a Wallet from a Mnemonic Phrase (Base Address)**

```bash
./cardano-wallet --name=restored-wallet --seed="your twelve or twenty four word seed phrase goes here"
```

**4. Create a Single Key-Pair Wallet (Enterprise Address)**

This is the default behavior and creates a simple wallet with no staking capabilities.

```bash
./cardano-wallet --name=payment-key
```

### Output Example

The tool generates a JSON file containing all keys and addresses.

```json
{
  "skey": "ed25519e_sk18qn7l5w0pspu2uf6pz5qvn392g23fwpn99vrzjmy6j3fxvjrhdvcm8r44jkvmnv2h5uqx06k5x20gcdlhns0d6xzewfzpgtzk25vxmsw2c3nh",
  "skey_hex": "3827efd1cf0c03c5713a08a8064e25521514b8332958314b64d4a2933243bb598d9c75acaccdcd8abd38033f56a194f461bfbce0f6e8c2cb9220a162b2a8c36e",
  "pkey": "ed25519_pk1l4k5ydd0nlal4vd3zum2e76wx7hpunz5quq7ntqy3z5fnpk9nm3scy6ad0",
  "pkey_hex": "fd6d4235af9ffbfab1b11736acfb4e37ae1e4c540701e9ac0488a89986c59ee3",
  "key_hash": "e9c2caf1072e363420c7a4c84b622284f82a3799d8acf6af0c87ee41",
  "base_address_preview": "addr_test1qr5u9jh3quhrvdpqc7jvsjmzy2z0s23hn8v2ea40pjr7usfqf0xczeqwhr8k0q556shm2xc5s04cyd36448vz8rnrdtsu6u3gq",
  "base_address_preprod": "addr_test1qr5u9jh3quhrvdpqc7jvsjmzy2z0s23hn8v2ea40pjr7usfqf0xczeqwhr8k0q556shm2xc5s04cyd36448vz8rnrdtsu6u3gq",
  "base_address_mainnet": "addr1q85u9jh3quhrvdpqc7jvsjmzy2z0s23hn8v2ea40pjr7usfqf0xczeqwhr8k0q556shm2xc5s04cyd36448vz8rnrdtslvp3yl",
  "enterprise_address_mainnet": "addr1v85u9jh3quhrvdpqc7jvsjmzy2z0s23hn8v2ea40pjr7usgqjrh84",
  "enterprise_address_preview": "addr_test1vr5u9jh3quhrvdpqc7jvsjmzy2z0s23hn8v2ea40pjr7usgm6htgs",
  "enterprise_address_preprod": "addr_test1vr5u9jh3quhrvdpqc7jvsjmzy2z0s23hn8v2ea40pjr7usgm6htgs",
  "reward_address_mainnet": "stake1uysyhnvpvs8t3nm8s22dgta4rv2g86uzxca26nkpr3e3k4cwpgth2",
  "reward_address_preview": "stake_test1uqsyhnvpvs8t3nm8s22dgta4rv2g86uzxca26nkpr3e3k4cftzfnh",
  "reward_address_preprod": "stake_test1uqsyhnvpvs8t3nm8s22dgta4rv2g86uzxca26nkpr3e3k4cftzfnh",
  "mnemonic": "essence taste already amount black shell neutral amused negative chronic mechanic warm famous clerk zero barely random october pipe antenna glue volume silver donor"
}
```

## Disclaimer

The 2 seed phrases used in this document must not be used in your project.

The `mnemonic`, `skey` and `skey_hex` must stay **private at all time**.


---

# 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://dev.ada-anvil.io/developer-tools/wallet-cli.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.
