@biconomy/mexa
TypeScript icon, indicating that this package has built-in type declarations

3.0.6 • Public • Published

Enable meta transactions or gasless transactions in your DApp by integrating Biconomy Gasless SDK in your DApp

Biconomy Gasless SDK

Introduction

Biconomy Gasless SDK, enables meta transactions or gasless transactions in your DApp (Decentralized Application) out of the box without any change in your smart contracts and just a few lines of code in your DApp to integrate gasless sdk.

By using Gasless SDK, dapp users are able to use the dapp and send transactions free of cost while developer pays the gas fee on their behalf as a part of user acquisition cost.

Let’s Get Started

  1. Go to Biconomy Gasless Dashboard to register your DApp and methods on which to enable meta transactions and copy your DApp ID and API Key.
  2. Install Biconomy Gasless SDK
npm install @biconomy/mexa

Import and initialize gasless sdk and web3

import { Biconomy } from "@biconomy/mexa";
const biconomy = new Biconomy(window.ethereum, {
        apiKey: apiKey,
        contractAddresses: [<Your contract address>],
});      
await biconomy.init();

Initialize your dapp after gasless SDK initialization

biconomy.on("txMined", (data: any) => {
    // Event emitter to monitor when a transaction is mined
    console.log("transaction data", data);
});
biconomy.on("txHashGenerated", (data: any) => {
    // Event emitter to monitor when a transaction hash is generated
    console.log("transaction data", data);
});
biconomy.on("txHashChanged", (data: any) => {
    // Event emitter to monitor when a transaction hash is changed in case of gas price bump
    console.log("transaction data", data);
});
biconomy.on("error", (data: any) => {
    // Event emitter to monitor when an error occurs
    console.log("transaction data", data);
});

Congratulations!! You have now enabled meta transactions in your DApp. Interact with web3 the way you have been doing it.

Now whenever there is a write transaction action initiated from user (registered in biconomy gasless dashboard also), gasless SDK will ask for user’s signature and handle the transaction rather than sending signed transaction directly to blockchain from user’s wallet.

Key Name Value Required? Description
apiKey

type: string

API Key can be found on Biconomy gasless dashboard.

true Unique id assigned to each DApp that used to authenticate requests coming from Biconomy gasless sdk.
strictMode

type: boolean

default value: false

Value could be true or false.

false

If strict mode is on, and method/api called by user is not registered on Biconomy gasless dashboard then no transaction will be initiated.

If strict mode is off, and method called by user is not registered on Biconomy gasless dashbord dashboard then existing provider will be used to send user transaction but in this case, the user will have to pay the transaction fee.

Readme

Keywords

none

Package Sidebar

Install

npm i @biconomy/mexa

Weekly Downloads

513

Version

3.0.6

License

MIT

Unpacked Size

2.96 MB

Total Files

131

Last publish

Collaborators

  • divyan73
  • vgabriel45
  • joepegler
  • arcticfloyd1984
  • aboudjem
  • ankurdubey.bico
  • livingrock7
  • sachin.tomar