For ERC20 Tokens that support meta transactions by Permit method, you can combine permit and target method execution in one call using ERC20ForwarderClient.
How It works?
This feature is available for tokens that follow the EIP 2612 (USDC, Uniswap LP tokens) standard for their permit function. Dai uses a non standard method which we will call DAI Permit.
Users will be asked for two signatures. One signature will be for Permit method (to provide approval to spend tokens by ERC20 Forwarder) on token contracts that meets above criteria. Another signature will be for ERC20 Forwarder contract to perform meta transaction and execute target method call. You can find the source code here
First signature will be taken from the client side and passed on as Permit Options to ERC20ForwarderClient call. Mexa is responsible for taking second signature for message that performs work on your contract.
Client Side Integration
You can refer to the SDK integration code with passing some extra parameters and using different method to send away your transaction to Biconomy.
buildTx will accept this optional parameter permitType with below possible values.
permitType : "EIP2612_Permit"
In this case cost returned by this method would be total fees.
New method in ERC20ForwarderClient : permitAndSendTxEIP712 which will accept optional paramter metaInfo.
metaInfo has permitType and permitData
To obtain permit data,
Prompt to get the signature for Permit meta transaction based on the ERC20 token / permit type
Get r,s,v components of the signature and formulate permitData object
Create metaInfo using permitData and permitType (above mentioned constants) as members. Let's see this in action in below sample code to simplify your one time integration.