Documentation Index Fetch the complete documentation index at: https://mintlify.com/tempoxyz/tempo/llms.txt
Use this file to discover all available pages before exploring further.
The TypeScript SDK provides a type-safe, developer-friendly interface for building on Tempo. Built on top of viem , it extends Ethereum tooling with Tempo-specific features like TIP-20 tokens, batch payments, and account abstraction.
Installation
npm install tempo-viem viem
Quick Start
Connect to Tempo testnet:
import { createPublicClient , http } from 'viem'
import { tempoTestnet } from 'tempo-viem/chains'
const client = createPublicClient ({
chain: tempoTestnet ,
transport: http ( 'https://rpc.moderato.tempo.xyz' )
})
Get Token Balance
Query TIP-20 token balances:
import { tip20Abi } from 'tempo-viem/abis'
const balance = await client . readContract ({
address: '0x20c0000000000000000000000000000000000001' , // AlphaUSD
abi: tip20Abi ,
functionName: 'balanceOf' ,
args: [ '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEbb' ]
})
Send Transfer
Send a TIP-20 token transfer:
import { createWalletClient , parseUnits } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
const account = privateKeyToAccount ( '0x...' )
const wallet = createWalletClient ({
account ,
chain: tempoTestnet ,
transport: http ( 'https://rpc.moderato.tempo.xyz' )
})
const hash = await wallet . writeContract ({
address: '0x20c0000000000000000000000000000000000001' ,
abi: tip20Abi ,
functionName: 'transfer' ,
args: [
'0x742d35Cc6634C0532925a3b844Bc9e7595f0bEbb' ,
parseUnits ( '100' , 6 ) // 100 tokens with 6 decimals
]
})
const receipt = await client . waitForTransactionReceipt ({ hash })
TIP-20 Tokens
Transfer with Memo
Include reconciliation data in transfers:
import { stringToHex , padHex } from 'viem'
const memo = padHex ( stringToHex ( 'INV-12345' ), { size: 32 })
const hash = await wallet . writeContract ({
address: '0x20c0000000000000000000000000000000000001' ,
abi: tip20Abi ,
functionName: 'transferWithMemo' ,
args: [
'0x742d35Cc6634C0532925a3b844Bc9e7595f0bEbb' ,
parseUnits ( '100' , 6 ),
memo
]
})
Watch Transfer Events
Listen for incoming transfers:
const unwatch = client . watchContractEvent ({
address: '0x20c0000000000000000000000000000000000001' ,
abi: tip20Abi ,
eventName: 'Transfer' ,
onLogs : ( logs ) => {
logs . forEach (( log ) => {
console . log ( `Transfer: ${ log . args . from } -> ${ log . args . to } : ${ log . args . value } ` )
})
}
})
Filter by Recipient
Watch transfers to a specific address:
const unwatch = client . watchContractEvent ({
address: '0x20c0000000000000000000000000000000000001' ,
abi: tip20Abi ,
eventName: 'Transfer' ,
args: {
to: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEbb'
},
onLogs : ( logs ) => {
console . log ( 'Received payment:' , logs )
}
})
Batch Payments
Send multiple transfers atomically:
import { tempoTransactionType } from 'tempo-viem'
// Create multiple transfer calls
const calls = [
{
to: '0x20c0000000000000000000000000000000000001' ,
data: encodeFunctionData ({
abi: tip20Abi ,
functionName: 'transfer' ,
args: [ '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEbb' , parseUnits ( '100' , 6 )]
})
},
{
to: '0x20c0000000000000000000000000000000000001' ,
data: encodeFunctionData ({
abi: tip20Abi ,
functionName: 'transfer' ,
args: [ '0x70997970C51812dc3A010C7d01b50e0d17dc79C8' , parseUnits ( '50' , 6 )]
})
}
]
const hash = await wallet . sendTransaction ({
type: tempoTransactionType ,
calls ,
maxFeePerGas: parseGwei ( '20' ),
maxPriorityFeePerGas: parseGwei ( '1' )
})
Account Abstraction
Pay gas fees for users:
const hash = await wallet . sendTransaction ({
type: tempoTransactionType ,
calls: [ /* user's operations */ ],
feeToken: '0x20c0000000000000000000000000000000000001' , // Pay fees in AlphaUSD
from: sponsorAddress , // Sponsor's address
maxFeePerGas: parseGwei ( '20' ),
maxPriorityFeePerGas: parseGwei ( '1' )
})
Scheduled Payments
Set validity windows for transactions:
const now = Math . floor ( Date . now () / 1000 )
const oneHourLater = now + 3600
const hash = await wallet . sendTransaction ({
type: tempoTransactionType ,
calls: [ /* payment calls */ ],
validAfter: now ,
validBefore: oneHourLater ,
maxFeePerGas: parseGwei ( '20' ),
maxPriorityFeePerGas: parseGwei ( '1' )
})
Chain Configuration
The SDK includes pre-configured chain definitions:
import { tempoTestnet , tempoMainnet } from 'tempo-viem/chains'
// Testnet (Moderato)
console . log ( tempoTestnet )
// {
// id: 42431,
// name: 'Tempo Testnet',
// network: 'tempo-testnet',
// nativeCurrency: { name: 'USD', symbol: 'USD', decimals: 6 },
// rpcUrls: {
// default: { http: ['https://rpc.moderato.tempo.xyz'] }
// },
// blockExplorers: {
// default: { name: 'Tempo Explorer', url: 'https://explore.tempo.xyz' }
// }
// }
Available ABIs
The SDK exports typed ABIs for all Tempo precompiles:
import {
tip20Abi , // TIP-20 token interface
tip403Abi , // TIP-403 policy registry
feeAmmAbi , // Fee AMM for stablecoin gas
accountAbi // Smart account interface
} from 'tempo-viem/abis'
Error Handling
Handle Tempo-specific errors:
import { ContractFunctionExecutionError } from 'viem'
try {
const hash = await wallet . writeContract ({
address: tokenAddress ,
abi: tip20Abi ,
functionName: 'transfer' ,
args: [ recipient , amount ]
})
} catch ( error ) {
if ( error instanceof ContractFunctionExecutionError ) {
// Handle insufficient balance, blocked address, etc.
console . error ( 'Transfer failed:' , error . shortMessage )
}
}
TypeScript Support
The SDK is fully typed with automatic inference:
// Return types are automatically inferred
const balance : bigint = await client . readContract ({
address: '0x20c0000000000000000000000000000000000001' ,
abi: tip20Abi ,
functionName: 'balanceOf' ,
args: [ '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEbb' ]
})
// Event args are strongly typed
client . watchContractEvent ({
address: '0x20c0000000000000000000000000000000000001' ,
abi: tip20Abi ,
eventName: 'Transfer' ,
onLogs : ( logs ) => {
logs . forEach (( log ) => {
// log.args.from, log.args.to, log.args.value are all typed
})
}
})
Next Steps
Integration Guide Step-by-step integration walkthrough
TIP-20 Reference Complete TIP-20 token specification
Account Abstraction Learn about Tempo Transactions
Examples View complete code examples