Skip to content
LogoLogo

Migration from v0

Replace each API of version 0 of the package with its API of version 1.

Version 0 of accounts connects an app to Tempo Wallet through an EIP-1193 provider. The app sends RPC methods, such as wallet_connect and eth_sendTransaction, and Tempo Wallet's dialog signs each call that no access key covers.

Version 1 is the SDK of Tempo ID, an OAuth 2.0 and OpenID Connect provider. A sign-in returns a session with the user, the tokens, and an access key that signs each transaction within the limits that the user approved. Accounts.create returns an instance in place of a provider, and plugins add its members.

Notable changes covers what affects most apps, and Quick reference lists each API of version 0. In each diff, removed lines are code of version 0, and added lines code of version 1.

Installation

Viem is a peer dependency.

Notable changes

Instance creation

Accounts.create replaces Provider.create, and chain replaces testnet. A web app needs no registration, since the page's origin is its client ID. See Instance.

tempo.config.ts
import { Provider, tempoWallet } from 'accounts'
import { Accounts } from 'accounts'
import { dialog, viem } from 'accounts/plugins'
 
const provider = Provider.create({ 
  adapter: tempoWallet(), 
  testnet: true, 
}) 
export const accounts = Accounts.create({ 
  chain: 'testnet', 
  plugins: [dialog(), viem()], 
}) 

Sign-in plugins

A sign-in plugin replaces each adapter, and its signIn replaces wallet_connect. dialog shows Tempo ID's sign-in over the page, as tempoWallet showed Tempo Wallet. See Sign-in.

import { accounts } from './tempo.config.js'
 
export async function signIn() {
  const result = await provider.request({ method: 'wallet_connect' }) 
  const address = result.accounts[0]?.address 
  const session = await accounts.dialog.signIn() 
  const address = session.accessKey?.account 
  return address
}

session.accessKey.account is the address of the Tempo Account that the access key acts for, not the access key's address. With the accessKey option set to false, a sign-in requests no access key, and accounts.account.get() reads the Tempo Account from Tempo ID.

import { accounts } from './tempo.config.js'
 
export async function getAddress() { 
  const account = await accounts.account.get() 
  return account?.address 
} 

Sessions

One session, which accounts.session reads, replaces the accounts of provider.store. An instance does not read version 0's stored state, so each user signs in once after the upgrade. See Session and storage.

import { accounts } from './tempo.config.js'
 
export async function watch(render: (address: string | undefined) => void) {
  await provider.ready() 
  const [address] = await provider.request({ method: 'eth_accounts' }) 
  const session = await accounts.session.get() 
  const address = session?.accessKey?.account 
  render(address)
 
  provider.on('accountsChanged', ([address]) => render(address)) 
  accounts.session.subscribe((session) => render(session?.accessKey?.account)) 
}

Access key requests

The app requests an access key at each sign-in with the accessKey option, which replaces accessKey.authorize. It takes a duration, a decimal limit, and a token symbol. See Access keys.

tempo.config.ts
import { Expiry } from 'accounts'
import { Addresses } from 'viem/tempo'
import { Accounts } from 'accounts'
import { dialog, viem } from 'accounts/plugins'
 
const provider = Provider.create({ 
  accessKey: { 
    authorize: { 
      expiry: Expiry.days(1), 
      limits: [{ limit: 100_000_000n, token: Addresses.ousd }], 
    }, 
  }, 
}) 
export const accounts = Accounts.create({ 
  accessKey: () => ({ 
    expiry: '1d', 
    limits: [{ limit: '100', token: 'ousd' }], 
  }), 
  chain: 'testnet', 
  plugins: [dialog(), viem()], 
}) 

Instance methods

A method of the instance replaces each RPC method. accounts.pay replaces wallet_transfer, with the same decimal amount, and the access key signs with no prompt. The viem plugin's actions take Viem's values, such as an amount in base units. See RPC methods.

import { Addresses } from 'viem/tempo'
import { accounts } from './tempo.config.js'
 
const to = '0x000000000000000000000000000000000000dEaD'
 
export async function send() {
  await provider.request({ 
    method: 'wallet_transfer', 
    params: [{ amount: '1', to, token: Addresses.ousd }], 
  }) 
  const { transaction } = await accounts.pay({ 
    amount: '1', 
    to, 
    token: Addresses.ousd, 
  }) 
  return transaction 
}

Wagmi connector

The tempoId connector of accounts/wagmi replaces tempoWallet of wagmi/connectors, and takes the options of Accounts.create. The hooks of Viem's actions replace Hooks.wallet, which sends Tempo Wallet's RPC methods. See Wagmi.

import { tempoId } from 'accounts/wagmi'
import { createConfig, http } from 'wagmi'
import { tempoModerato } from 'wagmi/chains'
import { tempoWallet } from 'wagmi/connectors'
 
