> ## 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.

# Send a Transaction

> [card] Recommended: JavaScript SDK with React Hooks
>
> For new React apps, we recommend the JavaScript SDK with React Hooks (`@dynamic-labs-sdk/react-hooks`) instead of the legacy React SDK documented here. The JS SDK comes with many benefits such as a much smaller bundle size and other optimizations. Use the [React quickstart (JavaScript SDK)](https://www.dynamic.xyz/docs/javascript/reference/react-quickstart.md) to get started.

In this example, we'll show how to send a transaction on Tempo. Since Tempo has no native token, all transactions pay fees in TIP-20 stablecoins.

```tsx theme={"system"}
import { FC, useState } from 'react';
import { useDynamicContext } from '@dynamic-labs/sdk-react-core';
import { isTempoWallet } from '@dynamic-labs/tempo';
import { encodeFunctionData, erc20Abi, Hex } from 'viem';

const SendTransactionButton: FC = () => {
  const { primaryWallet } = useDynamicContext();
  const [txHash, setTxHash] = useState<string | null>(null);

  const onSendTransaction = async () => {
    if (!primaryWallet || !isTempoWallet(primaryWallet)) {
      throw new Error('Tempo wallet not found');
    }

    const publicClient = await primaryWallet.getPublicClient();
    const walletClient = await primaryWallet.getWalletClient();

    const fromAddress = primaryWallet.address as Hex;
    const toAddress = '0x...' as Hex; // recipient address
    const tokenAddress = '0x...' as Hex; // TIP-20 token to transfer
    const feeTokenAddress = '0x...' as Hex; // TIP-20 token for gas fees
    const amount = BigInt(1000000); // amount in base units

    // Encode the transfer call
    const callData = encodeFunctionData({
      abi: erc20Abi,
      functionName: 'transfer',
      args: [toAddress, amount],
    });

    // Get nonce
    const nonce = await publicClient.getTransactionCount({
      address: fromAddress,
    });

    // Estimate gas with 30% buffer
    const gasEstimate = await publicClient.estimateGas({
      account: fromAddress,
      data: callData,
      to: tokenAddress,
    });
    const gas = (gasEstimate * BigInt(130)) / BigInt(100);

    // Get gas price
    const gasPrice = await publicClient.getGasPrice();

    // Build Tempo transaction with fee token
    const tempoTx = {
      calls: [
        {
          data: callData,
          to: tokenAddress,
          value: BigInt(0),
        },
      ],
      chainId: await publicClient.getChainId(),
      gas,
      maxFeePerGas: gasPrice,
      maxPriorityFeePerGas: gasPrice / BigInt(10),
      nonce,
      feeToken: feeTokenAddress,
    };

    // Sign and send the transaction
    const hash = await walletClient.sendTransaction(tempoTx);
    setTxHash(hash);

    console.log('Transaction hash:', hash);
  };

  return (
    <div>
      <button onClick={onSendTransaction}>Send Transaction</button>
      {txHash && <p>Transaction: {txHash}</p>}
    </div>
  );
};
```

## Transaction Parameters

| Parameter | Type | Required | Description |
| - | - | - | - |
| `calls` | `Array` | Yes | Array of call objects with `to`, `data`, and `value` |
| `chainId` | `number` | Yes | The Tempo chain ID (4217 for mainnet, 42431 for testnet) |
| `gas` | `bigint` | Yes | Gas limit for the transaction |
| `maxFeePerGas` | `bigint` | Yes | Maximum fee per gas unit |
| `maxPriorityFeePerGas` | `bigint` | Yes | Maximum priority fee per gas unit |
| `nonce` | `number` | Yes | Transaction nonce |
| `feeToken` | `Hex` | No | TIP-20 token address to pay gas fees (defaults to network stablecoin) |


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