<!--
Sitemap:
- [Tempo Accounts SDK - Getting Started](/docs/): Set up the Tempo Accounts SDK to create, manage, and interact with accounts on Tempo.
- [Deploying to Production](/docs/production): Things to consider before deploying your application with the Tempo Accounts SDK to production.
- [FAQ](/docs/faq): Frequently asked questions about the Tempo Accounts SDK.
- [Connect Accounts](/docs/guides/connect-accounts): Connect a Tempo account in your application.
- [Authentication](/docs/guides/authentication): Authenticate connected accounts against your own server with a signed SIWE challenge.
- [Transfers](/docs/guides/transfers): Send stablecoin transfers from a connected Tempo account, initiated either by the user or by your server.
- [Spend Permissions](/docs/guides/spend-permissions): Authorize spend limits, call scopes, and expiries so repeat transfers can be signed without a confirmation prompt.
- [Subscriptions](/docs/guides/subscriptions): Charge recurring payments from a connected Tempo account.
- [Fee Sponsorship](/docs/guides/fee-sponsorship): Sponsor transaction fees from a server-controlled policy.
- [Deposits](/docs/guides/deposits): Open the Tempo deposit flow from a connected account and let the user choose deposit details.
- [Swaps](/docs/guides/swaps): Open the Tempo swap flow from a connected account with optional pre-filled intent fields.
- [Theming](/docs/guides/theming): Match embedded account surfaces to your product.
- [CLI](/docs/guides/cli): Authorize and use Tempo accounts from command-line tools.
- [Adapters](/docs/adapters/): Choose the signing adapter for your Tempo Accounts SDK integration.
- [Tempo Wallet Adapter](/docs/adapters/tempo-wallet): Use Tempo Wallet as the hosted universal wallet adapter.
- [WebAuthn Adapter](/docs/adapters/webauthn): Use domain-bound passkeys as the account signing adapter.
- [Turnkey Adapter](/docs/adapters/turnkey): Use Turnkey-managed wallet accounts as the account signing adapter.
- [Privy Adapter](/docs/adapters/privy): Use Privy embedded wallets as the account signing adapter.
- [Private Key Adapter](/docs/adapters/private-key): Sign in-process with a `secp256k1` private key.
- [Custom Adapter](/docs/adapters/custom): Author your own adapter with the `Adapter.define` API.
- [Adapters](/docs/api/adapters): Pluggable adapters for the Tempo Accounts SDK Provider.
- [dialog](/docs/api/dialog): Adapter for the Tempo Wallet dialog, an embedded iframe or popup for account management.
- [local](/docs/api/local): Key-agnostic adapter for defining arbitrary account types and signing mechanisms.
- [privy](/docs/api/privy): Adapter backed by Privy core SDK sessions and embedded wallets.
- [secp256k1](/docs/api/secp256k1): Adapter that signs in-process with a `secp256k1` private key.
- [turnkey](/docs/api/turnkey): Adapter backed by Turnkey client sessions.
- [webAuthn](/docs/api/webAuthn): Adapter for passkey-based accounts using WebAuthn registration and authentication.
- [Dialog](/docs/api/dialogs): Dialog modes for embedding the Tempo Wallet.
- [Dialog.iframe](/docs/api/dialog.iframe): Embed the Tempo Wallet auth UI in an iframe dialog element.
- [Dialog.popup](/docs/api/dialog.popup): Open the Tempo Wallet auth UI in a popup window.
- [Expiry](/docs/api/expiry): Utility functions for computing access key expiry timestamps.
- [Provider](/docs/api/provider): Create an EIP-1193 provider for managing accounts on Tempo.
- [Rpc](/docs/api/rpc): Per-method Zod schemas and shared building blocks for the Accounts JSON-RPC surface.
- [Schema](/docs/api/schema): Zod-based JSON-RPC schema definitions for the Accounts provider.
- [Storage](/docs/api/storage): Pluggable storage adapters for persisting provider state.
- [Storage.combine](/docs/api/storage.combine): Combine multiple Storage adapters into one.
- [Storage.cookie](/docs/api/storage.cookie): Cookie-backed Storage adapter.
- [Storage.from](/docs/api/storage.from): Create a Storage adapter from a custom implementation.
- [Storage.idb](/docs/api/storage.idb): IndexedDB-backed Storage adapter.
- [Storage.localStorage](/docs/api/storage.localStorage): localStorage-backed Storage adapter.
- [Storage.memory](/docs/api/storage.memory): In-memory Storage adapter.
- [TrustedHosts](/docs/api/trustedHosts): Trusted host mappings and matching helpers for dialog adapters.
- [WebAuthnCeremony](/docs/api/webauthnceremony): Pluggable strategy for WebAuthn registration and authentication ceremonies.
- [WebAuthnCeremony.from](/docs/api/webauthnceremony.from): Create a WebAuthnCeremony from a custom implementation.
- [WebAuthnCeremony.server](/docs/api/webauthnceremony.server): Server-backed WebAuthn ceremony that delegates to a remote handler.
- [CLI](/docs/cli/provider): Create a Provider for CLI environments.
- [eth_accounts](/docs/rpc/eth_accounts): Get the addresses of the currently connected accounts.
- [eth_chainId](/docs/rpc/eth_chainId): Get the chain ID of the currently active chain.
- [eth_fillTransaction](/docs/rpc/eth_fillTransaction): Fills missing transaction fields and returns wallet-aware metadata.
- [eth_requestAccounts](/docs/rpc/eth_requestAccounts): Request access to user accounts, prompting the user to connect if needed.
- [eth_sendTransaction](/docs/rpc/eth_sendTransaction): Send a transaction from the connected account.
- [eth_sendTransactionSync](/docs/rpc/eth_sendTransactionSync): Send a transaction and wait for the receipt.
- [eth_signTransaction](/docs/rpc/eth_signTransaction): Sign a transaction without broadcasting it.
- [eth_signTypedData_v4](/docs/rpc/eth_signTypedData_v4): Sign EIP-712 typed structured data with the connected account.
- [personal_sign](/docs/rpc/personal_sign): Sign a message with the connected account.
- [wallet_authorizeAccessKey](/docs/rpc/wallet_authorizeAccessKey): Authorize an access key for delegated transaction signing.
- [wallet_connect](/docs/rpc/wallet_connect): Connect account(s) with optional capabilities like access key authorization.
- [wallet_deposit](/docs/rpc/wallet_deposit): Open the wallet deposit flow with optional pre-filled fields.
- [wallet_depositZone](/docs/rpc/wallet_depositZone): Open the wallet zone-deposit flow with optional pre-filled fields.
- [wallet_disconnect](/docs/rpc/wallet_disconnect): Disconnect the connected account(s).
- [wallet_getBalances](/docs/rpc/wallet_getBalances): Get token balances for an account.
- [wallet_getCallsStatus](/docs/rpc/wallet_getCallsStatus): Get the status of a batch of calls sent via wallet_sendCalls.
- [wallet_getCapabilities](/docs/rpc/wallet_getCapabilities): Get account capabilities for specified chains.
- [wallet_revokeAccessKey](/docs/rpc/wallet_revokeAccessKey): Revoke a previously authorized access key.
- [wallet_send](/docs/rpc/wallet_send): Open the wallet send-token flow with optional pre-filled fields.
- [wallet_sendCalls](/docs/rpc/wallet_sendCalls): Send a batch of calls from the connected account.
- [wallet_swap](/docs/rpc/wallet_swap): Open the wallet swap flow with optional pre-filled swap intent fields.
- [wallet_switchEthereumChain](/docs/rpc/wallet_switchEthereumChain): Switch the provider's active chain.
- [wallet_withdrawZone](/docs/rpc/wallet_withdrawZone): Open the wallet zone-withdraw flow with optional pre-filled fields.
- [Remote](/docs/api/remote): Bridge that runs inside the wallet's iframe/popup and serves RPC requests from the host SDK.
- [Remote.create](/docs/api/remote.create): Create a remote context bound to a Messenger and Provider.
- [Remote.useEnsureVisibility](/docs/api/remote.useEnsureVisibility): React hook that monitors iframe visibility and falls back to a popup when occluded.
- [Remote.useState](/docs/api/remote.useState): React hook to subscribe to a remote context's state store.
- [Remote.useTheme](/docs/api/remote.useTheme): React hook that applies theme overrides from URL search params and live messenger updates.
- [Remote.validateSearch](/docs/api/remote.validateSearch): Validate an RPC request payload from URL search params.
- [Tempo Accounts Server Handlers](/docs/server/): Configure server-side Tempo Accounts SDK handlers for relaying wallet RPC requests, composing backends, and managing WebAuthn ceremonies.
- [Handler.auth](/docs/server/handler.auth): Server handler that issues SIWE-based authentication challenges and sessions.
- [Handler.codeAuth](/docs/server/handler.codeAuth): Server handler for the device-code (PKCE) access-key bootstrap flow.
- [Handler.compose](/docs/server/handler.compose): Compose multiple server handlers into a single handler.
- [Handler.exchange](/docs/server/handler.exchange): Server handler that returns Stablecoin DEX quotes and ready-to-submit calls.
- [Handler.relay](/docs/server/handler.relay): Server handler that proxies certain RPC requests with wallet-aware enrichment.
- [Handler.webAuthn](/docs/server/handler.webAuthn): Server-side WebAuthn ceremony handler for registration and authentication.
- [hc](/docs/server/hc): Typed RPC client for handlers built with the Tempo Accounts SDK.
- [Kv](/docs/server/kv): Key-value store adapters for server-side persistence.
- [Kv.cloudflare](/docs/server/kv.cloudflare): Kv adapter backed by a Cloudflare Workers KV namespace.
- [Kv.durableObject](/docs/server/kv.durableObject): Kv adapter backed by a Cloudflare Durable Object with atomic take and create.
- [Kv.from](/docs/server/kv.from): Wrap a custom Kv-shaped object so the SDK accepts it as a Kv.
- [Kv.memory](/docs/server/kv.memory): In-memory Kv adapter for tests and single-process deployments.
- [Tempo Accounts SDK](/index): The fastest way to add stablecoins to your application.
- [Secp256k1 Adapter](/docs/adapters/secp256k1): Sign in-process with a `secp256k1` private key.
- [Bring Your Auth](/docs/enterprise/bring-your-auth/): Connect enterprise auth and signing systems to Tempo accounts.
- [Hosted Universal Wallets](/docs/enterprise/hosted-universal-wallets): Stub for hosting a universal wallet on your own domain.
- [Handler.feePayer (Deprecated)](/docs/server/handler.feePayer): Deprecated — use Handler.relay with feePayer option instead.
- [tempoWallet](/docs/wagmi/tempoWallet): Wagmi connector for the Tempo Wallet dialog.
- [webAuthn](/docs/wagmi/webAuthn): Wagmi connector for passkey-based WebAuthn accounts.
- [AWS KMS](/docs/enterprise/bring-your-auth/aws-kms): Stub for integrating AWS KMS-backed signing with the Tempo Accounts SDK.
- [Custom Auth](/docs/enterprise/bring-your-auth/custom): Stub for first-party enterprise auth and signing integrations.
- [Privy](/docs/enterprise/bring-your-auth/privy): Enterprise notes for integrating Privy-backed auth with the Tempo Accounts SDK.
- [Turnkey](/docs/enterprise/bring-your-auth/turnkey): Stub for integrating Turnkey-backed signing with the Tempo Accounts SDK.
-->

