<!-- tempo-docs-context -->
> Source: [/docs/api/fee-payer](https://tempo.com/developers/docs/api/fee-payer.md)
> Section: [API reference](https://tempo.com/developers/docs/api.md). Tempo API reference: authentication, conventions, endpoints grouped by product, Console management endpoints, JSON-RPC, and the indexer. An API key authenticates API requests; an account signing key authorizes transactions.
> [Documentation index](https://tempo.com/developers/llms.txt) · [Docs skill](https://tempo.com/developers/SKILL.md)

> Tempo MCP: Use `search`, `find_pages`, `read_page`, and `code` at `https://mcp.tempo.xyz` for Tempo and related documentation.
> If an indexed page is missing or reflects an older site, read this site’s [documentation index](https://tempo.com/developers/llms.txt) and Markdown pages directly.

<span id="fee-payer-api" />

<span id="sponsor-user-fees-with-feepayer" />

# Sponsor your users' fees

Pay network fees for your users so they only hold the stablecoins they send.

## Fee sponsorship demo

Send a testnet payment whose fee Tempo's public fee payer covers.

**Interactive demo: Sponsor User Fees**

1. Connect
2. Add funds
3. Send relayer sponsored payment

<span id="get-started" />

<span id="configure-clients-for-hosted-fee-sponsorship" />

<span id="fee-sponsorship-implementation-steps" />

## Set up fee sponsorship

::::steps
<span id="set-up-organization" />

<span id="get-an-api-key" />

### Create an API key

Sign in to [Tempo Console](https://tempo.com/console?to=/\:org/projects), create an organization and project, add a payment method in [**Billing**](https://tempo.com/console?to=/\:org/billing), and create a key in [**API Keys**](https://tempo.com/console?to=/\:org/api-keys/new). Console shows the key once.

The key's environment picks the network. A production key (`tempo:sk:...`) sponsors mainnet transactions. A sandbox key (`tempo_sandbox:sk:...`) sponsors testnet transactions, and the examples on this page use one. Switch environments in the organization picker. To try sponsorship without a key, use the [public testnet fee payer](https://tempo.com/developers/docs/api/fee-payer#public-testnet-fee-payer).

<span id="hosted-fee-payer-endpoints" />

<span id="hosted-fee-payer-endpoint" />

### Point your client at the fee payer

The hosted fee payer is a JSON-RPC relay at `https://api.tempo.xyz/rpc/sponsor`. It fills, sponsors, and broadcasts Tempo Transactions. Pass your key in the `key` search parameter and wrap your transport with Viem's [`withRelay`](https://viem.sh/tempo/transports/withRelay).

:::code-group
```ts twoslash [Viem]
import { Account, createClient, http, withRelay } from 'viem/tempo'

const client = createClient({
  account: Account.fromSecp256k1('0x...'),
  testnet: true,
  transport: withRelay( // [!code focus]
    http(), // default transport // [!code focus]
    http('https://api.tempo.xyz/rpc/sponsor?key=tempo_sandbox:sk:...'), // relay transport // [!code focus]
  ), // [!code focus]
})
```

```ts twoslash [Wagmi (Tempo Wallet)]
// @noErrors
import { tempoModerato } from 'viem/chains'
import { createConfig, http } from 'wagmi'
import { tempoWallet } from 'wagmi/connectors'

export const config = createConfig({
  connectors: [tempoWallet({
    feePayer: 'https://sponsor.moderato.tempo.xyz', // [!code focus]
  })],
  chains: [tempoModerato],
  multiInjectedProviderDiscovery: false,
  transports: {
    [tempoModerato.id]: http(),
  },
})
```

```ts twoslash [Wagmi (WebAuthn)]
// @noErrors
import { tempoModerato } from 'viem/chains'
import { withRelay } from 'viem/tempo'
import { createConfig, http } from 'wagmi'
import { webAuthn } from 'wagmi/tempo'

export const config = createConfig({
  connectors: [webAuthn({ authUrl: '/auth' })],
  chains: [tempoModerato],
  multiInjectedProviderDiscovery: false,
  transports: {
    [tempoModerato.id]: withRelay( // [!code focus]
      http(), // [!code focus]
      http('https://sponsor.moderato.tempo.xyz'), // [!code focus]
    ), // [!code focus]
  },
})
```
:::

The Wagmi tabs run in the browser, so they use the keyless [public testnet fee payer](https://tempo.com/developers/docs/api/fee-payer#public-testnet-fee-payer). Never put an API key in browser code. For keyed or mainnet sponsorship, call the Fee Payer API from your own backend.

`withRelay` sends every `eth_fillTransaction` request to the relay, including self-paid ones. `withFeePayer` is deprecated.

<span id="sponsor-transaction-fees" />

### Send a sponsored transaction

Set `feePayer: true` on each transaction you want sponsored.

:::code-group
```ts [Viem]
const receipt = await client.sendTransactionSync({
  data: '0xdeadbeef',
  feePayer: true, // [!code focus]
  to: '0xcafebabecafebabecafebabecafebabecafebabe',
})
```

```tsx twoslash [React (Wagmi)]
import { Hooks } from 'wagmi/tempo'
import { getAddress, parseUnits } from 'viem'

const alphaUsd = '0x20c0000000000000000000000000000000000001'

// @noErrors
function SendSponsoredPayment() {
  const sendPayment = Hooks.token.useTransferSync() // [!code hl]

  return (
    <form onSubmit={
      (event) => {
        event.preventDefault()
        const formData = new FormData(event.target as HTMLFormElement)

        const recipient = getAddress(String(formData.get('recipient')))

        sendPayment.mutate({ // [!code hl]
          amount: parseUnits('100', 6), // [!code hl]
          feePayer: true, // [!code focus]
          to: recipient, // [!code hl]
          token: alphaUsd, // [!code hl]
        }) // [!code hl]
      }
    }>
      <div>
        <label htmlFor="recipient"> Recipient address </label>
        <input type="text" name="recipient" placeholder="0x..." required />
      </div>
      <button type="submit" disabled={sendPayment.isPending}>
        Send Payment
      </button>
    </form>
  )
}
```
:::

For mainnet, remove `testnet: true`, use a production key (`tempo:sk:...`), and activate production billing. Sandbox keys can't sponsor mainnet transactions.
::::

<span id="how-hosted-fee-sponsorship-works" />

## How the Fee Payer API works

The sender signs the transaction, and the fee payer separately signs the fee. The fee payer applies its policy, fills the fee fields, and reports whether it sponsored the request. Tempo supports this natively, so you don't need a paymaster contract, bundler, or EntryPoint contract.

A fee payer signs one specific transaction. Sponsorship doesn't grant authority over the sender's account. The [Tempo Transaction specification](https://tempo.com/developers/docs/protocol/transactions/spec-tempo-transaction#fee-payer-signature-details) lists the fields each signer commits to.

## Public testnet fee payer

For demos and testnet development without an API key, use `https://sponsor.moderato.tempo.xyz`. Use the hosted fee payer with a sandbox key for authenticated testing.

<span id="use-a-fee-payer-in-production" />

<span id="fee-sponsorship-best-practices" />

## Fee sponsorship limits

Decide who you sponsor, which contracts and methods you cover, per-user limits, and your total fee budget.

Sponsorship covers the network fee only. It doesn't fund the transfer amount, an FX spread, or a receiving provider's charges. Record the sponsored fee against each payment.

<span id="learn-more" />

## Related

[Choose a fee token](https://tempo.com/developers/docs/guide/payments/pay-fees-in-any-stablecoin): Covers paying fees in any supported stablecoin.

[Tempo API authentication](https://tempo.com/developers/docs/api/authentication): Covers production and sandbox API keys.

[Fee specification](https://tempo.com/developers/docs/protocol/fees/spec-fee): Covers how fees work on Tempo.
