Git Product home page Git Product logo

biconomy-client-sdk's Introduction

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.

๐Ÿ› ๏ธ 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

โš™๏ธ installation

npm i @biconomy/account

๐Ÿ’ผ Example Usages

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, {
  mode: PaymasterMode.SPONSORED,
});

const {
  receipt: { transactionHash },
  userOpHash,
} = await wait();
Key Description
buildUseropDto Options for building a userOp
paymasterServiceData PaymasterOptions 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.

biconomy-client-sdk's People

Contributors

livingrockrises avatar amanraj1608 avatar talhamalik883 avatar gabidev45 avatar joepegler avatar aboudjem avatar arcticfloyd1984 avatar vgabriel45 avatar tomarsachin2271 avatar asheerrizvi avatar kunal047 avatar ankurdubey521 avatar innovation-stack avatar protodev-rage avatar au2001 avatar pjijin avatar lovejeet avatar anonacc avatar himanshugarg06 avatar rhicc avatar sudotx avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.