Configuration

Configure Gasless SDK (EOA) as per your requirement with multiple options

Biconomy constructor takes 2 parameters

const biconomy = new Biconomy(<existing web3 provider>, options);

<existing web3 provider>

object required

Any web3 provider that supports personal_sign, eth_accounts, eth_sendTransaction, eth_call RPC methods.

For example, it can be window.ethereum for Metamask or portis.provider for Portis and so on.

options

object required

A json object having following configuration values for initializing Gasless SDK (EOA) .

apiKey

string required API Key can be found on Gasless SDK (EOA) dashboard.

Unique id assigned to each DApp that used to authenticate requests coming from Gasless SDK (EOA).

strictMode

boolean optional

Default false

If strict mode is on, and method/api called by user is not registered on Gasless SDK (EOA) dashboard then no transaction will be initiated.

If strict mode is off, and method called by user is not registered on Gasless SDK (EOA) dashboard then existing provider will be used to send user transaction but in this case, the user will have to pay the transaction fee.

transferHandlerAddress

string optional

Default ${biconomy.transferHandlerAddress}

Transfer Handler Address is the contract address that's responsible for ERC20 token transfers after getting approval from the user. If transfer handler address is provided by the developer then Gasless SDK (EOA) will initialize helper clients with transfer handler contract using this address.

If address is not provided Gasless SDK (EOA) will initialize it to biconomy's deployed contracts based on provider's network id.

erc20ForwarderAddress

string optional

Default ${biconomy.erc20ForwarderAddress}

ERC20 Forwarder Address is the contract address thats' responsible for calculating the cost of transaction gas in ERC20 tokens, use the fee multiplier provided by fee manager, allow or block any tokens and make the transfer to fee recipient.

Biconomy currently supports universal fee proxy per network deployed by us.

If address is not provided Gasless SDK (EOA) will initialize it to biconomy's deployed contracts based on provider's network id.

debug

boolean optional

Default false

By default there will be no logs printed on console but if you want to run Gasless SDK (EOA) in debug mode, set the debug value as true and all logs will be printed that will help you in debugging the code.

Example Code

For metamask biconomy initialization code would look like:

let options = {
 apiKey: <API KEY>,
 strictMode: true,
 debug: true
};
const biconomy = new Biconomy(window.ethereum, options);

Biconomy ships with permit client and can be accessed using biconomy.permitClient. Please check SDK front end implementation for example. However Permit Client can be imported along with Biconomy from Gasless SDK (EOA) for your custom initialization for independent use.

PermitClient

Permit Client serves two methods daiPermit (for getting approval to spend DAI) and eip2612Permit (for getting approval to spend any token that supports EIP2612 signed approvals e.g USDC)

Permit Client constructor takes 2 parameters

const permitClient = new PermitClient(<provider>, erc20ForwarderAddress, daiTokenAddress);

If this client is directly accessed from biconomy object, it would contain erc20ForwarderAddress passed with Biconomy options which is essentially the spender of the tokens.

options for daiPermit and eip2612Permit

1. daiPermit

spender

string optional

Default ${permitClient.erc20ForwarderAddress}

spender is the ehtereum contract address or EOA thats' allowed to spend tokens on behalf of the user. Gas fees will be charged from user's wallet by making transaction IERC20.transferFrom by this spender.

expiry

Number optional

Default Math.floor(Date.now() / 1000 + 3600)

Time window in unix epoch format until the spender is allowed to make transfer of DAI tokens. If your transaction takes longer than this, please give a larger time frame to avoid giving permit again.

allowed

boolean optional

Default true

Whether the spender is allowed to spend the tokens. Used to revoke the permission before dealine it would make sense to use this with stand alone permit client.

2. eip2612Permit

spender

string optional

Default ${permitClient.erc20ForwarderAddress}

spender is the ethereum contract address or EOA thats' allowed to spend tokens on behalf of the user. Gas fees will be charged from user's wallet by making transaction IERC20.transferFrom by this spender.

deadline

Number optional

Default Math.floor(Date.now() / 1000 + 3600)

Time window in unix epoch format until the spender is allowed to make transfer of tokens. If your transaction takes longer than this, please give a larger time frame to avoid giving permit again.

value

String required

Default true

How many tokens the spender is allowed to spend. This should be in calculated based on token decimals. For example to spend 1 USDC (token decimals 18) this value would be "1000000000000000000" Used to revoke the permission before deadline it would make sense to use this with stand alone permit client.

Last updated