Skip to main content
Integrate Para’s embedded wallets with thirdweb for smart accounts, gas sponsorship, and in-app payments. The useThirdwebSmartAccount hook handles Para signer creation, smart wallet setup, and gas sponsorship configuration automatically — supporting both EIP-4337 and EIP-7702 modes.

Prerequisites

Installation

npm install @getpara/react-sdk viem @tanstack/react-query

Add your keys to .env.local

NEXT_PUBLIC_THIRDWEB_CLIENT_ID=your_thirdweb_client_id
NEXT_PUBLIC_PARA_API_KEY=your_para_api_key

Setup Para Provider

"use client";

import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { ParaProvider } from "@getpara/react-sdk";

const queryClient = new QueryClient();

export default function Providers({ children }: { children: React.ReactNode }) {
  return (
    <QueryClientProvider client={queryClient}>
      <ParaProvider
        paraClientConfig={{
          apiKey: process.env.NEXT_PUBLIC_PARA_API_KEY!,
          env: "BETA",
        }}
        config={{ appName: "My App" }}
      >
        {children}
      </ParaProvider>
    </QueryClientProvider>
  );
}

Usage

Use the useThirdwebSmartAccount hook to create and manage a thirdweb smart account. The hook handles Para signer creation, smart wallet setup, and gas sponsorship configuration internally.
"use client";

import { useThirdwebSmartAccount } from "@getpara/react-sdk";
import { useMutation } from "@tanstack/react-query";
import { sepolia } from "viem/chains";
import { parseEther } from "viem";

const THIRDWEB_CLIENT_ID = process.env.NEXT_PUBLIC_THIRDWEB_CLIENT_ID!;

export function ThirdwebDemo() {
  const { smartAccount, isLoading, error } = useThirdwebSmartAccount({
    clientId: THIRDWEB_CLIENT_ID,
    chain: sepolia,
    sponsorGas: true,   // enable gas sponsorship (default)
    mode: "4337",       // or "7702"
  });

  const {
    mutate: sendTransaction,
    isPending: isSending,
    error: sendError,
  } = useMutation({
    mutationFn: async () => {
      if (!smartAccount) throw new Error("Smart account not ready");
      return smartAccount.sendTransaction({
        to: "0xRecipient",
        value: parseEther("0.01"),
      });
    },
    onSuccess: (receipt) => {
      console.log("Transaction hash:", receipt.transactionHash);
    },
  });

  const {
    mutate: sendBatch,
    isPending: isBatching,
    error: batchError,
  } = useMutation({
    mutationFn: async () => {
      if (!smartAccount) throw new Error("Smart account not ready");
      return smartAccount.sendBatchTransaction([
        { to: "0xRecipientA", value: parseEther("0.01") },
        { to: "0xRecipientB", data: "0xencodedCallData" },
      ]);
    },
    onSuccess: (receipt) => {
      console.log("Batch tx hash:", receipt.transactionHash);
    },
  });

  if (isLoading) return <p>Setting up smart account...</p>;
  if (error) return <p>Error: {error.message}</p>;
  if (!smartAccount) return null;

  return (
    <div>
      <h2>thirdweb Smart Account</h2>
      <p>Address: {smartAccount.smartAccountAddress}</p>
      <p>Mode: {smartAccount.mode}</p>

      <button onClick={() => sendTransaction()} disabled={isSending}>
        {isSending ? "Sending..." : "Send Transaction"}
      </button>
      {sendError && <p style={{ color: "red" }}>{sendError.message}</p>}

      <button onClick={() => sendBatch()} disabled={isBatching}>
        {isBatching ? "Batching..." : "Send Batch"}
      </button>
      {batchError && <p style={{ color: "red" }}>{batchError.message}</p>}
    </div>
  );
}

Key Features

  • Dual mode support: Choose between EIP-4337 (smart wallets via bundler) or EIP-7702 (EOA delegation)
  • Built-in gas sponsorship: Enable sponsorGas: true for gasless transactions
  • Transaction batching: Send multiple transactions atomically via sendBatchTransaction
  • Para wallet management: Embedded wallet infrastructure with MPC security

Next Steps

thirdweb Documentation

Explore thirdweb’s smart wallet features and SDK documentation

Account Abstraction Guide

See all supported AA providers and the unified SmartAccount interface