Docs

Enable Gasless Transactions

By combining Account abstraction and In-App Wallet, you can create a truly seamless user experience:

  • Gasless transactions
  • Batched transactions
  • Full account recovery the user "account"

Let's create an app that creates smart accounts for our users.

These smart accounts will require a “personal wallet” to access and initialize the wallet. For this personal wallet, we will of course use an in-app wallet.

From the user's perspective, they will log in with their email or social account. Under the hood, an in-app wallet is created for them, and then a smart account is created and initialized using the in-app wallet.

When the user connects a wallet by entering their email, they will be able to view & interact with their smart account:

Example Repo

View a fully functioning project on GitHub:

Source Code

Source Code is open-source. View and contribute to its source code on GitHub.

1. Deploy an Account Factory

Deployable via the explore page or build your own ERC 4337 compatible factory contract using the Solidity SDK.

Select the appropriate thirdweb account factory type for your app:

Learn more about Account abstraction here

2. Enable account abstraction in your app

To enable account abstraction in your app, you need to add the accountAbstraction prop to the ConnectButton or ConnectEmbed component.

import { ConnectButton } from "thirdweb/react";
import { inAppWallet } from "thirdweb/wallets";
const wallets = [inAppWallet()];
export default function App() {
return (
<ThirdwebProvider>
<ConnectButton
client={client}
wallets={wallets}
accountAbstraction={{
factoryAddress: "0x...", // your factory address
chain: sepolia, // your chain
gasless: true,
}}
/>
</ThirdwebProvider>
);
}

This will create an in-app wallet and a smart account for the user. The smart account will be initialized with the in-app wallet as the owner.

Pass your deployed factoryAddress to the accountAbstraction prop. This will allow the smart account to be be deployed only when the user sends their first transaction.

You can sponsor transactions simply by passing gasless: true to the accountAbstraction prop. This will allow the smart account to send transactions without the user needing to hold any ETH.