Skip to main content

Getting Started

Getting started to add ERC-4337 smart wallet support to your application easily.

Once set, your application will:

  • Let users connect to their smart wallet using any personal wallet, including email and local wallets for easy onboarding.
  • Automatically deploy individual account contracts for your users when they do their first on-chain transaction.
  • Handle all transaction gas costs via the thirdweb paymaster.

1. Smart Wallet Factory Contract

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

Choose the right smart wallet setup for your app. thirdweb offers the following three different kinds of smart wallets:

2. An API key

You will require an API key to use thirdweb's infrastructure services such as the bundler and paymaster.

Obtain an API key from the thirdweb dashboard Settings page.

The API key lets you access thirdweb's bundler and paymaster infrastructure, which is required for the smart wallet to operate and optionally enable gasless transactions.

The API key will need to have the following settings:

  • smart wallet as an enabled service
  • The contracts that the smart wallet will interact with must be added to the "Destination Contracts" list. Learn more here

Learn more about creating an API key and restricting which contracts the smart wallet can interact with here.

3. Connecting & Creating Smart Wallets in an Application

Use the following code to integrate smart wallets into your apps. This will:

  • Connect your users to their smart wallet based on their personal wallet (can be any wallet, including email or local wallets).
  • Automatically deploy the individual account contracts for your users when they do their first on-chain transaction.
  • Handle all transaction gas costs via the thirdweb paymaster.
  • Select your deployed account factory and client ID to get use the thirdweb infrastructure.
Gasless Transactions

To setup gasless transactions, set the gasless option to true in the smart wallet configuration. All transactions performed with the smart wallet will then be gasless.

import { ThirdwebProvider, ConnectWallet, smartWallet, metamaskWallet, embeddedWallet } from "@thirdweb-dev/react";
const config = { factoryAddress: "0x...", gasless: true };
export default function App() {
return (
<ThirdwebProvider
clientId="YOUR_CLIENT_ID"
activeChain="goerli"
supportedWallets={[
smartWallet(metamaskWallet(), config),
smartWallet(embeddedWallet(), config)
]}
>
<ConnectWallet />
</ThirdwebProvider>
);
}

Using a Template

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

4. Executing Transactions with Smart Wallets

Once setup, you can use the thirdweb TypeScript, React, React Native and Unity SDKs to deploy contracts, perform transactions, and manipulate wallets like any other wallet.

import { ThirdwebSDK } from "@thirdweb-dev/sdk";
// Simply initialize your SDK with the created smart wallet
const sdk = await ThirdwebSDK.fromWallet(smartWallet, "goerli", {
clientId: "YOUR_CLIENT_ID"
});
// You can now interact with the blockchain as you would with a regular EOA
const smartWalletAddress = await sdk.wallet.getAddress();
// gas free wallet actions
await sdk.wallet.transfer("0x...", "0.01");
// gas free contract deployments
const contractAddress = await sdk.deployer.deployNFTCollection({
name: "My NFT Collection",
primary_sale_recipient: smartWalletAddress
});
// gas free contract interactions
const contract = await sdk.getContract(contractAddress);
await contract.erc721.mint({
name: "My NFT",
description: "My NFT description",
image: "https://example.com/image.png",
});