Native Account Abstraction (via EIP-7702 Smart EOAs)

With the recent Ethereum upgrade Pectra, EIP-7702 allows you to upgrade your EOA and get SmartWallet-like functionality with:

  • Much cheaper gas costs, batching functionality
  • No account separation - your wallet address does not change, not even on zksync chains (once they implement EIP-7702)
  • Much faster execution, with the option of paying for gas yourself or having thirdweb manage gas sponsorship, similar to SmartWallet.

The API is also drastically simplified!

ExecutionMode.EIP7702Sponsored

Upgrade to an EIP7702 smart account, unlocking all functionality of 4337 without the downsides, and thirdweb handles the execution and gas sponsorship for you!

var smartEoa = await InAppWallet.Create(
client: thirdwebClient,
authProvider: AuthProvider.Google,
executionMode: ExecutionMode.EIP7702Sponsored
);

ExecutionMode.EIP7702

Upgrade to an EIP7702 smart account, unlocking all functionality of 4337 without the downsides, but sponsoring gas yourself.

var smartEoa = await InAppWallet.Create(
client: thirdwebClient,
authProvider: AuthProvider.Google,
executionMode: ExecutionMode.EIP7702
);

ExecutionMode.EOA

"Normal" EOA Execution, no smart account functionality

var basicEoa = await InAppWallet.Create(
client: thirdwebClient,
authProvider: AuthProvider.Google,
// does not need to be explicitly passed, is the default but we're showing it here
executionMode: ExecutionMode.EOA
);

When using EIP-7702 execution modes - if not already delegated to a smart account - an EIP-7702 authorization will be signed and bundled with your first transaction, similar to how 4337 works with initcode, but without the large gas costs, slower execution and chain specific requirements.

SmartWallet (via EIP-4337 Bundlers)

Instantiate a SmartWallet to enable advanced blockchain interactions, including gasless transactions through account abstraction. This wallet type is especially useful for creating a user-friendly experience in decentralized applications.

Usage

var smartWallet = await SmartWallet.Create(personalWallet, chainId);

Example

Here's how you can create a SmartWallet for a user, assuming you already have a ThirdwebClient and a personal wallet (PrivateKeyWallet or InAppWallet) set up:

var client = ThirdwebClient.Create(clientId: "yourClientId", bundleId: "yourBundleId");
var personalWallet = await PrivateKeyWallet.Create(client, "yourPrivateKeyHex");
BigInteger chainId = 137; // Polygon mainnet
bool gasless = true; // Enable gasless transactions
var smartWallet = await SmartWallet.Create(
personalWallet,
gasless,
);
Console.WriteLine($"SmartWallet address: {await smartWallet.GetAddress()}");
// Sign a message (this will also deploy your smart wallet if it hasn't been deployed yet)
var message = "Hello, Thirdweb!";
var signature = await wallet.PersonalSign(message);
Console.WriteLine($"Signature: {signature}");