thirdwebPlayground
Account Abstraction

Account Abstraction EIP-5792

EIP-5792 brings a standard for abstracted actions—combine transaction batching, bundling, and paymasters with a unified smart account interface

Documentation

Getting the wallet capabilities

Get the capabilities of the connected wallet using the useCapabilities hook

Code
import { useCapabilities } from "thirdweb/react";

function App() {
  // requires a connected wallet
  // try metamask or coinbase wallet to view their capabilities
  // works with in-app wallets too!
  const capabilities = useCapabilities();
  console.log(capabilities);

  return (
    <div>Capabilities: {JSON.stringify(capabilities)}</div>
  );
}
Preview

Sending calls to the wallet

Send batched calls to the connected wallet using the useSendCalls hook

Code
import {
  useSendCalls,
  useWaitForCallsReceipt,
} from "thirdweb/react";

function App() {
  const {
    mutate: sendCalls,
    isPending,
    data,
  } = useSendCalls();
  const { data: receipt, isLoading: isConfirming } =
    useWaitForCallsReceipt(data);

  const handleClick = async () => {
    sendCalls({
      calls: [firstTransaction, secondTransaction],
    });
  };

  return (
    <>
      <button onClick={handleClick}>Send calls</button>
      {isPending && <p>Sending...</p>}
      {isConfirming && <p>Confirming...</p>}
      {receipt && (
        <p>
          Confirmed!{" "}
          {receipt?.receipts?.[0]?.transactionHash}
        </p>
      )}
    </>
  );
}
Preview