Skip to content
Alchemy Logo

Tempo API Quickstart

How to get started building on Tempo using Alchemy

Don't have an API key?

Build faster with production-ready APIs, smart wallets and rollup infrastructure across 70+ chains. Create your free Alchemy API key and get started today.

Tempo is a general-purpose blockchain optimized for payments. Tempo is designed to be a low-cost, high-throughput blockchain with user and developer features core to a modern payment system.

The Tempo API provides interaction with the Tempo network through a set of JSON-RPC methods. If you've worked with Ethereum's JSON-RPC APIs, you'll find the interface familiar.

Let's use the viem package to create a Tempo client connected to Alchemy and fetch the latest block number!

npm install --save viem

import { createPublicClient, http } from "viem";
import { tempoModerato } from "viem/chains";
 
const client = createPublicClient({
  chain: tempoModerato,
  transport: http("https://tempo-moderato.g.alchemy.com/v2/YOUR_ALCHEMY_API_KEY"),
});

Tempo chain support requires viem 2.44.2 or later. For Tempo Mainnet, use the tempo chain from viem/chains with your tempo-mainnet URL.

Now that you've created a client connected to Alchemy, you can continue with some basics:

const blockNumber = await client.getBlockNumber();
console.log("Current block number:", blockNumber);

Tempo has no native gas token, so eth_getBalance returns a placeholder value, not a real balance. Read balances from TIP-20 tokens instead. This example reads the pathUSD balance of an address:

import { erc20Abi, formatUnits } from "viem";
 
const PATH_USD = "0x20c0000000000000000000000000000000000000"; // pathUSD (TIP-20, 6 decimals)
 
const balance = await client.readContract({
  address: PATH_USD,
  abi: erc20Abi,
  functionName: "balanceOf",
  args: ["0xab5801a7d398351b8be11c439e05c5b3259aec9b"],
});
console.log("Balance (pathUSD):", formatUnits(balance, 6));

You can also use the Token API method alchemy_getTokenBalances to fetch an address's TIP-20 balances. It returns up to 100 balances per call, so use pageKey to page through the rest.

const block = await client.getBlock({
  blockNumber: blockNumber, // from previous example
});
console.log(block);

const tx = await client.getTransaction({ hash: "0xYOUR_TX_HASH" });
console.log(tx);

const receipt = await client.getTransactionReceipt({
  hash: "0xYOUR_TX_HASH"
});
console.log(receipt);

For the full list of Tempo APIs, see the Tempo API Endpoints.

Was this page helpful?