Biconomy SDK Release 7
What's Changed
Smart Account Abstraction
Abstracted the smart account creation process to improve UX and reduce boilerplate code.
Example of creating a smart a smart account and sending user gasless user op.
Before
import { ethers } from "ethers";
import { BiconomySmartAccountV2, DEFAULT_ENTRYPOINT_ADDRESS} from "@biconomy/account";
import { Bundler } from "@biconomy/bundler";
import { BiconomyPaymaster } from "@biconomy/paymaster";
import { PaymasterMode } from "@biconomy/paymaster";
import {
DEFAULT_ECDSA_OWNERSHIP_MODULE,
ECDSAOwnershipValidationModule,
} from "@biconomy/modules";
let provider = new ethers.providers.JsonRpcProvider("rpcUrl");
let signer = new ethers.Wallet("private key", provider);
const bundler = new Bundler({
bundlerUrl: "bundler url",
chainId: 80001,
entryPointAddress: DEFAULT_ENTRYPOINT_ADDRESS,
});
const paymaster = new BiconomyPaymaster({
paymasterUrl: "paymaster url",
strictMode: false,
});
const ecdsaModule = await ECDSAOwnershipValidationModule.create({
signer: signer,
moduleAddress: DEFAULT_ECDSA_OWNERSHIP_MODULE,
});
const biconomySmartAccountConfig = {
signer: signer,
chainId: 80001,
paymaster: paymaster,
bundler: bundler,
entryPointAddress: DEFAULT_ENTRYPOINT_ADDRESS,
defaultValidationModule: ecdsaModule,
activeValidationModule: ecdsaModule,
};
const biconomySmartAccount = await BiconomySmartAccountV2.create(
biconomySmartAccountConfig
);
const transaction = {
to: "0xd3C85Fdd3695Aee3f0A12B3376aCD8DC54020221",
data: "0x"
}
let partialUserOp = await biconomySmartAccount.buildUserOp([transaction],
paymasterServiceData: {
mode: PaymasterMode.SPONSORED,
},
});
const userOpResponse = await biconomySmartAccount.sendUserOp(partialUserOp);
await userOpResponse.wait();
After
import { ethers } from "ethers";
import { BiconomySmartAccountV2} from "@biconomy/account";
import { PaymasterMode } from "@biconomy/paymaster";
let provider = new ethers.providers.JsonRpcProvider("rpcUrl");
let signer = new ethers.Wallet("private key", provider);
const biconomySmartAccountConfig = {
signer: signer,
chainId: 80001
biconomyPaymasterApiKey: "paymaster api key",
bundlerUrl: "bundler url"
};
const biconomySmartAccount = await BiconomySmartAccountV2.create(
biconomySmartAccountConfig
);
const transaction = {
to: "0xd3C85Fdd3695Aee3f0A12B3376aCD8DC54020221",
data: "0x"
}
let partialUserOp = await biconomySmartAccount.buildUserOp([transaction],
paymasterServiceData: {
mode: PaymasterMode.SPONSORED,
},
);
const userOpResponse = await biconomySmartAccount.sendUserOp(partialUserOp);
await userOpResponse.wait();
The smart account uses ECDSA by default, entry point address is also set by default by the SDK.
-
Abstracted Bundler
Bundler is now required, this will help us remove the need of providing a chainId as a param in the create method in the future because we can get it from bundler instance or bundler url. Making sure a smart account has a bundler is essential as the smart account is not functional without the bundler.
The user can now skip creating the instance of the bundler and provide just the bundler url instead to the “create” method of BiconomySmartAccountV2.
Example of creating a smart account and sending a user op.
const provider = new ethers.providers.JsonRpcProvider("https://rpc.ankr.com/polygon_mumbai"); const signer = new ethers.Wallet("private key", provider); const bundlerUrl = "bundler url"; const biconomyPaymasterApiKey = "paymaster api key"; const chainId = 80001; let smartAccount = await BiconomySmartAccountV2.create({ signer, chainId, bundlerUrl })
-
Abstracted Paymaster
Paymaster is now abstracted, added a new optional param, “biconomyPaymasterApiKey” which can be provided instead of having to manually create the instance of paymaster by the user.
const provider = new ethers.providers.JsonRpcProvider("https://rpc.ankr.com/polygon_mumbai"); const signer = new ethers.Wallet("private key", provider); const bundlerUrl = "bundler url"; const biconomyPaymasterApiKey = "paymaster api key"; const chainId = 80001; let smartAccount = await BiconomySmartAccountV2.create({ signer, chainId, biconomyPaymasterApiKey })
-
Default validation module to ECDSA
User does not need to provide a “defaultValidationModule” and “activeValidationModule” if the module that he wants to use is ECDSA, this will be set by default on the smart accounts.
const provider = new ethers.providers.JsonRpcProvider("https://rpc.ankr.com/polygon_mumbai"); const signer = new ethers.Wallet("private key", provider); const bundlerUrl = "bundler url"; const chainId = 80001; // ECDSA validation module is assigned by the SDK by default let smartAccount = await BiconomySmartAccountV2.create({ signer, chainId, bundlerUrl })
-
Abstracted entry point address
The “entryPointAddress” is now optional. User can skip providing an entry point address and the SDK will set it to “DEFAULT_ENTRYPOINT_ADDRESS” by default.
const provider = new ethers.providers.JsonRpcProvider("https://rpc.ankr.com/polygon_mumbai"); const signer = new ethers.Wallet("private key", provider); const bundlerUrl = "bundler url"; const chainId = 80001; // Entry point address is automatically set to **DEFAULT_ENTRYPOINT_ADDRESS** let smartAccount = await BiconomySmartAccountV2.create({ signer, chainId, bundlerUrl })
Support for WalletClientSigner
Our smart accounts now supports WalletClientSigner from “@alchemy/aa-core”.
User can now pass WalletClientSigner instead of ethers.Signer or keep using ethers.Signer if preferred.
import { WalletClientSigner } from "@alchemy/aa-core"; import { privateKeyToAccount } from "viem/accounts"; import { createWalletClient, http } from "viem"; import { polygonMumbai } from "viem/chains"; import { BiconomySmartAccountV2 } from "../src/BiconomySmartAccountV2"; import { ChainId } from "@biconomy/core-types"; const wallet = privateKeyToAccount(`0x${privKey}`); const walletClient = createWalletClient({ account: wallet, chain: polygonMumbai, transport: http("https://rpc-mumbai.maticvigil.com"), }); const ecdsaSigner: WalletClientSigner = new WalletClientSigner(walletClient, "json-rpc"); const account = await BiconomySmartAccountV2.create({ chainId: ChainId.POLYGON_MUMBAI, signer: ecdsaSigner, bundlerUrl: "https://bundler.biconomy.io/api/v2/80001/..." });
What's Changed
- Merge main into develop by @livingrockrises in #330
- Update import paths by @AmanRaj1608 in #332
- Made entryPointAddress optional by @VGabriel45 in #336
- Feat/devx 336 abstract paymaster by @VGabriel45 in #334
- fix: misleading error when paymaster policy check fails by @livingrockrises in #335
- Added check for entryPointAddress field by @VGabriel45 in #337
- Feat/devx 337 abstract module by @VGabriel45 in #333
- Feat/devx 349 wallet client signer support by @VGabriel45 in #339
- Fix: Receipt status type by @joepegler in #342
- Feat/devx 362 abstract required bundler by @VGabriel45 in #341
- Release/r7 by @livingrockrises in #345
New Contributors
- @joepegler made their first contribution in #342
Full Changelog: r6...r7