Integrate Gasless SDK (EOA)

Integrate Gasless SDK (EOA) on our client side to enable gasless transactions

Gasless SDK (EOA) can be installed either via npm repository or using standalone javascript file using html <script/> tag

Install Gasless SDK (EOA) via npm

npm install @biconomy/mexa

Import and Initialize Gasless SDK (EOA)

import { Biconomy } from "@biconomy/mexa";
const biconomy = new Biconomy(window.ethereum,{apiKey: "q9oEztJM8.e8ed08a7-5b38-48e3-b4c0-f66e6b66f407"});
web3 = new Web3(biconomy);

Initialize DApp after Gasless SDK (EOA) initialization

biconomy.onEvent(biconomy.READY, () => {
  // Initialize your dapp here like getting user accounts etc
  await window.ethereum.enable();
  contract = new web3.eth.Contract(config.contract.abi, config.contract.address);
}).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 Gasless SDK (EOA) dashboard also) initiated from the user , Gasless SDK (EOA) 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.

Check out the full code here

Last updated