Skip to main content

Managed Account Factory

The Managed Account Factory contract is used to deploy upgradeable ERC-4337 smart wallets with role based permission control.

The ManagedAccount smart wallet is an upgradeable smart contract written in the dynamic contract pattern.

App developers can issue ManagedAccount smart wallets programmatically by deploying a ManagedAccountFactory smart contract.

The admin of the ManagedAccountFactory contract can push upgrades to all ManagedAccounts that it creates. This admin does not require any permissions on the ManagedAccount smart wallets to do so. An upgrade to the features of ManagedAccount applies to all ManagedAccount smart wallets created by the factory. This is the right wallet for developers who anticipate pushing upgrades to their users' wallets.

thirdweb's smart wallets have the following features by default:

  • Have multiple signers with different permissions
  • Execute transactions (single and batched).
  • Send and receive native tokens.
  • Send and receive ERC-721 and ERC-1155 NFTs.
  • Multicall-able.
  • Store contract metadata.

Extensions

This contract includes the following extensions:

Use Cases & Examples

Use the ManagedAccountFactory contract alongside the SmartWallet connector or ConnectWallet to easily use account abstraction in your projects:

Connect Wallet

import {
smartWallet,
metamaskWallet,
coinbaseWallet,
walletConnect,
} from "@thirdweb-dev/react";

const config = {
factoryAddress: "0x...",
gasless: true,
}

<ThirdwebProvider
supportedWallets={[
smartWallet(metamaskWallet(), config),
smartWallet(coinbaseWallet(), config),
smartWallet(walletConnect(), config),
]}
clientId="your-client-id"
>
<YourApp />
</ThirdwebProvider>
import { ConnectWallet } from "@thirdweb-dev/react";

// render ConnectWallet button wherever you want

function App() {
return (
<div>
<ConnectWallet />
</div>
);
}

TypeScript

import { LocalWallet, SmartWallet } from "@thirdweb-dev/wallets";
import { Goerli } from "@thirdweb-dev/chains";

// First, connect the personal wallet, which can be any wallet (metamask, walletconnect, etc.)
// Here we're just generating a new local wallet which can be saved later
const personalWallet = new LocalWallet();
await personalWallet.generate();

// Setup the Smart Wallet configuration
const config: SmartWalletConfig = {
chain: Goerli, // the chain where your smart wallet will be or is deployed
factoryAddress: "{{factory_address}}", // your own deployed account factory address
clientId: "YOUR_CLIENT_ID", // Use client id if using on the client side, get it from dashboard settings
secretKey: "YOUR_SECRET_KEY", // Use secret key if using on the server, get it from dashboard settings
gasless: true, // enable or disable gasless transactions
};

// Then, connect the Smart wallet
const wallet = new SmartWallet(config);
await wallet.connect({
personalWallet,
});

// You can then use this wallet to perform transactions via the SDK
const sdk = await ThirdwebSDK.fromWallet(wallet, Goerli);

Templates

Clone these templates to quickly deploy Smart Wallets and connect to them.