export const config = createConfig({
  chains: [tempoModerato],
  connectors: [tempoWallet()], 
  connectors: [ 
    // The page's origin is a third-party client ID, whose connection needs an access key.
    tempoId({ accessKey: { expiry: '1d', limits: [{ limit: '100', token: 'ousd' }] } }), 
  ], 
  transports: { [tempoModerato.id]: http() },
})

Server plugins

One server instance replaces each Handler of accounts/server, and the backend plugin replaces Handler.auth. The backend holds the session and its access key, and the page holds only a cookie. See Server.

server.ts
import { Handler, Kv } from 'accounts/server'
import { Accounts, Store } from 'accounts'
import { backend } from 'accounts/plugins'
 
const auth = Handler.auth({ path: '/api/auth', store: Kv.memory() }) 
const accounts = Accounts.create({ 
  clientId: 'https://app.example', 
  plugins: [backend({ store: Store.memory() })], 
}) 
 
export default {
  fetch: (request: Request) => auth.fetch(request), 
  fetch: (request: Request) => accounts.handler.fetch(request), 
}

Fee relay

The relay plugin replaces Handler.relay, and the viem plugin's relay option replaces feePayer. A relay is a JSON-RPC proxy whose fee payer co-signs each transaction.

Version 0's route checks no caller, and version 1's verifies each request's access token. See Fee sponsorship.

tempo.config.ts
import { Accounts } from 'accounts'
import { dialog, viem } from 'accounts/plugins'
 
const provider = Provider.create({ 
  adapter: tempoWallet(), 
  feePayer: '/api/relay', 
}) 
export const accounts = Accounts.create({ 
  chain: 'testnet', 
  plugins: [dialog(), viem({ relay: '/api/relay' })], 
}) 

Removed adapters

The local plugin replaces the local and secp256k1 adapters: it holds a secp256k1 owner key, and takes a version 0 file's account with v0. See Local owner keys. Version 1 has no replacement for the other adapters that hold an owner key in the app: webAuthn, turnkey, and privy. See Removed APIs.

Removed surface

The root entry exports no EIP-1193 provider and no RPC schema, and only the wagmi connector's getProvider returns a provider. Version 1 has no wallet-side module, such as Remote and Messenger, since Tempo ID is the only wallet side, and no handler for a flow that Tempo ID serves. See Removed APIs.

Quick reference

Each export, option, member, and RPC method of version 0, in alphabetical order. An option belongs to Provider.create or to its adapter.

