Biconomy SDK
Search…
⌃K

User Onboarding & Smart Account Deployments

Your users can start their journey on your Dapp by connecting existing EOA signer they own or for Web2 users you can create this non-custodial EOA signer using social login flow. Once you have an EOA, follow below steps from SDK references to initialise smart account and get the address.
yarn add @biconomy/smart-account
// or
npm install @biconomy/smart-account
import {
ChainId
} from "@biconomy/core-types";
import SmartAccount from "@biconomy/smart-account";
// Get the EOA provider for choice of your wallet which manahes your signer
const { provider, address } = useWeb3AuthContext();
const walletProvider = new ethers.providers.Web3Provider(provider);
// Initialize the Smart Account
let options = {
activeNetworkId: ChainId.GOERLI,
supportedNetworksIds: [ ChainId.GOERLI, ChainId.POLYGON_MAINNET, ChainId.POLYGON_MUMBAI
]}
let smartAccount = new SmartAccount(walletProvider, options);
smartAccount = await smartAccount.init();
// Init
let smartAccount = new SmartAccount(walletProvider, options);
smartAccount = await smartAccount.init();
const address = smartAccount.address;
console.log('address', address);
Smart account address that SDK spins up are counter factual in nature and remains the same address on all EVM chains. You can securely transfer funds to this counterfactual address using transfer from Centralised exchange or via Fiat on-ramps.
These smart accounts are only deployed when users initiate a first transaction. Optionally as a Dapp you can just deploy the wallets and sponsor gas for it. Please check below flows.

Wallet Deployment flow

"Wallet deployment only" is supported using only gasless transactions where gas is sponsored via dApps using Paymasters (Gas Tanks). Users do not need to hold any assets to pay fees for this deployment.
Initialise Smart Account with appropriate config as mentioned here in gasless section.
// Assuming smart account has already been initialised
const tx = await smartAccount.deployWalletUsingPaymaster();
Note: above deploy wallet uses createSenderIfNeeded() from Entry point which merely calls Wallet Factory contract for deployment. One can also plug in a local relayer to make this transaction directly on wallet factory.

Wallet Deployment batched with a transaction

Any gasless or user paid transaction will check whether the wallet is deployed or not and batches the wallet deployment with intended transaction/batch transactions. The below diagram illustrates wallet deployment batched with the intended transaction, where the user first transfers assets in their smart account from which fees will be deduced (i.e dApp doesn't wish to sponsor).