πŸ“™
Biconomy SDK (Mexa)
Enable meta transactions or gasless transactions in your Dapp by integrating Mexa SDK in your DApp in a few lines of code

Introduction

Biconomy SDK (Mexa), 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 mexa.
By using Mexa, 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. 1.
    Go to Mexa Dashboard to register your DApp and methods on which to enable meta transactions and copy your API Key.
  2. 2.
    Install Biconomy SDK (Mexa)

1. Installing and importing SDK

Mexa can be installed either via npm repository or using standalone javascript file using html <script/> tag
Via NPM
Standalone JS File
1
npm install @biconomy/mexa
Copied!
1
// Install Biconomy
2
<script src="https://cdn.jsdelivr.net/npm/@biconomy/[email protected]/dist/mexa.js"></script>
3
​
4
// Import Biconomy
5
let Biconomy = window.Biconomy.default;
Copied!

2. Initializing SDK

You can use Mexa either with Web3.js or Ethers.js library. It works with both libraries.
web3
ethers
1
import {Biconomy} from "@biconomy/mexa";
2
const biconomy = new Biconomy(<web3 provider>,{apiKey: <API Key>, debug: true});
3
web3 = new Web3(biconomy);
Copied!
1
import {Biconomy} from "@biconomy/mexa";
2
const biconomy = new Biconomy(<web3 provider>,{apiKey: <API Key>, debug: true});
3
let ethersProvider = new ethers.providers.Web3Provider(biconomy);
Copied!
Note: <web3 provider> could be window.ethereum for Metamask or portis.provider for Portis and so on. It should be a provider object not RPC url.

3. Initialize your DApp after Mexa initialization

1
biconomy.onEvent(biconomy.READY, () => {
2
// Initialize your dapp here like getting user accounts etc
3
}).onEvent(biconomy.ERROR, (error, message) => {
4
// Handle error while initializing mexa
5
});
Copied!
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 (registered in mexa dashboard also) initiated from the user, Mexa will ask for user’s signature either EIP-712 format or personal signature as instructed and handle the transaction rather than sending signed transaction directly to blockchain from user’s wallet.
Last modified 9mo ago