Gasless SDK (EOA) 3

The new TypeScript Gasless SDK (EOA) is here!

Changes in the new SDK:

  1. Typescript based SDK

  2. Using event listeners you can monitor the state change of a transaction. One can get notified on transaction hash creation, transaction being mined or on any error.

How to build and send transaction with Ethers:

https://github.com/bcnmy/gasless-playground/blob/master/src/components/Ethers_EIP2771_EIP712Sign.tsx

const provider = await biconomy.provider;
const contractInstance = new ethers.Contract(
  config.contract.address,
  config.contract.abi,
  biconomy.ethersProvider
);
let { data } = await contractInstance.populateTransaction.setQuote(arg);
let txParams = {
  data: data,
  to: config.contract.address,
  from: userAddress,
  signatureType: "EIP712_SIGN",
};
await provider.send("eth_sendTransaction", [txParams]);
// Listen to transaction updates:
biconomy.on("txHashGenerated", data: { transactionId: string; transactionHash: string; }) => {
  console.log(data);
  showSuccessMessage(`tx hash ${data.hash}`);
});

biconomy.on("txMined", (data: {msg: string; id: string; hash: string; receipt: string}) => {
  console.log(data);
});

biconomy.on("onError", (data: {error: any; transactionId: string}) => {
  console.log(data);
});

bicnomy.on("txHashChanged", (data: {transactionId: string, transactionHash: string}) => {
  console.log(data);
});

How to build and send transactions with Web3:

https://github.com/bcnmy/gasless-playground/blob/master/src/components/Web3_EIP2771_EIP712Sign.tsx

const web3 = new Web3(biconomy.provider);
const contractInstance = new web3.eth.Contract(
  abi
  contractAddress
);
await contractInstance.methods.setQuote(newQuote).send({
  from: address,
  signatureType: "EIP712_SIGN",
});
// Listen to transaction updates:
biconomy.on("txHashGenerated", data: { transactionId: string; transactionHash: string; }) => {
  console.log(data);
  showSuccessMessage(`tx hash ${data.hash}`);
});

biconomy.on("txMined", (data: {msg: string; id: string; hash: string; receipt: string}) => {
  console.log(data);
});

biconomy.on("onError", (data: {error: any; transactionId: string}) => {
  console.log(data);
});

bicnomy.on("txHashChanged", (data: {transactionId: string, transactionHash: string}) => {
  console.log(data);
});

Last updated