Version 0Version 1Section
accessKey.authorize (option)accessKeyAccess keys
accessKey.keystores (option)Removed. The instance creates and keeps the access keyAccess keys
AdapterRemoved. Plugin.from extends an instanceRemoved APIs
adapter (option)pluginsInstance
asyncStorageRemoved. expo sets the store, or Store.from wraps oneReact Native
auth (option)dialog({ backend: true })Backend sessions
authorizeAccessKey (option)accessKeyAccess keys
chains (option)chains, as chain IDsInstance
clideviceCLI
CliAuthRemoved. Tempo ID serves the device grantRemoved APIs
ConnectortempoIdWagmi
dangerous_secp256k1localLocal owner keys
deviceCodedeviceCLI
DialogRemoved. The dialog plugin owns the dialogRemoved APIs
dialogdialog of accounts/pluginsSign-in
eth_accountssession.accessKey?.account, or accounts.account.get()RPC methods
eth_chainIdaccounts.chain.get()RPC methods
eth_fillTransactionaccounts.fillTransactionRPC methods
eth_requestAccountsaccounts.dialog.signIn()Sign-in
eth_sendTransactionaccounts.sendTransactionRPC methods
eth_sendTransactionSyncaccounts.sendTransactionSyncRPC methods
eth_signTransactionaccounts.signTransactionRPC methods
eth_signTypedData_v4accounts.signTypedDataRPC methods
ExecutionErrorExecutionError of viem/tempoErrors
ExpiryA duration, such as '1d', or Expiry of viem/tempoAccess keys
feePayer (option)viem({ relay })Fee sponsorship
getOrCreateMmkvEncryptionKeyRemovedReact Native
Handler.authbackendBackend sessions
Handler.codeAuthRemoved. Tempo ID serves the device grantRemoved APIs
Handler.composeaccounts.handlerBackend sessions
Handler.deviceCodeRemoved. Tempo ID serves the device grantRemoved APIs
Handler.exchangeRemoved. accounts.dex reads each quoteRemoved APIs
Handler.fromaccounts.handlerBackend sessions
Handler.oidcProviderRemoved. Tempo ID issues each tokenRemoved APIs
Handler.relayrelayFee sponsorship
Handler.webAuthnRemoved. Tempo ID runs each passkey ceremonyRemoved APIs
HandoffRemoved. Version 1 has no phone handoffRemoved APIs
handoff (option)Removed. Version 1 has no phone handoffRemoved APIs
hcRemoved. Import it from hono/clientRemoved APIs
Hooks.wallet.useDepositaccounts.funding.open() of an instanceWagmi
Hooks.wallet.useSwapHooks.dex.useSellSync, Hooks.dex.useBuySyncWagmi
Hooks.wallet.useTransferHooks.token.useTransferSyncWagmi
hydrationTimeout (option)RemovedSession and storage
icon, name, rdns, theme (options)Removed. Tempo ID names the appSign-in
IdentityRemoved. The session holds the verified userRemoved APIs
identity (option)Removed. The session holds the verified userRemoved APIs
IntersectionObserverRemoved. The dialog plugin reads the support of the browserRemoved APIs
KeystoreRemoved. The instance creates and keeps the access keyAccess keys
Kv.cloudflareStore.workersKv of accounts/cloudflareStores
Kv.durableObjectSessions.durableObject, or Store.durableObject, of accounts/cloudflareStores
Kv.fromStore.fromStores
Kv.memoryStore.memoryStores
Kv.NonceStorageDurableObject.sessions of accounts/cloudflareStores
locallocalLocal owner keys
Mach.fundaccounts.funding.openRPC methods
Mach.getFundingUrlRemovedRemoved APIs
Mach.tokenRemoved. A limit names the token as 'mach'Access keys
maxAccounts (option)Removed. An instance holds one sessionSession and storage
MessengerRemovedRemoved APIs
mobileWebAuthexpo of accounts/expoReact Native
MountRemovedRemoved APIs
mpp (option)mpp of accounts/mppMPP
openAuthSessionexpo of accounts/expoReact Native
persistCredentials (option)RemovedSession and storage
personal_signaccounts.signMessage, or accounts.dialog.signMessageRPC methods
postMessageRemovedRemoved APIs
privyRemovedRemoved APIs
PromptErrorRemoved. onCode shows the codeCLI
provider.chainsaccounts.chain.get(), for the selected chainInstance
Provider.createAccounts.createInstance
provider.getAccessKeyStatussession.accessKey, Session.expiredAccess keys
provider.getAccountRemoved. No Viem action takes accountInstance
provider.getClientaccounts.viemInstance
provider.getMppxParametersaccounts.mpp(), a payerMPP
provider.onaccounts.session.subscribe, accounts.chain.subscribeSession and storage
provider.readyaccounts.session.getSession and storage
provider.requestA method of the instanceRPC methods
provider.storeaccounts.sessionSession and storage
ProviderRequestRemovedRemoved APIs
relay (option)transport of viem()Instance
RemoteRemovedRemoved APIs
RpcRemovedRemoved APIs
SchemaRemovedRemoved APIs
secp256k1localLocal owner keys
secureMmkvRemoved. expo sets the store, or Store.from wraps oneReact Native
storage (option)storeSession and storage
Storage.combineRemovedSession and storage
Storage.cookieRemovedSession and storage
Storage.filesystemStore.fileCLI
Storage.fromStore.fromSession and storage
Storage.idbThe default store of a browserSession and storage
Storage.localStorageRemovedSession and storage
Storage.memoryStore.memorySession and storage
Store.HydrationErrorRemovedSession and storage
Store.waitForHydrationaccounts.session.getSession and storage
tempoWalletdialog of accounts/plugins, tempoId of accounts/wagmiSign-in
testnet (option)chain: 'testnet'Instance
TimeoutErrorAccounts.RequestError, with expired_tokenCLI
transports (option)transport of viem()Instance
TrustedHostsTempo ID's verification of the app, which skips the frame's visibility checkSign-in
turnkeyRemovedRemoved APIs
wallet_authorizeAccessKeyaccounts.dialog.signIn({ accessKey })Access keys
wallet_connectaccounts.dialog.signIn()Sign-in
wallet_depositaccounts.funding.open()RPC methods
wallet_depositZoneaccounts.zone.depositRPC methods
wallet_disconnectaccounts.signOut()RPC methods
wallet_getBalancesaccounts.token.getBalanceRPC methods
wallet_getCallsStatusThe receipt of a Sync actionRPC methods
wallet_getCapabilitiesRemovedRemoved APIs
wallet_revokeAccessKeyaccounts.dialog.revokeAccessKey()Access keys
wallet_sendCallsaccounts.sendTransactionSync, with callsRPC methods
wallet_swapaccounts.dex.sellSync, accounts.dex.buySyncRPC methods
wallet_switchEthereumChainaccounts.switchChainRPC methods
wallet_transferaccounts.payRPC methods
wallet_updateAccessKeyaccounts.dialog.updateAccessKeyAccess keys
wallet_withdrawZoneaccounts.zone.requestWithdrawalRPC methods
webAuthnRemovedRemoved APIs
WebAuthnCeremonyRemoved. Tempo ID runs each passkey ceremonyRemoved APIs