# Getting Started

## Overview

The Tempo Accounts SDK is a TypeScript library for applications and wallets to create, manage, and interact with accounts on Tempo.

### Demo

Below is a live example of the Tempo Wallet adapter from the Tempo Accounts SDK — connect a Tempo account and send a payment to see the end-to-end flow.

<Demo title="Make a Payment" githubUrl="https://github.com/tempoxyz/accounts/tree/main/examples/basic" headerAction={<DemoReset />} className="flex flex-col gap-3">
  <Steps.Step label="Create an account, or use an existing one." action={<ConnectAccount />} />

  <SendPayment />
</Demo>

### Quick Prompt

You can integrate the Tempo Accounts SDK, and achieve a flow like the demo above by prompting your agent:

```
Read accounts.tempo.xyz/docs and integrate Tempo accounts into my application
```

### Adapters

The Tempo Accounts SDK ships with several signing adapters. Pick the one that matches how you want to custody your Tempo account.

<Cards>
  <Card description="Universal account hosted on Tempo" icon="lucide:wallet" to="/docs/adapters/tempo-wallet" title="Tempo Wallet" />

  <Card description="Passkey accounts bound to your own origin" icon="lucide:fingerprint" to="/docs/adapters/webauthn" title="WebAuthn (Passkeys)" />

  <Card description="Accounts custodied by Turnkey infrastructure" icon="<svg viewBox=&#x22;-18 -12 50 50&#x22; fill=&#x22;none&#x22; xmlns=&#x22;http://www.w3.org/2000/svg&#x22;><path d=&#x22;m8.023 11.354 6.518 14.253H0l6.518-14.253a.828.828 0 0 1 1.505 0ZM7.27 9.145a4.576 4.576 0 0 0 4.579-4.572A4.576 4.576 0 0 0 7.269 0a4.576 4.576 0 0 0-4.578 4.573A4.576 4.576 0 0 0 7.27 9.145Z&#x22; fill=&#x22;currentColor&#x22;/></svg>" to="/docs/adapters/turnkey" title="Turnkey" />

  <Card description="Accounts backed by Privy auth and embedded wallets" icon="lucide:shield" to="/docs/adapters/privy" title="Privy" />

  <Card description="Direct private key accounts" icon="lucide:key-round" to="/docs/adapters/private-key" title="Private Key" />

  <Card description="Bring your own auth infrastructure" icon="lucide:plug" to="/docs/adapters/custom" title="Custom" />
