Socket
Socket
Sign inDemoInstall

@biconomy/account

Package Overview
Dependencies
66
Maintainers
6
Versions
23
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
3K
increased by4.25%
Maintainers
6
Created
Weekly downloads
 

Changelog

Source

4.1.0 (2023-04-03)

Features:

  • Added Speed optimisation, removing redundant gasEstimate call to bundler (2371b2)
  • Added smartAccount.getBalances() method (4b8bae)
  • Added smartAccount.getSupportedTokens() method (6d2fb27)
  • Added smartAccount.deploy() method (be9dc4)
  • Increased checking of the chainId from the bundler, paymaster and the provider (5d2f3)
  • Added entity name to Logger calls (9278ec)
  • Export a 'getChain' by id helper, which returns a viem chain (ab2ba)
  • Add "stateOverride" optional param (20fd54)

Fixes:

  • Fix for encodeAbiParameters inside batched session module (b27061)
  • added flag to skip calldata approval patch (75698)
  • Fixed the particle auth build

Chores:

  • Added tests for ecdsa module (1a8f29)
  • Increased test coverage (329003)
  • Improved issue reporting guidelines (8b9fb5d)
  • Added e2e tests for optimism, ran from GH actions (5051ba)
  • Added ABI SVM test (49c96)
  • Added tests for batched session router testing (2eb9765)

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
  paymasterUrl: "", // 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
paymasterUrlYou can pass in a paymasterUrl 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,
  paymasterUrl,
});

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 06 Mar 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