Entrypoints

Plugins move to accounts/plugins, and each optional platform has its own entry.

Version 0Version 1
accountsaccounts: Accounts, Permissions, Plugin, Session, Store
accounts, for each adapteraccounts/plugins (Sign-in)
accounts/cli, accounts/deviceCodedevice of accounts/plugins (CLI)
accounts/mobileWebAuthaccounts/expo (React Native)
accounts/postMessageRemoved (Removed APIs)
accounts/react, with RemoteRemoved. accounts/react now exports the react plugin, which adds accounts.useSession()
accounts/react/privyRemoved (Removed APIs)
accounts/react-native/async-storageRemoved (React Native)
accounts/react-native/expo-secure-storeRemoved (React Native)
accounts/react-native/expo-web-browseraccounts/expo (React Native)
accounts/react-native/secure-mmkvRemoved (React Native)
accounts/serveraccounts/plugins, and accounts/cloudflare for a Worker (Server)
accounts/wagmiaccounts/wagmi: tempoId, wagmi (Wagmi)

The mpp plugin has its own entry, accounts/mpp (MPP).

Instance

Accounts.create takes these options in place of those of Provider.create. Instance creation holds the main example.

Version 0Version 1
accessKey.authorize, authorizeAccessKeyaccessKey (Access keys)
adapterplugins (Sign-in)
authdialog({ backend: true }) (Server)
chains, as chain definitionschains, as chain IDs
feePayerviem({ relay }) (Fee sponsorship)
mppmpp() of accounts/mpp (MPP)
relay, transportstransport of viem()
storagestore (Session and storage)
testnet: truechain: 'testnet'
hydrationTimeout, identity, maxAccounts, persistCredentialsRemoved

An instance needs a client ID. In a browser, clientId defaults to the page's origin. A CLI passes a cli: name, and a backend its public origin.

The viem plugin takes the transport of the instance's chain, or a function that returns the options of each chain.

tempo.config.ts
import { Accounts } from 'accounts'
import { dialog, viem } from 'accounts/plugins'
import { http } from 'viem'
import { tempo, tempoModerato } from 'viem/chains'
 
const provider = Provider.create({ 
  chains: [tempoModerato, tempo], 
  transports: { 
    [tempo.id]: http('https://rpc.example/tempo'), 
    [tempoModerato.id]: http('https://rpc.example/moderato'), 
  }, 
}) 
export const accounts = Accounts.create({ 
  chain: 'testnet', 
  plugins: [ 
    dialog(), 
    viem((chainId) => ({ 
      transport: http(`https://rpc.example/${chainId}`), 
    })), 
  ], 
}) 

The provider's members map to the instance's:

Version 0Version 1
provider.chainsaccounts.chain.get(), the ID of the selected chain
provider.getAccessKeyStatus()session.accessKey, Session.expired(session)
provider.getAccount()Removed. No Viem action of the instance takes account
provider.getClient()accounts.viem
provider.getMppxParameters()accounts.mpp(), a payer of the mpp plugin
provider.on(event)accounts.session.subscribe, accounts.chain.subscribe
provider.ready()accounts.session.get()
provider.request({ method })A method of the instance (RPC methods)
provider.storeaccounts.session

Sign-in

A Tempo ID sign-in plugin replaces each adapter that reaches Tempo Wallet. An instance without a sign-in plugin receives dialog.

Version 0Version 1
tempoWallet(), dialog(), or no adapterdialog()
cli(), deviceCode()device() (CLI)
mobileWebAuth(), tempoWallet() of accounts/mobileWebAuthexpo() (React Native)
local(), secp256k1()local() (Local owner keys)
turnkey(), webAuthn(), privy()Removed (Removed APIs)
postMessage()Removed (Removed APIs)

These adapter options have no replacement:

AdapterOptions
dialogdialog, host, icon, name, rdns, theme
tempoWallethandoff, icon, mount, theme

Tempo ID's approval page names the app: the host for an origin client ID, or the name of the app's registration.

Tempo ID's verification of a registered app replaces TrustedHosts. In Safari and Firefox, which lack IntersectionObserver v2, the dialog frames Tempo ID's pages only for a first-party or verified app. Any other app's pages open in a popup.

The sign-in's parameters replace the capabilities of wallet_connect:

