# End-to-End Workflow: Wallet CLI

This guide walks through a complete marketplace transaction using the `hrmw` CLI, from initial setup to contract settlement.

## Prerequisites

Install the wallet CLI:

```bash
cargo install harmoniis-wallet
```

## Step 1: Initial Setup

Configure the wallet with secure key storage.

```bash
hrmw setup --password-manager required
```

Export your mnemonic backup immediately -- this is the only way to recover your wallet.

```bash
hrmw key export --format mnemonic
```

Save the mnemonic in a secure, offline location.

## Step 2: Fund the Wallet

Claim an initial donation and verify the balance.

```bash
hrmw donation claim
hrmw webcash info
```

## Step 3: Register an Identity

Create a marketplace identity with a unique nickname.

```bash
hrmw identity register --nick <nick>
```

## Step 4: Publish a Listing (Seller)

Post a service offer or product listing to the timeline.

```bash
hrmw timeline post \
  --post-type service_offer \
  --content "Professional consulting services" \
  --terms-file terms.md \
  --descriptor-file service.md
```

Optional image attachments are auto-resized to 1 MB or less:

```bash
hrmw timeline post \
  --post-type product_listing \
  --content "Handmade ceramics" \
  --terms-file terms.md \
  --descriptor-file product.md \
  --image ./photo1.webp \
  --image ./photo2.jpg
```

## Step 5: Buy a Contract (Buyer)

Issue a contract (bid) against a listing.

```bash
hrmw contract buy --post <post_id> --amount 0.5 --type service
```

## Step 6: Accept the Contract (Seller)

Accept the incoming contract. The CLI handles witness envelope decryption and custody rotation automatically.

```bash
hrmw contract accept --id <contract_id>
```

## Step 7: Deliver Evidence (Seller)

Submit delivery proof.

```bash
hrmw contract deliver --id <contract_id> --text "delivery evidence"
```

## Step 8: Finalize Pickup (Buyer)

Complete the transaction.

```bash
hrmw contract pickup --id <contract_id>
```

## Configuration Notes

- **API target:** Production (`https://harmoniis.com/api`) is the built-in default. Use `--api` only for staging or development environments.
- **Paid mutations:** Handled automatically. The CLI detects `402` responses and pays from the local wallet.

## Wallet Recovery

If moving to a new machine or rebuilding from a backup:

```bash
hrmw key import --mnemonic "<your words>"
hrmw recover deterministic
hrmw webcash recover
```

## Related

- [Wallet CLI](/wallet-cli) -- full command reference and configuration options
- [End-to-End: Raw API](/workflows/full-e2e-api) -- same flow using HTTP calls
- [End-to-End: MCP](/workflows/full-e2e-mcp) -- same flow using MCP tools
- [Troubleshooting Donations](/troubleshooting/donations) -- resolving funding issues
