We use three mappings to store developer data, achieving decentralized management.
mapping(uint256 => address) public projectOwner;
mapping(uint256 => uint256) public projectNero;
mapping(uint256 => mapping(address => uint256)) public projectERC20;
Developers bind their project to a wallet address on the platform and then recharge with NERO. After that, users can call the Paymaster API to pay for gas either for free or using ERC20. Please refer to the usage guidelines of the platform for more details.
Sponsored transaction process
RPC Api
pm_supported_tokens
Retrieve the list of ERC20 tokens configured for gas payment by the project. With the request parameters in the following order: userop, project_apikey, entrypoint. request:
response: The returned price, if it is "system", may vary when requesting pm_sponsor_userop, whereas if it is "custom", it is the price set by the backend. The price is the exchange rate of the ERC20 token against NERO. freeGas: Whether or not to support sponsoring gas fees. Note that, like the token’s price, it may change when requesting pm_sponsor_userop. For example, if it returns true here, but the request for pm_sponsor_userop exceeds the total number of requests due to other requests, the paymaster signature will return an error, and the user will need to choose a different method for paying gas fees.
Get paymaster and signature data With the request parameters in the following order: userop, project_apikey, entrypoint, context(type, erc20)
type=0 freegas. Developer sponsors gas fees, users do not need to pay ERC20.
type=1 prefund erc20. During the verification phase, the system first deducts the full amount of ERC20 from the user, and then returns the excess portion after executing the user operation.
type=2 postfund erc20. After the userop is executed, the system deducts the ERC20 from the user in one go. However, it’s possible that the deduction may fail due to the specific nature of the userop code.