Version 0, capabilitiesVersion 1, accounts.dialog.signIn
authbackend of dialog(), with method: 'siwe' for a SIWE message
authorizeAccessKeyaccessKey
personalSign, digestchallenge, whose signature is session.challengeSignature
showDepositfunding
identityRemoved. session.user holds the verified email
method: 'register', name, userId, credentialIdRemoved. Tempo ID's page selects the sign-in or the registration
import { accounts } from './tempo.config.js'
 
export async function signIn(message: string) {
  const result = await provider.request({ 
    method: 'wallet_connect', 
    params: [{ capabilities: { personalSign: { message } } }], 
  }) 
  const signature = result.accounts[0]?.capabilities.signature 
  const session = await accounts.dialog.signIn({ challenge: message }) 
  const signature = session.challengeSignature 
  return signature
}

CLI

The device plugin, the OAuth device authorization grant (RFC 8628), replaces Provider.create of accounts/cli. Version 0 opens the browser itself. In version 1, onCode shows the code and its URL.

A cli: client ID needs no registration, and its instance saves the session to ~/.tempo/id/store.json with no store option. Store.file replaces Storage.filesystem for another file.

import { accounts } from './tempo.config.js'
 
await provider.request({ method: 'wallet_connect' }) 
const session = await accounts.device.signIn() 
Version 0Version 1
host, name, rdnsclientId
openonCode of device()
Storage.filesystem()The default store of a cli: client ID
TimeoutError of accounts/deviceCodeAccounts.RequestError, with expired_token
PromptError of accounts/deviceCodeRemoved. onCode shows the code
pollingInterval, retryCount, timeoutRemoved. Tempo ID sets the interval and the expiry

React Native

The expo preset of accounts/expo replaces accounts/mobileWebAuth and the accounts/react-native entries. It keeps the session in the device's secure store, and signs in on Tempo ID's pages in the system browser. A native app passes its registration's client ID, since the registration names the app's custom scheme.

import { Button } from 'react-native'
import { accounts } from './tempo.config.js'
 
export function App() {
  async function signIn() {
    await provider.request({ method: 'wallet_connect' }) 
    await accounts.redirect.signIn() 
  }
 
  return <Button onPress={signIn} title="Sign in with Tempo" />
}
Version 0Version 1
baseUrlclientId
openAuthSessionRemoved. expo opens the system browser
asyncStorage(), secureMmkv()The secure store of expo, or Store.from as store
getOrCreateMmkvEncryptionKey()Removed

Session and storage

accounts.session replaces provider.store, version 0's Zustand store. Sessions holds the main example.

Version 0Version 1
provider.store.getState().accountsaccounts.session.get()
provider.store.subscribeaccounts.session.subscribe
provider.ready(), Store.waitForHydrationaccounts.session.get(), which loads the saved session
Store.HydrationError, hydrationTimeoutRemoved
provider.on('accountsChanged')accounts.session.subscribe
provider.on('chainChanged')accounts.chain.subscribe
provider.on('connect'), provider.on('disconnect')accounts.session.status
maxAccountsRemoved. An instance holds one session
persistCredentialsRemoved. The store holds the whole session

accounts.session.status holds pending, reauthorizing, signedIn, or signedOut.

import { accounts } from './tempo.config.js'
 
export function watch(render: (status: string) => void) {
  provider.on('connect', () => render('connected')) 
  provider.on('disconnect', () => render('disconnected')) 
  accounts.session.status.subscribe(() => { 
    render(accounts.session.status.get().status) 
  }) 
}

The store option replaces storage. A store holds values without serializing them, since a browser's access key is a non-extractable CryptoKey.

Version 0Version 1
Storage.idb()The default store of a browser
Storage.memory()Store.memory()
Storage.from()Store.from()
Storage.filesystem() of accounts/cliStore.file()
Storage.combine(), Storage.cookie(), Storage.localStorage()Removed

Outside a browser, an instance with a cli: client ID saves its session to the file of Store.file(). Any other instance holds a session only with a store.

Access keys

The accessKey option replaces accessKey.authorize and authorizeAccessKey. Access key requests holds the main example.

Version 0Version 1
expiry: Expiry.days(1)expiry: '1d', or Unix seconds
limits: [{ limit: 100_000_000n, token }]limits: [{ limit: '100', token: 'ousd' }]
Expiry.months(), Expiry.years()Expiry of viem/tempo. A duration has no such unit
Mach.tokentoken: 'mach'
accessKey.keystores, Keystore, reuseRemoved. The instance creates and keeps the access key

Without scopes, the instance fills them from limits. Size limits for the app's transactions, since no dialog signs a transaction outside them. Tempo ID's approval page, in the dialog, replaces each RPC method of an access key, and each call defaults to the session's access key.

import { accounts } from './tempo.config.js'
 
