Account Abstraction

Deploys a smart account for the user to interact with your app. The specified personal wallet will be the admin signer. For more information about Account Abstration, see the glossary.

Usage

using Thirdweb;
public async void ConnectWallet()
{
// Reference to your Thirdweb SDK
var sdk = ThirdwebManager.Instance.SDK;
// Configure the connection
var connection = new WalletConnection(
provider: WalletProvider.SmartWallet, // The wallet provider you want to connect to (Required)
chainId: 1, // The chain you want to connect to (Required)
password: "myEpicPassword", // If using a local wallet as personal wallet (Optional)
email: "[email protected]", // If using a personal wallet login option that requires email (Optional)
personalWallet: WalletProvider.LocalWallet // The personal wallet you want to use with your Smart Wallet (Optional)
);
// Connect the wallet
string address = await sdk.Wallet.Connect(connection);
}

Behavior

WebGL

Goes through the specified personalWallet login flow, then generates or connects a smart account based on that EOA address.

Standalone

Goes through the specified personalWallet login flow, then generates or connects a smart account based on that EOA address.

Mobile

Goes through the specified personalWallet login flow, then generates or connects a smart account based on that EOA address.

Miscellaneous

The ultimate goal of a smart account is to be able to sponsor gas fees for your users, while providing a signless and gasless experience.

They also work with any wallet provider as the EOA, but it is recommended to use a signless wallet, like In-App Wallets, for the best experience.

You would then be able to login to the exact same persistent EOA and smart account address across your apps, and even across different platforms.

You can also create session keys (revokable), allowing new signers to interact with the smart account without being the admin. You may also add/remove admins.

using Thirdweb;
// Reference to your Thirdweb SDK
var sdk = ThirdwebManager.Instance.SDK;
// Create a session key
string signerAddress = "0xSignerAddress";
List<string> approvedTargets = new List<string> { "0xTargetAddress" };
string nativeTokenLimitPerTransactionInWei = "0";
string permissionStartTimestamp = "0";
string permissionEndTimestamp = Utils.GetUnixTimestampIn10Years().ToString();
string reqValidityStartTimestamp = "0";
string reqValidityEndTimestamp = Utils.GetUnixTimestampIn10Years().ToString();
var createSessionResult = await sdk.Wallet.CreateSessionKey(
"0xSignerAddress",
approvedTargets,
nativeTokenLimitPerTransactionInWei,
permissionStartTimestamp,
permissionEndTimestamp,
reqValidityStartTimestamp,
reqValidityEndTimestamp
);
// Get a list of current signers with permission details
List<SignerWithPermissions> signers = await sdk.Wallet.GetAllActiveSigners();
// Revoke a session key
var revokeSessionResult = await sdk.Wallet.RevokeSessionKey("0xSignerAddress");
// Add admin
var addAdminResult = await sdk.Wallet.AddAdmin("0xSignerAddress");
// Remove admin
var removeAdminResult = await sdk.Wallet.RemoveAdmin("0xSignerAddress");
// These features pair well with the `smartWalletAccountOverride` option to connect to a specific smart wallet
var connection = new WalletConnection(
...options,
smartWalletAccountOverride: "0xSmartWalletAddress"
);
var address = await sdk.Wallet.Connect(connection);

ZkSync Support

ZkSync chains make use of native account abstraction, whereby the user's EOA is the smart account. We support this as well.

The only difference is that no account factory or additional parameters are needed, simply set gasless to true, connect to ZkSync with a SmartWallet provider, and you're good to go.

Additional Options

Smart accounts, through paymasters, can be seen as a "plugin" to your user wallets, whereby all gas fees can be sponsored onchain. To enable this, simply set the gasless option to true in your ThirdwebManager prefab.

All smart accounts are deployed through an Account Factory, which is a contract that deploys smart accounts on behalf of your users. You would need to set this address in your ThirdwebManager prefab's settings as well.