Wallet Integration¶
This guide outlines the steps for wallet developers to integrate paymaster services, enabling gas fee sponsorship for their users. By following these standards, wallets can offer seamless, gasless transactions across multiple paymaster providers.
Interaction Workflow¶
Integration involves modifying the transaction creation and sending process to interact with paymaster services. For detailed information about the paymaster API interface, please refer to this document.
The main steps are:
- Transaction Preparation:
- When a user initiates a transaction, first call
gm_sponsorable
to check if it’s eligible for sponsorship. - If sponsorable, set the transaction’s gas price to zero.
- When a user initiates a transaction, first call
- User Notification:
- Inform the user that the transaction will be gas-free and sponsored by the “policy name” returned by the API.
- Transaction Signing:
- Have the user sign the zero-gas-price transaction.
- Submission to Paymaster:
- Send the signed transaction to the paymaster using
eth_sendRawTransaction
.
- Send the signed transaction to the paymaster using
- Response Handling:
- Process the paymaster’s response:
- If successful, inform the user that the transaction is submitted.
- If failed, consider falling back to normal transaction processing or inform the user of the failure.
- Process the paymaster’s response:
- Transaction Monitoring:
- Monitor the transaction status as usual.
Best Practice¶
- Always check sponsorability before modifying gas price.
- Provide clear user feedback about sponsorship status.
- Implement proper error handling for cases where sponsorship fails.
- Consider fallback mechanisms for non-sponsored transactions.