export async function revoke() {
  await provider.request({ 
    method: 'wallet_revokeAccessKey', 
    params: [{ accessKeyAddress, address }], 
  }) 
  await accounts.dialog.revokeAccessKey() 
}
Version 0Version 1
wallet_authorizeAccessKeyaccounts.dialog.signIn({ accessKey })
wallet_updateAccessKeyaccounts.dialog.updateAccessKey({ limits })
wallet_revokeAccessKeyaccounts.dialog.revokeAccessKey(), or accounts.accessKey.revokeSync
provider.getAccessKeyStatus()session.accessKey, and Session.expired(session)

The session replaces the access key's status. accounts.session.get() empties a saved session whose access key expired.

import { Session } from 'accounts'
import { accounts } from './tempo.config.js'
 
export async function isUsable() {
  const status = await provider.getAccessKeyStatus() 
  const usable = status === 'pending' || status === 'published'
  const session = await accounts.session.get() 
  const usable = !!session?.accessKey && !Session.expired(session) 
  return usable
}

RPC methods

A method of the instance replaces each RPC method of provider.request. Instance methods holds the main example.

Version 0Version 1
eth_accountssession.accessKey?.account, or accounts.account.get()
eth_chainIdaccounts.chain.get()
eth_fillTransaction, eth_signTransactionaccounts.fillTransaction, accounts.signTransaction
eth_requestAccounts, wallet_connectaccounts.dialog.signIn() (Sign-in)
eth_sendTransactionaccounts.sendTransaction
eth_sendTransactionSync, wallet_sendCallsaccounts.sendTransactionSync, with calls
eth_signTypedData_v4accounts.signTypedData
personal_signaccounts.signMessage, or accounts.dialog.signMessage
wallet_deposit, Mach.fundaccounts.funding.open()
wallet_depositZone, wallet_withdrawZoneaccounts.zone.deposit, accounts.zone.requestWithdrawal
wallet_disconnectaccounts.signOut()
wallet_getBalancesaccounts.token.getBalance, for each token
wallet_getCallsStatusThe receipt of a Sync action, or accounts.waitForTransactionReceipt
wallet_getCapabilitiesRemoved
wallet_swapaccounts.dex.sellSync, accounts.dex.buySync
wallet_switchEthereumChainaccounts.switchChain({ chainId })
wallet_transferaccounts.pay

Access keys lists the RPC methods of an access key.

The access key signs each transaction. Without one, a transaction throws Accounts.AccessKeyRequiredError, except accounts.token.transfer and transferSync on a page, which Tempo ID's payment page sends. On a page, if the node refuses a transaction for a low balance or a spent limit, Tempo ID's screen fixes it, and the transaction sends again.

accounts.signMessage signs with the access key, in a keychain envelope for the Tempo Account. accounts.dialog.signMessage shows the message on Tempo ID's page, and the Tempo Account signs it, as personal_sign did.

import { accounts } from './tempo.config.js'
 
export async function sign(message: string) {
  const signature = await provider.request({ 
    method: 'personal_sign', 
    params: [Hex.fromString(message), address], 
  }) 
  const { signature } = await accounts.dialog.signMessage({ message }) 
  return signature
}

wallet_sendCalls returns an ID for wallet_getCallsStatus. A Sync action returns the receipt itself.

import { parseUnits } from 'viem'
import { Actions, Addresses } from 'viem/tempo'
import { accounts } from './tempo.config.js'
 
const calls = [
  Actions.token.transfer.call({
    amount: parseUnits('1', 6),
    to: '0x000000000000000000000000000000000000dEaD',
    token: Addresses.ousd,
  }),
]
 
export async function send() {
  const { id } = await provider.request({ 
    method: 'wallet_sendCalls', 
    params: [{ calls }], 
  }) 
  const { receipts } = await provider.request({ 
    method: 'wallet_getCallsStatus', 
    params: [id], 
  }) 
  const receipt = await accounts.sendTransactionSync({ calls }) 
  return receipt 
}

Wagmi

tempoId replaces tempoWallet, and takes the options of Accounts.create, with the config's chains and transports. Wagmi connector holds the main example.

import { viem } from 'accounts/plugins'
import { tempoId } from 'accounts/wagmi'
import { Expiry } from 'accounts'
import { Addresses } from 'viem/tempo'
import { tempoWallet } from 'wagmi/connectors'
 
