# How It Works

The wallet integration follows a linear handshake between client, identity provider, and backend:

{% stepper %}
{% step %}

#### Connect

The user triggers authentication via Privy. If the user does not have an existing wallet, Privy provisions an embedded wallet automatically based on the provider configuration.
{% endstep %}

{% step %}

#### Token Issuance

On successful login, Privy issues an identity token on the client. This token is scoped to the authenticated session and contains the user's linked wallet address.
{% endstep %}

{% step %}

#### Request

The client attaches the identity token as a Bearer credential in the `Authorization` header of any API call that requires a verified session.
{% endstep %}

{% step %}

#### Verify

The backend calls `verifyPrivyWallet` from the City SDK, which validates the token signature against Privy's infrastructure using your app credentials, and returns the decoded user object, including wallet address and user ID.
{% endstep %}

{% step %}

#### Associate

The verified wallet identity is now available for use across City-powered product features, including vault deposits, access control checks, KYC-gated flows, or any on-chain interaction that requires a known sender.
{% endstep %}
{% endstepper %}


---

# 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://city-protocol.gitbook.io/docs/neofinance-as-a-service/wallet/how-it-works.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.
