Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
@biconomy/account
Advanced tools
Readme
The Biconomy SDK is your all-in-one toolkit for building decentralized applications (dApps) with ERC4337 Account Abstraction and Smart Accounts. It is designed for seamless user experiences and offers non-custodial solutions for user onboarding, sending transactions (userOps), gas sponsorship and much more.
bun add @biconomy/account viem
bun i
import { createSmartAccountClient } from "@biconomy/account";
const smartAccount = await createSmartAccountClient({
signer: viemWalletOrEthersSigner,
bundlerUrl: "", // From dashboard.biconomy.io
paymasterUrl: "", // From dashboard.biconomy.io
});
const { wait } = await smartAccount.sendTransaction({ to: "0x...", value: 1 });
const {
receipt: { transactionHash },
success,
} = await wait();
For a comprehensive understanding of our project and to contribute effectively, please refer to the following resources:
Key | Description |
---|---|
signer | This signer will be used for signing userOps for any transactions you build. Will accept ethers.JsonRpcSigner as well as a viemWallet |
paymasterUrl | You can pass in a paymasterUrl necessary for sponsoring transactions (retrieved from the biconomy dashboard) |
bundlerUrl | You can pass in a bundlerUrl (retrieved from the biconomy dashboard) for sending transactions |
import { createSmartAccountClient } from "@biconomy/account";
import { createWalletClient, http, createPublicClient } from "viem";
import { privateKeyToAccount, generatePrivateKey } from "viem/accounts";
import { mainnet as chain } from "viem/chains";
const account = privateKeyToAccount(generatePrivateKey());
const signer = createWalletClient({ account, chain, transport: http() });
const smartAccount = await createSmartAccountClient({
signer,
bundlerUrl,
paymasterUrl,
});
Key | Description |
---|---|
oneOrManyTx | Submit multiple or one transactions |
userOpReceipt | Returned information about your tx, receipts, userOpHashes etc |
const oneOrManyTx = { to: "0x...", value: 1 };
const { wait } = await smartAccount.sendTransaction(oneOrManyTx, {
paymasterServiceData: {
mode: PaymasterMode.SPONSORED,
},
});
const {
receipt: { transactionHash },
userOpHash,
success,
} = await wait();
Key | Description |
---|---|
buildUseropDto | Options for building a userOp |
paymasterServiceData | PaymasterOptions set in the buildUseropDto |
import { encodeFunctionData, parseAbi } from "viem";
const preferredToken = "0x747A4168DB14F57871fa8cda8B5455D8C2a8e90a"; // USDC
const tx = {
to: nftAddress,
data: encodeFunctionData({
abi: parseAbi(["function safeMint(address to) public"]),
functionName: "safeMint",
args: ["0x..."],
}),
};
const buildUseropDto = {
paymasterServiceData: {
mode: PaymasterMode.ERC20,
preferredToken,
},
};
const { wait } = await smartAccount.sendTransaction(
[tx, tx] /* Mint twice */,
buildUseropDto
);
const {
receipt: { transactionHash },
userOpHash,
success,
} = await wait();
This project is licensed under the MIT License. See the LICENSE file for details
FAQs
SDK for Biconomy integration with support for account abstraction, smart accounts, ERC-4337.
The npm package @biconomy/account receives a total of 1,902 weekly downloads. As such, @biconomy/account popularity was classified as popular.
We found that @biconomy/account demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.