const connector = tempoWallet({ 
  authorizeAccessKey: () => ({ 
    expiry: Expiry.days(1), 
    limits: [{ limit: 100_000_000n, token: Addresses.ousd }], 
  }), 
  feePayer: '/api/relay', 
}) 
const connector = tempoId({ 
  accessKey: () => ({ 
    expiry: '1d', 
    limits: [{ limit: '100', token: 'ousd' }], 
  }), 
  plugins: [viem({ relay: '/api/relay' })], 
}) 
Version 0Version 1
tempoWallet() of wagmi/connectorstempoId() of accounts/wagmi
Connector, dialog, tempoWallet of accounts/wagmitempoId() of accounts/wagmi
dangerous_secp256k1 of accounts/wagmilocal (Local owner keys)
webAuthn of accounts/wagmiRemoved (Removed APIs)
Hooks.wallet.useTransfer of wagmi/tempoHooks.token.useTransferSync of wagmi/tempo
Hooks.wallet.useSwap of wagmi/tempoHooks.dex.useSellSync, Hooks.dex.useBuySync of wagmi/tempo
Hooks.wallet.useDeposit of wagmi/tempoaccounts.funding.open() of an instance
capabilities of connectaccessKey and signIn of connect

The wagmi plugin of accounts/wagmi adds accounts.wagmi, a wagmi config for an instance that the app creates itself.

Server

One instance replaces each Handler of accounts/server. accounts.handler serves each server plugin's routes, so it replaces Handler.compose and Handler.from.

Backend sessions

accounts.handler serves the backend plugin's routes under /api/auth, and accounts.session.get reads a request's session. On the page, dialog({ backend: true }) replaces the auth option.

import { Handler, Kv } from 'accounts/server'
import { Accounts, Store } from 'accounts'
import { backend } from 'accounts/plugins'
import { Hono } from 'hono'
 
const auth = Handler.auth({ path: '/api/auth', store: Kv.memory() }) 
const accounts = Accounts.create({ 
  accessKey: () => ({ 
    expiry: '1d', 
    limits: [{ limit: '100', token: 'ousd' }], 
  }), 
  chain: 'testnet', 
  clientId: 'https://app.example', 
  plugins: [backend({ store: Store.memory() })], 
}) 
 
const app = new Hono()
 
app.all('/api/*', (c) => auth.fetch(c.req.raw)) 
app.all('/api/*', (c) => accounts.handler.fetch(c.req.raw)) 
 
app.get('/me', async (c) => {
  const session = await auth.getSession(c.req.raw) 
  if (!session) return c.json({ error: 'unauthenticated' }, 401) 
  return c.json({ address: session.address }) 
  const session = await accounts.session.get(c.req.raw) 
  if (session?.method !== 'tempo-id') 
    return c.json({ error: 'unauthenticated' }, 401) 
  return c.json({ address: session.accessKey?.account }) 
})
 
export default app

The session names a Tempo Account only through its access key, so the backend's instance sets accessKey. A deployed origin lists /api/auth/callback in the redirect_uris of its web app manifest.

Version 0Version 1
/api/auth/challenge, /api/auth, /api/auth/logout/api/auth/login, /api/auth/callback, /api/auth/session, /api/auth/logout
The EIP-4361 message that the user signssiwe(), with signIn({ method: 'siwe' }) of the dialog plugin
auth.getSession(request)accounts.session.get(request)
session.address, session.emailsession.accessKey?.account, session.user.email
Handler.compose, Handler.fromaccounts.handler

Fee sponsorship

The relay plugin replaces Handler.relay, and accounts.relay.fetch serves its route. Fee relay shows the page's change.

server.ts
import { Handler } from 'accounts/server'
import { Accounts } from 'accounts'
import { relay } from 'accounts/plugins'
import { Hono } from 'hono'
import { privateKeyToAccount } from 'viem/accounts'
 
const account = privateKeyToAccount(
  process.env.FEE_PAYER_PRIVATE_KEY as `0x${string}`,
)
 
const handler = Handler.relay({ feePayer: { account }, path: '/api/relay' }) 
const accounts = Accounts.create({ 
  chain: 'testnet', 
  clientId: 'https://app.example', 
  plugins: [relay({ account })], 
}) 
 
const app = new Hono()
 
app.post('/api/relay', (c) => handler.fetch(c.req.raw)) 
app.post('/api/relay', (c) => accounts.relay.fetch(c.req.raw)) 
 
export default app
Version 0Version 1
autoSwapRelay.autoSwap() of viem/tempo, in plugins
cacheTtl, kvRemoved
chains, transportsThe chain of the instance, and the viem plugin
feePayer.accountaccount, or apiKey for the sponsor of the Tempo API
feePayer.feeToken, feePayer.name, feePayer.url, feePayer.validateThe options of Relay.feePayer() of viem/tempo, in plugins
features: 'all'The relay plugins of viem/tempo, in plugins
onRequestauthorize, which receives the request and its verified token
pathThe path of the app's own route, or handler: { relay: true } for /api/relay
resolveTokensresolveTokens

