# Starknet Wallet API

> The standard route for private dapps on Starknet: ask a privacy-enabled wallet to shield, transfer, and withdraw via starknet.js.

The **Starknet Wallet API** is the recommended route for most **private dapps**.
Instead of managing private state yourself, your dapp asks the user's
privacy-enabled wallet
to perform a private action, and the wallet handles keys, notes, proving, and
submission.

Use this route when you are building an app **on top of** existing privacy
wallets. If you are building the wallet itself, use the
[Build Privacy Wallets](/sdk/getting-started). If your app needs private DeFi,
pair this route with an [Anonymizer Contract](/helpers/privacy-invoke).

> **User recovery matters even when the wallet manages the key.** Ready and
> Xverse users should export a viewing-key backup for every account that holds
> shielded funds. The key reveals private activity if leaked but cannot authorize
> spending. See [Viewing Keys & Backups](/viewing-keys).

## Install

```shell
npm install starknet@^10.8.0
```

**Pin the version.** starknet.js `10.8.0` is the current stable release and
includes Wallet API `0.10.4`, including shadow accounts. The `11.x` line is
published on the npm `next` tag; use it only when your app has completed the
[v10 to v11 migration](https://starknet-js.com/docs/guides/migrate/).

## Why most dapps want this route

- **No viewing keys in your app.** The wallet holds the user's viewing key; your
  dapp never sees it.
- **No note or proof management.** The wallet discovers notes, builds the
  transaction, generates the proof, and submits it.
- **Standard Starknet integration.** You connect and call through `starknet.js`
  and the user's wallet, the same way you already integrate other Starknet
  actions.

## How it fits together

Your dapp talks to `starknet.js`, which reaches the user's privacy-enabled wallet
through the Starknet Wallet API. The wallet runs the STRK20 SDK internally and
settles against the privacy pool. For private DeFi, the same call path also triggers your app-specific
[anonymizer contract](/helpers/privacy-invoke).

## React hooks or direct WalletAccountV6?

There are two practical ways to use the Starknet Wallet API from a dapp, each with
its own page in this section:

- **React dapps:** use the
  [starknet-start `useStrk20` hooks](/starknet-wallet-api/starknet-start-hook), a
  convenience wrapper that calls into a `WalletAccountV6` (or equivalent) under the
  hood.
- **Outside React, or when you need finer control** over connection and proof
  handling: use
  [starknet.js `WalletAccountV6`](/starknet-wallet-api/starknet-js) directly.

In both cases the wallet itself must support the STRK20 wallet API methods, since
the ZK proofs and signatures are managed wallet-side.

## What you can do through the wallet

Without writing any privacy cryptography, a dapp can ask the wallet to:

- **Shield** - deposit public ERC-20 tokens into the pool.
- **Private transfer** - move value privately between registered users.
- **Withdraw (unshield)** - move tokens back out to a public address.
- **Use a shadow account** - act through a persistent per-dapp address that is
  not publicly linked to the user's main wallet.
- **Swap** - where the connected wallet supports it.

Broader DeFi actions (lending, staking, custom flows) pair the Starknet Wallet
API with an app-specific anonymizer contract that the pool invokes atomically —
see [Private DeFi End to End](/starknet-wallet-api/private-defi) for the wiring.
For positions that need a stable pseudonymous caller, use
[Shadow Accounts](/starknet-wallet-api/shadow-accounts) instead.

## What to keep in mind

- **Wallet support varies.** Available actions depend on the connected wallet;
  detect capabilities before offering an action.
- **Make backup guidance discoverable.** Do not ask users to give your dapp their
  viewing key. Link them to the wallet's account-specific export flow instead.
- **Edges stay public.** Deposits and withdrawals expose public ERC-20 legs and
  timing, even though in-pool movement is private.
- **Verify versions and addresses.** Confirm wallet, `starknet.js`, and pool
  contract details for your target network before launch.

## Choose your route

| You are building...                                                                   | Start here                                                                          |
| ------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
| A private dapp anywhere from private DeFi, private consumer apps, private games, etc. | [Anonymizer Contracts](/helpers/privacy-invoke) and Starknet Wallet API (this page) |
| A Starknet privacy wallet                                                             | [Build Privacy Wallets](/sdk/getting-started)                                       |

## Read next

- [starknet-start](/starknet-wallet-api/starknet-start-hook)
- [starknet.js](/starknet-wallet-api/starknet-js)
- [Shadow Accounts](/starknet-wallet-api/shadow-accounts)
- [Anonymizer Contract Anatomy](/helpers/privacy-invoke)
- [Build Privacy Wallets](/sdk/getting-started)
