Account abstraction

Let users connect to their smart accounts with any wallet and unlock gas sponsorship, batched transactions, session keys and full wallet programmability.

Connect smart accounts

Enable smart accounts on the UI components or build your own UI.

// Using UI components
import { ConnectButton } from "thirdweb/react";

function App() {
  return (
    <>
      <ConnectButton
        client={client}
        // account abstraction options
        accountAbstraction={{
          chain,
          sponsorGas: true,
        }}
      />
    </>
  );
}
// Using your own UI
import { useConnect } from "thirdweb/react";
import { createWallet } from "thirdweb/wallets";

function App() {
  const { connect } = useConnect({
    client,
    // account abstraction options
    accountAbstraction: {
      chain,
      sponsorGas: true,
    },
  });

  return (
    <>
      <button
        onClick={() =>
          connect(async () => {
            // any wallet connected here will be
            // converted to a smart account
            const adminWallet = createWallet(
              "io.metamask",
            );
            await adminWallet.connect({ client });
            return adminWallet;
          })
        }
      >
        Connect (metamask)
      </button>
    </>
  );
}

Sponsored transactions

Set `sponsorGas: true` to enable gas-free transactions for your users.
Free on testnets, billed at the end of the month on mainnets.

import { claimTo } from "thirdweb/extensions/erc1155";
import { TransactionButton } from "thirdweb/react";

function App() {
  return (
    <>
      {/* transactions will be sponsored */}
      <TransactionButton
        transaction={() =>
          claimTo({
            contract,
            to: "0x123...",
            tokenId: 0n,
            quantity: 1n,
          })
        }
      >
        Mint
      </TransactionButton>
    </>
  );
}
Loading...