# Getting Started

## Overview

[Tempo](https://tempo.xyz) is a purpose-built Layer 1 blockchain optimized for payments.

It enshrines features like [token management](https://docs.tempo.xyz/protocol/tip20/overview), [Fee AMM](https://docs.tempo.xyz/protocol/fees), and a [stablecoin DEX](https://docs.tempo.xyz/protocol/exchange) directly into the protocol, as well as a [Tempo transaction type](https://docs.tempo.xyz/protocol/transactions) 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.

::::steps
### Install

To use the Tempo extension, ensure that you have Viem installed.

:::code-group
```bash [npm]
npm i viem
```

```bash [pnpm]
pnpm i viem
```
:::

### Configure

Next, we will configure a [Viem Client](/docs/clients/custom).

In the snippet below, we create a Tempo Client with `createClient`. It defaults to the
Tempo mainnet chain and an `http` transport, and comes preconfigured with `tempoActions`.

```ts twoslash [viem.config.ts] 
// [!include ~/snippets/tempo/viem.config.ts:setup]
```

:::tip
`createClient` also accepts Tempo options like `testnet` to target the Tempo testnet and
`feeToken` to set a default fee token for every transaction.

```ts
import { createClient } from 'viem/tempo'

export const client = createClient({
  feeToken: '0x20c0000000000000000000000000000000000001', // [!code hl]
  testnet: true, // [!code hl]
})
```
:::

### 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](https://docs.tempo.xyz/protocol/transactions#properties)
like `calls` (batch transactions), `feePayer` (fee sponsorship), `nonceKey` (concurrent transactions) and more!

:::code-group
```ts twoslash [example.ts]
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,
})
```

```ts twoslash [viem.config.ts] filename="viem.config.ts"
// [!include ~/snippets/tempo/viem.config.ts:setup]
```
:::

:::tip
[See all Viem Actions](/docs/actions/public/introduction)
:::

### Use Tempo Actions

You can also use [Tempo-specific Actions](/tempo/actions):

:::code-group
```ts twoslash [example.ts]
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.logoURI,
  metadata.decimals,
  metadata.totalSupply
)
// @log: Alpha USD Metadata: Alpha USD, AlphaUSD, https://example.com/token.svg, 6, 1000000000000000000000n
```

```ts twoslash [viem.config.ts] filename="viem.config.ts"
// [!include ~/snippets/tempo/viem.config.ts:setup]
```
:::

:::tip
[See all Tempo Actions](/tempo/actions)
:::

### Next Steps

After you have set up Tempo with Viem, you can now:

* Follow a guide on how to [use accounts](https://docs.tempo.xyz/guide/use-accounts), [make payments](https://docs.tempo.xyz/guide/payments), [issue stablecoins](https://docs.tempo.xyz/guide/issuance) and [exchange stablecoins](https://docs.tempo.xyz/guide/stablecoin-exchange).
* Use the [suite of Tempo Actions](/tempo/actions)
::::
