Getting Started
Overview
Tempo is a purpose-built Layer 1 blockchain optimized for payments.
It enshrines features like token management, Fee AMM, and a stablecoin DEX directly into the protocol, as well as a Tempo transaction type with support for batch calls, fee sponsorship, configurable fee tokens, concurrent transactions, access keys, and scheduled execution.
Setup
Setup the Tempo extension for Viem by following the steps below.
Install
To use the Tempo extension, ensure that you have Viem installed.
npm i viemConfigure
Next, we will configure a Viem Client.
In the snippet below, we will set up a Tempo chain, and extend our client with tempoActions.
import { createClient, http, publicActions, walletActions } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { tempoTestnet } from 'viem/chains'
import { tempoActions } from 'viem/tempo'
export const client = createClient({
account: privateKeyToAccount('0x...'),
chain: tempoTestnet,
transport: http(),
})
.extend(publicActions)
.extend(walletActions)
.extend(tempoActions())Use Viem Actions
Once we have configured our Viem client with Tempo, we can then use regular Viem actions (e.g. sendTransactionSync)
that are decorated with Tempo properties
like calls (batch transactions), feePayer (fee sponsorship), nonceKey (concurrent transactions) and more!
import { client } from './viem.config'
const receipt = await client.sendTransactionSync({
calls: [
{
data: '0xcafebabe00000000000000000000000000000001',
to: '0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef'
},
{
data: '0xdeadbeef00000000000000000000000000000002',
to: '0xfeedfacefeedfacefeedfacefeedfacefeedface'
},
{
data: '0xfeedface00000000000000000000000000000003',
to: '0xfeedfacefeedfacefeedfacefeedfacefeedface'
},
],
feePayer: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045',
nonceKey: 1337n,
})Use Tempo Actions
You can also use Tempo-specific Actions:
import { client } from './viem.config'
const alphaUsd = '0x20c0000000000000000000000000000000000001'
const metadata = await client.token.getMetadata({
token: alphaUsd
})
console.log(
'Alpha USD Metadata:',
metadata.name,
metadata.symbol,
metadata.decimals,
metadata.totalSupply
)
Alpha USD Metadata: Alpha USD, AlphaUSD, 6, 1000000000000000000000nNext Steps
After you have set up Tempo with Viem, you can now:
- Follow a guide on how to use accounts, make payments, issue stablecoins and exchange stablecoins.
- Use the suite of Tempo Actions