> ## Documentation Index
> Fetch the complete documentation index at: https://xavierscript.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Publishing to npm

> Publish the SDK and its sub-packages from the pnpm workspace

The Yanga Wallet monorepo publishes **three packages** to npm using `pnpm publish`. Publishing is always done from the **monorepo root** — never from inside an individual package directory.

## Published Packages

| Package                | Registry name                      | Visibility |
| ---------------------- | ---------------------------------- | ---------- |
| `packages/sdk`         | `agent-economy-wallet`             | Public     |
| `packages/wallet-core` | `@agent-economy-wallet/core`       | Public     |
| `packages/mcp-server`  | `@agent-economy-wallet/mcp-server` | Public     |

The root monorepo and `@agent-economy-wallet/cli` are marked `"private": true` and are **never** published.

***

## Prerequisites

* A free [npmjs.com](https://npmjs.com) account
* An **npm organisation** named `agent-economy-wallet` (required for scoped packages like `@agent-economy-wallet/core`)
* Two-Factor Authentication (2FA) enabled on your npm account

***

## Publishing Steps

<Steps>
  <Step title="Authenticate with npm">
    ```bash theme={null}
    pnpm login
    ```

    Follow the browser prompt. You only need to do this once per machine.
  </Step>

  <Step title="Build the entire workspace">
    From the **monorepo root**, compile all packages in dependency order:

    ```bash theme={null}
    pnpm build
    ```
  </Step>

  <Step title="Run tests">
    ```bash theme={null}
    pnpm test
    ```
  </Step>

  <Step title="Bump versions">
    Edit the `"version"` field inside the `package.json` of each package you changed. All three published packages should stay in sync:

    * `packages/sdk/package.json`
    * `packages/wallet-core/package.json`
    * `packages/mcp-server/package.json`

    Follow [Semantic Versioning](https://semver.org/): `patch` for fixes, `minor` for new features, `major` for breaking changes.
  </Step>

  <Step title="Publish the workspace">
    ```bash theme={null}
    pnpm publish -r --access public --no-git-checks --otp YOUR_2FA_CODE
    ```

    `pnpm publish -r` recursively publishes every non-private package in the workspace. It automatically replaces internal `workspace:*` references with real version numbers in the published bundle — so consumers never see them.

    <Note>
      Get your `--otp` code from your authenticator app (Google Authenticator, Authy, etc.) immediately before running this command — OTP codes expire in 30 seconds.
    </Note>
  </Step>
</Steps>

***

## What Gets Published

The SDK (`agent-economy-wallet`) is a thin re-export layer over `@agent-economy-wallet/core` and `@agent-economy-wallet/mcp-server`. Consumers can use a single import:

```typescript theme={null}
import {
  AgentWallet,
  createCoreServices,
  createX402Paywall,
  discoverRegistry,
  buildRegistrationTx,
  X402Client,
  WELL_KNOWN_TOKENS,
} from "agent-economy-wallet";
```

The full export list is documented in the [SDK Overview](/sdk/overview#full-api-surface).

***

## Checking Published Packages

After publishing, verify the packages appear correctly:

```bash theme={null}
# Check the latest version on the registry
pnpm view agent-economy-wallet version
pnpm view @agent-economy-wallet/core version
pnpm view @agent-economy-wallet/mcp-server version
```