Relay.feePayer takes the fee payer and its policy, so a relay plugin with plugins takes no account, and throws with both. The plugins run in order, and the plugins after Relay.feePayer do not run for a transaction that it signs.

server.ts
import { Handler } from 'accounts/server'
import { Accounts } from 'accounts'
import { relay } from 'accounts/plugins'
import { Hono } from 'hono'
import { privateKeyToAccount } from 'viem/accounts'
import { Relay } from 'viem/tempo'
 
const account = privateKeyToAccount(
  process.env.FEE_PAYER_PRIVATE_KEY as `0x${string}`,
)
const allowed = '0x000000000000000000000000000000000000dEaD'
 
const handler = Handler.relay({ 
  autoSwap: true, 
  feePayer: { 
    account, 
    validate: (request) => request.to === allowed, 
  }, 
  path: '/api/relay', 
}) 
const accounts = Accounts.create({ 
  chain: 'testnet', 
  clientId: 'https://app.example', 
  plugins: [ 
    relay({ 
      plugins: [ 
        Relay.feePayer({ 
          account, 
          validate: (request) => request.to === allowed, 
        }), 
        Relay.autoSwap(), 
      ], 
    }), 
  ], 
}) 
 
const app = new Hono()
 
app.post('/api/relay', (c) => handler.fetch(c.req.raw)) 
app.post('/api/relay', (c) => accounts.relay.fetch(c.req.raw)) 
 
export default app

With verify: false, the route checks no caller, as in version 0. Use it only behind the app's own guard, such as a backend session.

Stores

Store replaces Kv of accounts/server. The backend plugin's store holds each backend session.

Version 0Version 1
Kv.memory()Store.memory()
Kv.from()Store.from()
Kv.durableObject()Sessions.durableObject() of accounts/cloudflare, for the sessions of backend
Kv.NonceStorageDurableObject.sessions() of accounts/cloudflare
Kv.cloudflare()Store.workersKv() of accounts/cloudflare

Store.postgres and Store.redis are new server stores. Store.durableObject of accounts/cloudflare keeps values in the app's own Durable Object.

MPP

The mpp plugin of accounts/mpp replaces the mpp option. Version 0's option is on by default, and replaces the global fetch. Version 1 leaves the global fetch, and adds accounts.fetch, which pays each HTTP 402 challenge with the session's access key.

import { accounts } from './tempo.config.js'
 
export async function fortune() {
  const response = await fetch('https://api.example.com/fortune') 
  const response = await accounts.fetch('https://api.example.com/fortune') 
  return response.text()
}

provider.getMppxParameters() returns the parameters of an mppx client that the app creates. accounts.mpp() returns a payer with its own fetch, and accounts.mpp.session() returns a payment session's manager.

import { accounts } from './tempo.config.js'
 
export async function fortune() { 
  const payer = accounts.mpp({ maxAmount: '1' }) 
  const response = await payer.fetch('https://api.example.com/fortune') 
  return response.text() 
} 

Errors

ExecutionError moves to viem/tempo, and ExecutionError.from replaces ExecutionError.parse.

parse.ts
import { ExecutionError } from 'accounts'
import { ExecutionError } from 'viem/tempo'
 
export function parse(error: Error) {
  const parsed = ExecutionError.parse(error) 
  const parsed = ExecutionError.from(error) 
  return parsed
}

Version 0's provider rejects with an RPC error and its code. An instance throws named errors:

Version 1Condition
Accounts.RequestErrorTempo ID refuses a request. Its reason names the cause
Accounts.AccessKeyRequiredErrorThe session holds no access key for the call
Accounts.SignedOutErrorA Viem action runs while the instance holds no session

Removed APIs

Version 1 has no replacement for these APIs.

Version 0Reason
turnkey, webAuthn, privyAn instance holds no owner key but the local plugin's
AdapterA plugin of Plugin.from extends an instance
Remote, Dialog, Messenger, Mount, postMessageTempo ID is the only wallet side
Handoff, handoffVersion 1 has no phone handoff
IntersectionObserverThe dialog plugin reads the support of the browser
Keystore, accessKey.keystoresThe instance creates and keeps the access key
Schema, Rpc, ProviderRequest, wallet_getCapabilitiesThe instance serves no RPC request
Handler.codeAuth, Handler.deviceCode, CliAuthTempo ID serves the device grant
Handler.webAuthn, WebAuthnCeremonyTempo ID runs each passkey ceremony
Handler.oidcProvider, Identity, identityTempo ID issues each token, with the verified user
Handler.exchangeThe page reads each quote through accounts.dex
hchono/client exports it
Mach.getFundingUrlaccounts.funding.open() opens the deposit page
icon, name, rdns, themeTempo ID's approval page names the app, and takes no theme
cacheTtl, kv of Handler.relayThe relay plugin holds no cache

Next steps