Docs

SmartWallet.Create

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(client, personalWallet, factoryAddress, gasless, chainId, accountAddressOverride, entryPoint, bundlerUrl, paymasterUrl);

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 = 1; // Ethereum mainnet
string factoryAddress = "0xFactoryContractAddress";
bool gasless = true; // Enable gasless transactions
var smartWallet = await SmartWallet.Create(
client,
personalWallet,
factoryAddress,
gasless,
chainId,
null, // Optional: accountAddressOverride
"0xEntryPointAddress", // Optional: entryPoint
null, // Optional: bundlerUrl
null // Optional: paymasterUrl
);
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}");

Note: This documentation covers the setup of a SmartWallet for advanced blockchain interactions. The optional gasless feature, powered by account abstraction, can significantly enhance the user experience by abstracting away the complexities of gas fees.