Skip to content
LogoLogo

Getting started

Get started with Tempo ID in an app.

Overview

The Accounts SDK provides what an app needs to sign users in with Tempo ID, act onchain on Tempo, and call the Tempo API.

Sign in with Tempo IDSign users in on the web, on mobile, in a CLI, or on a server. Act onchain on TempoSend payments and transactions within limits that the user approves, with no wallet prompt. Use the Tempo APISponsor the fees of users' transactions through the Tempo API.

Demo

The demo signs in through Tempo ID's dialog, and pays 1 OUSD on Tempo testnet with the sign-in's access key, with no approval.

Send a paymentDemo
pnpx gitpick tempoxyz/accounts/tree/main/examples/webSource

Quick prompt

To add the flow of the demo to an app, paste this prompt into a coding agent.

Walkthrough

Each tab builds the flow on one platform, on Tempo testnet.

The web example runs these steps in a React app.

Install the packages

Create the instance

Create one instance for the app with Accounts.create. Each sign-in requests an access key with these limits.

tempo.config.ts
import { Accounts } from 'accounts'
import { viem } from 'accounts/plugins'
import { react } from 'accounts/react'
 
export const accounts = Accounts.create({
  // Each sign-in requests an access key that sends up to 100 OUSD for a day.
  accessKey: () => ({
    expiry: '1d',
    limits: [{ limit: '100', token: 'ousd' }],
  }),
  chain: 'testnet',
  plugins: [react(), viem()],
})

Sign the user in

useSession returns the session, and renders again when it changes. Without a session, dialog.signIn opens Tempo ID's sign-in in a dialog over the page.

import { accounts } from './tempo.config.js'
 
export function App() {
  const { session } = accounts.useSession()
 
  if (!session)
    return (
      <button onClick={() => accounts.dialog.signIn()} type="button">
        Sign in with Tempo
      </button>
    )
 
  return <p>Signed in as {session.user.email}</p>
}

Send a payment

pay sends 1 OUSD from the user's Tempo Account. If the access key's limits hold the amount, the access key signs it, and the user approves nothing. Otherwise, Tempo ID's payment page asks the user to approve it.

import { accounts } from './tempo.config.js'
 
export function Send() {
  return (
    <button
      onClick={async () => {
        const { transaction } = await accounts.pay({
          amount: '1',
          to: '0x000000000000000000000000000000000000dEaD',
          token: 'ousd',
        })
        console.log(transaction)
      }}
      type="button"
    >
      Send 1 OUSD
    </button>
  )
}

Render the button once the user signs in.

Examples

Each example is a small app that installs as it is.

The examples folder holds the others.

Next steps