Biconomy SDK

Sponsor Gas Fees For Your Users

Gasless sponsorships can be managed by passing relevant parameters in the Smart Account custom Network config for specific chainIds (once initialised your Smart Account is a multi chain instance). Set up Dapp configurations and invoke methods as mentioned in this section below.
Code below shows how to initialise smart account in order to avail benefits of gasless.
import { IPaymaster, ChainId } from "@biconomy/core-types";
import SmartAccount from "@biconomy/smart-account";
let options = {
activeNetworkId: activeChainId,
supportedNetworksIds: supportedChains,
// Network Config.
// Link Paymaster / DappAPIKey for the chains you'd want to support Gasless transactions on
networkConfig: [
chainId: ChainId.GOERLI,
dappAPIKey: '<DAPP_API_KEY>', // Get one from Paymaster Dashboard
// customPaymasterAPI: <IPaymaster Instance of your own Paymaster>
let smartAccount = new SmartAccount(walletProvider, options);
smartAccount = await smartAccount.init();
Start relaying transactions to the bundler. A complete example is linked below
// one can subscribe to socket events prior to sending transaction
// Transaction subscription
smartAccount.on('txHashGenerated', (response: any) => {
console.log('txHashGenerated event received via emitter', response);
showSuccessMessage(`Transaction sent: ${response.hash}`);
smartAccount.on('txMined', (response: any) => {
console.log('txMined event received via emitter', response);
showSuccessMessage(`Transaction mined: ${response.hash}`);
smartAccount.on('error', (response: any) => {
console.log('error event received via emitter', response);
// Gasless
const txResponse = await smartAccount.sendGasLessTransaction({ transaction: tx1 });