</Cards>

## Install

The Tempo Accounts SDK is available as an [NPM package](https://www.npmjs.com/package/accounts) under `accounts`

:::code-group

```bash [npm]
npm i accounts
```

```bash [pnpm]
pnpm i accounts
```

```bash [bun]
bun i accounts
```

:::

## Wagmi Usage

The Tempo Accounts SDK is best used in conjunction with [Wagmi](https://wagmi.sh/) to provide a seamless experience for developers and end-users.

::::steps

### Set up Wagmi

Get started with Wagmi by following the [official guide](https://wagmi.sh/react/getting-started).

### Configure

After you have set up Wagmi, you can configure the Tempo Accounts SDK with `tempoWallet` from `wagmi/connectors` or `webAuthn` from `wagmi/tempo`.

:::code-group

```tsx twoslash [Tempo Wallet]
import { createConfig, http } from 'wagmi'
import { tempo } from 'wagmi/chains'
import { tempoWallet } from 'wagmi/connectors' // [!code hl]

export const wagmiConfig = createConfig({
  chains: [tempo],
  connectors: [tempoWallet()], // [!code hl]
  transports: {
    [tempo.id]: http(),
  },
})
```

```tsx twoslash [Domain-bound Passkeys]
import { createConfig, http } from 'wagmi'
import { tempo } from 'wagmi/chains'
import { webAuthn } from 'wagmi/tempo' // [!code hl]

export const wagmiConfig = createConfig({
  chains: [tempo],
  connectors: [webAuthn({ authUrl: '/auth' })], // [!code hl]
  transports: {
    [tempo.id]: http(),
  },
})
```

:::

:::info\[What connector should I use?]
Most apps should use **Tempo Wallet** - it provides a universal account experience with embedded onramp, access keys, and transaction orchestration. **Domain-bound Passkeys** is for apps that want to manage domain-bound passkey accounts directly. [Learn more](/docs/faq#what-connector-should-i-use).
:::

:::tip
If you are using a wallet connection library and cannot supply a custom connector,
you can use `Provider.create()` to create a new provider instance, and inject itself
into the wallet connection library via [EIP-6963](https://eips.ethereum.org/EIPS/eip-6963).

```tsx
import { Provider } from 'accounts'
Provider.create()
```

:::

### Use Accounts

You can now use [Wagmi Hooks](https://wagmi.sh/react/api/hooks) like `useConnect`, or [Tempo Hooks](https://wagmi.sh/tempo) like `useTransfer`.

```tsx twoslash
// @noErrors
import { useConnect, useConnectors } from 'wagmi'

function Connect() {
  const connect = useConnect()
  const connectors = useConnectors()

  return connectors?.map((connector) => (
    <button
      key={connector.uid}
      onClick={() => connect.connect({ connector })}
    >
      Connect
    </button>
  ))
}
```

### Next Steps

<Cards>
  <Card description="Embed Tempo Wallet or domain-bound passkeys into your app" icon="lucide:user-plus" to="/docs/guides/connect-accounts" title="Create & Use Accounts" />

  <Card description="Send stablecoin transfers from a connected account, initiated by the user or by your server" icon="lucide:send" to="/docs/guides/transfers" title="Send Transfers" />

  <Card description="Sponsor account fees from a server-controlled policy" icon="lucide:badge-dollar-sign" to="/docs/guides/fee-sponsorship" title="Sponsor Fees" />

  <Card description="Choose between Tempo Wallet, WebAuthn, Turnkey, Privy, and custom signing infrastructure" icon="lucide:route" to="/docs/adapters" title="Choose an Adapter" />

  <Card description="Hooks to connect wallets, sign transactions, and more" icon="<svg viewBox=&#x22;-80 -80 789 789&#x22; fill=&#x22;none&#x22; xmlns=&#x22;http://www.w3.org/2000/svg&#x22;><path fill-rule=&#x22;evenodd&#x22; clip-rule=&#x22;evenodd&#x22; d=&#x22;M71.788 366.47C71.788 386.294 87.8583 402.364 107.682 402.364H179.47C199.294 402.364 215.364 386.294 215.364 366.47L215.364 222.894C215.364 203.07 231.434 187 251.258 187C271.082 187 287.152 203.07 287.152 222.894V366.47C287.152 386.294 303.222 402.364 323.046 402.364H394.834C414.658 402.364 430.728 386.294 430.728 366.47V222.894C430.728 203.07 446.798 187 466.622 187C486.446 187 502.516 203.07 502.516 222.894V438.258C502.516 458.082 486.446 474.152 466.622 474.152H35.894C16.0703 474.152 0 458.082 0 438.258L1.26782e-05 222.894C1.40786e-05 203.07 16.0703 187 35.894 187C55.7177 187 71.788 203.07 71.788 222.894L71.788 366.47ZM581.142 482.698C607.573 482.698 629 461.271 629 434.84C629 408.408 607.573 386.981 581.142 386.981C554.71 386.981 533.283 408.408 533.283 434.84C533.283 461.271 554.71 482.698 581.142 482.698Z&#x22; fill=&#x22;currentColor&#x22;/></svg>" to="https://wagmi.sh/react/api/hooks" title="Wagmi Hooks" />

  <Card description="Hooks to transfer stablecoins, interact with the stablecoin DEX, and read token data" icon="<svg viewBox=&#x22;0 0 178 178&#x22; fill=&#x22;none&#x22; xmlns=&#x22;http://www.w3.org/2000/svg&#x22;><path d=&#x22;M58.2683 51.1115C58.6089 50.0871 59.567 49.3954 60.6469 49.3954H136.216C137.116 49.3954 137.753 50.2773 137.468 51.1326L129.819 74.0819C129.478 75.1062 128.519 75.798 127.439 75.798H105.18C104.1 75.798 103.142 76.4897 102.801 77.5141L86.3416 126.889C86.001 127.913 85.0429 128.605 83.963 128.605H60.1428C59.2425 128.605 58.606 127.723 58.8912 126.868L75.3344 77.5372C75.6193 76.6819 74.9831 75.7999 74.0829 75.7999H51.8705C50.9702 75.7999 50.3338 74.918 50.6188 74.0626L58.2683 51.1115Z&#x22; fill=&#x22;currentColor&#x22;/></svg>" to="https://wagmi.sh/tempo" title="Tempo Hooks" />
</Cards>

::::

## Vanilla + Viem Usage

You can get started with the Tempo Accounts SDK by creating a new `Provider` instance.
Once set up, you can use the provider to interact with accounts via JSON-RPC, or use [Viem Actions](https://viem.sh/tempo) with `.getClient(){:js}`.

```tsx twoslash
// @noErrors
import { Provider } from 'accounts'
import { parseUnits } from 'viem'
import { tempoActions } from 'viem/tempo'

const provider = Provider.create()

const { accounts } = await provider.request({
  method: 'wallet_connect',
})

const client = provider.getClient().extend(tempoActions())

const { receipt } = await client.token.transferSync({
  token: '0x20c0000000000000000000000000000000000001',
  to: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEbb',
  amount: parseUnits('10', 6),
})
```

## Examples

Check out these examples to get started with the Tempo Accounts SDK.

| Example                                                                                                                | Description                                                                       |                                         |
| ---------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------- |
| [Embed Tempo Wallet](https://github.com/tempoxyz/accounts/tree/main/examples/basic)                                    | Wagmi-based setup using the `tempoWallet` connector to connect to Tempo Wallets.  | [Guide](/docs/guides/connect-accounts)  |
| [Deposits](https://github.com/tempoxyz/accounts/tree/main/examples/deposits)                                           | Open the deposit UI from a connected account.                                     | [Guide](/docs/guides/deposits)          |
| [Embed Domain-bound Passkeys](https://github.com/tempoxyz/accounts/tree/main/examples/webauthn)                        | Domain-bound passkey example using Wagmi and the `webAuthn` connector.            | [Guide](/docs/guides/authentication)    |
| [CLI + Tempo Wallets](https://github.com/tempoxyz/accounts/tree/main/examples/cli)                                     | Minimal CLI setup to connect and authorize local keys using Tempo Wallets.        | [Guide](/docs/guides/cli)               |
| [Access Keys + Tempo Wallets](https://github.com/tempoxyz/accounts/tree/main/examples/access-key)                      | Authorize access keys using Tempo Wallets to submit transactions without prompts. | [Guide](/docs/guides/spend-permissions) |
| [Access Keys + Domain-bound Passkeys](https://github.com/tempoxyz/accounts/tree/main/examples/access-key-and-webauthn) | Authorize access keys using domain-bound Passkeys.                                | [Guide](/docs/guides/spend-permissions) |
| [Sponsor Fees + Tempo Wallets](https://github.com/tempoxyz/accounts/tree/main/examples/fee-payer)                      | Sponsor transactions via Tempo Wallets.                                           | [Guide](/docs/guides/fee-sponsorship)   |
| [Sponsor Fees + Domain-bound Passkeys](https://github.com/tempoxyz/accounts/tree/main/examples/fee-payer-and-webauthn) | Sponsor transactions via domain-bound Passkeys.                                   | [Guide](/docs/guides/fee-sponsorship)   |

## Secure Origins (HTTPS)

The Tempo Accounts SDK is designed to be used on secure origins (HTTPS). If you are using HTTP,
it will fallback to using a popup instead of an iframe. This is because
WebAuthn is not supported on iframes embedded on insecure origins (HTTP).

Web frameworks typically default to HTTP in development environments. You
will need to ensure to turn on HTTPS in development to leverage the iframe dialog.

### Portless

[Portless](https://github.com/vercel-labs/portless) replaces port numbers with stable, named `.localhost` URLs and can enable HTTPS with auto-generated certificates.

```sh
npm install -g portless
portless run dev
# → https://myapp.localhost
```

### Next.js

HTTPS can be enabled on Next.js' dev server by setting the `--experimental-https` flag on the `next dev` command.

```bash
next dev --experimental-https
```

### Vite

HTTPS can be enabled on Vite's dev server by installing and configuring the `vite-plugin-mkcert` plugin.

```bash
npm i vite-plugin-mkcert
```

:::code-group

```ts [vite.config.ts]
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import mkcert from 'vite-plugin-mkcert'

export default defineConfig({
  plugins: [
    mkcert(),
    react(),
  ],
})
```

:::

## Getting Help

Have questions or building something cool with the Tempo Accounts SDK?

Join the Telegram group to chat with the team and other devs: [@mpp\_devs](https://t.me/mpp_devs)
