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


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. Go to Mexa Dashboard to register your DApp and methods on which to enable meta transactions and copy your API Key.

  2. Install Biconomy SDK (Mexa)

Mexa can be installed either via npm repository or using standalone javascript file using html <script/> tag

Standalone JS File
npm install @biconomy/mexa

Import and Initialize Mexa and web3

import Biconomy from "@biconomy/mexa";
const biconomy = new Biconomy(<web3 provider>,{apiKey: <API Key>});
web3 = new Web3(biconomy);

Note: <web3 provider> could be window.ethereum for Metamask or portis.provider for Portis and so on.

Standalone JS File
<script src=""></script>

Initialize Biconomy

let biconomy, web3;
if (window.Biconomy) {
let Biconomy = window.Biconomy;
biconomy = new Biconomy(<web3 provider object>,{ apiKey: <your apiKey>});
web3 = new Web3(biconomy);

Initialize your DApp after Mexa initialization

biconomy.onEvent(biconomy.READY, () => {
// Initialize your dapp here like getting user accounts etc
}).onEvent(biconomy.ERROR, (error, message) => {
// Handle error while initializing mexa

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 in an EIP-712 format and handle the transaction rather than sending signed transaction directly to blockchain from user’s wallet.

In next section we'll see how user login is required to retain the ownership of user transactions without changing anything in your smart contract code. Login is not required if you are using native meta transactions.