> ## Documentation Index
> Fetch the complete documentation index at: https://www.dynamic.xyz/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Sign for a fee sponsor

> Sign a Tempo transaction with an embedded wallet so that a sponsor signs it afterwards and pays the fee, using signTempoTransaction and awaitingFeePayer

A fee sponsor pays the fee for a transaction that someone else sends. On Tempo, the sender signs first and the sponsor signs the same transaction afterwards. `signTempoTransaction` from `@dynamic-labs-sdk/tempo/waas` produces the sender's half: it signs with an embedded Tempo wallet and returns the signed transaction without broadcasting it.

<Note>
  The SDK signs for the sender only. Your app provides the sponsor that adds its signature and broadcasts the transaction. This guide covers the sender's side.
</Note>

## Sign a transaction that awaits a fee payer

Set `awaitingFeePayer` to `true`. The wallet signs the transaction as one whose fee a sponsor will pay, and the function returns the serialized signed transaction in `signedTransaction`.

```typescript theme={"system"}
import type { TempoWalletAccount } from '@dynamic-labs-sdk/tempo';
import { signTempoTransaction } from '@dynamic-labs-sdk/tempo/waas';
import { encodeFunctionData, erc20Abi, parseUnits } from 'viem';

const signForSponsor = async (walletAccount: TempoWalletAccount) => {
  const { signedTransaction } = await signTempoTransaction({
    awaitingFeePayer: true,
    calls: [
      {
        data: encodeFunctionData({
          abi: erc20Abi,
          args: ['0xRecipientAddress...', parseUnits('1.5', 6)],
          functionName: 'transfer',
        }),
        to: '0xTip20TokenAddress...',
      },
    ],
    walletAccount,
  });

  return signedTransaction;
};
```

Send `signedTransaction` to your sponsor service. It is a signed Tempo transaction that still needs the fee payer's signature, so it cannot be broadcast as it is.

## Parameters

`signTempoTransaction` accepts the same Tempo fields as [`sendTempoTransaction`](/docs/javascript/reference/tempo/overview#send-a-tempo-transaction), plus `awaitingFeePayer`.

| Parameter | Type | Description |
| - | - | - |
| `walletAccount` | `WalletAccount` | The embedded Tempo wallet that signs. |
| `awaitingFeePayer` | `true` (optional) | Leaves the fee to a sponsor who signs afterwards. Cannot be combined with `feeToken`. |
| `calls` | `readonly TempoTransactionCall[]` | The calls the transaction executes atomically. Each call takes `to`, `data`, and `value`. |
| `feeToken` | `Hex` (optional) | The TIP-20 token address that pays the fee. Leave it out when `awaitingFeePayer` is set. |
| `gas` | `bigint` (optional) | The gas limit. Defaults to a buffered estimate, and the SDK uses the larger of your value and its estimate. |
| `nonceKey` | `bigint` (optional) | Selects a parallel nonce lane. See [Use parallel nonce lanes](/docs/javascript/reference/tempo/use-parallel-nonce-lanes). |
| `validAfter` | `number` (optional) | A Unix timestamp in seconds. The transaction is not valid before this time. |
| `validBefore` | `number` (optional) | A Unix timestamp in seconds. The transaction expires after this time. See [Set a validity window](/docs/javascript/reference/tempo/set-a-validity-window). |

Leave `awaitingFeePayer` out and `signTempoTransaction` returns a signed transaction that the sender pays for, which you can broadcast yourself.

### Returns

`Promise<{ signedTransaction: string }>`. The value is the serialized signed transaction. Nothing is sent to the network.

## Rules

The sponsor chooses the fee token, so a transaction that awaits a fee payer cannot name one. Passing `awaitingFeePayer` together with `feeToken` throws `TempoTransactionValidationError` before the wallet signs, and so does an `awaitingFeePayer` value other than `true`.

A transaction that awaits a fee payer cannot be broadcast by the sender. `sendTempoTransaction` throws `TempoTransactionValidationError` when `awaitingFeePayer` is set, and so does the viem `sendTransaction` of the Tempo wallet client. Use `signTempoTransaction` for these transactions.

<Tip>
  Set `validBefore` on a transaction you hand to a sponsor. If the sponsor does not sign and broadcast it in time, it expires instead of staying valid indefinitely.
</Tip>

## Errors

| Error | When it is thrown |
| - | - |
| `InvalidParamError` | The wallet account is not an embedded Tempo wallet account. |
| `TempoTransactionValidationError` | A field is malformed or inconsistent, for example `awaitingFeePayer` combined with `feeToken`. |

## Related

* [Pay fees with a TIP-20 token](/docs/javascript/reference/tempo/pay-fees-with-a-token) covers the case where the sender pays the fee.
* [Tempo](/docs/javascript/reference/tempo/overview) covers setup, transfers, and `sendTempoTransaction`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.