Socket
Socket
Sign inDemoInstall

@biconomy/account

Package Overview
Dependencies
6
Maintainers
6
Versions
22
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @biconomy/account

This package provides apis for ERC-4337 based smart account implementations


Version published
Weekly downloads
2.6K
decreased by-13.09%
Maintainers
6
Created
Weekly downloads
 

Changelog

Source

4.0.0 (2023-02-06)

Features

  • Export bundler / paymaster instances + helpers from master package (1d1f9d)
  • Export modules aliases from master package (d6205c)
  • Added sendTransaction abstraction for buildUserOp + sendUserOp (335c6e)
  • Reduced bundle size (765a3e3)
  • Added bundler abstraction during SmartAccount init (591bbb4)
  • Added e2e tests that speak with prod bundler / paymasters (4b4a53a)
  • Added support for simultaneous ethers + viem signers (8e4b2c8)
  • E2E tests for multichain modules (ecc86e2)
  • E2E tests for session validation modules (4ad7ea7)
  • Added TSDoc (638dae)
  • Make txs more typesafe and default with valueOrData (b1e5b5e)
  • Added createSmartAccountClient alias (232472)
  • Improve dx of using paymster to build userOps (bb54888)
  • Add ethers v6 signer support (9727fd)
  • Improved dx of using gas payments with erc20 (741806)

Chores

  • Removed SmartAccount Base class in favour of Alchemy's (be82732)
  • Migrate to viem v2 (8ce04a)
  • Remove common + core-types dependencies (673514)
  • Reincluded simulation flags (25d2be)

Bug Fixes

  • Make silently failing paymaster calls throw an error instead (693bf0)
  • Added string as a supported Transaction value type (b905dc)
  • Removed skipBundlerGasEstimation option (b905dc)
  • Ingest rpcUrl from SupportedSigners (ethers + viem) (f56b4d)

Readme

Source

Biconomy SDK

Biconomy SDK TypeScript Test Coverage

👋 Introduction

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.

⚙️ installation

npm i @biconomy/account

🛠️ Quickstart

import { createSmartAccountClient } from "@biconomy/account";

const smartAccount = await createSmartAccountClient({
  signer: viemWalletOrEthersSigner,
  bundlerUrl: "", // From dashboard.biconomy.io
  biconomyPaymasterApiKey: "", // From dashboard.biconomy.io
});

const { wait } = await smartAccount.sendTransaction({ to: "0x...", value: 1 });

const {
  receipt: { transactionHash },
  userOpHash,
} = await wait();

🌟 Features

  • ERC4337 Account Abstraction: Simplify user operations and gas payments.
  • Smart Accounts: Enhance user experience with modular smart accounts.
  • Paymaster Service: Enable third-party gas sponsorship.
  • Bundler Infrastructure: Ensure efficient and reliable transaction bundling.

For a step-by-step guide on integrating ERC4337 Account Abstraction and Smart Accounts into your dApp using the Biconomy SDK, refer to the official documentation. You can also start with Quick start here.

📚 Resources

💼 Example Usages

Initialise the smartAccount

KeyDescription
signerThis signer will be used for signing userOps for any transactions you build. Will accept ethers.JsonRpcSigner as well as a viemWallet
biconomyPaymasterApiKeyYou can pass in a biconomyPaymasterApiKey necessary for sponsoring transactions (retrieved from the biconomy dashboard)
bundlerUrlYou 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,
  biconomyPaymasterApiKey,
});

Send some ETH, have gas sponsored

KeyDescription
oneOrManyTxSubmit multiple or one transactions
userOpReceiptReturned information about your tx, receipts, userOpHashes etc
const oneOrManyTx = { to: "0x...", value: 1 };

const { wait } = await smartAccount.sendTransaction(oneOrManyTx, {
  mode: PaymasterMode.SPONSORED,
});

const {
  receipt: { transactionHash },
  userOpHash,
} = await wait();

Mint two NFTs, pay gas with token

KeyDescription
buildUseropDtoOptions for building a userOp
paymasterServiceDataPaymasterOptions set in the buildUseropDto
import { encodeFunctionData, parseAbi } from "viem";

const encodedCall = encodeFunctionData({
  abi: parseAbi(["function safeMint(address to) public"]),
  functionName: "safeMint",
  args: ["0x..."],
});

const tx = {
  to: nftAddress,
  data: encodedCall,
};
const oneOrManyTx = [tx, tx]; // Mint twice
const paymasterServiceData = {
  mode: PaymasterMode.ERC20,
  preferredToken: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
};
const buildUseropDto = { paymasterServiceData };

const { wait } = await smartAccount.sendTransaction(oneOrManyTx, buildUseropDto);

const {
  receipt: { transactionHash },
  userOpHash,
} = await wait();

🤝 Contributing

Community contributions are welcome! For guidelines on contributing, please read our contribution guidelines.

📜 License

This project is licensed under the MIT License. See the LICENSE.md file for details.

Keywords

FAQs

Last updated on 12 Feb 2024

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc