Alternative Fee Payments
Objective
Solution
import "@openzeppelin/community-contracts/account/paymaster/PaymasterERC20.sol";
contract MyERC20Paymaster is PaymasterERC20, Ownable {
function _fetchDetails(
PackedUserOperation calldata userOp,
bytes32 /* userOpHash */
) internal view virtual override returns (uint256 validationData, IERC20 token, uint256 tokenPrice) {
// oversimplified example - real-live paymaster should check liveness and sanity of the price
uint256 price = oracle.getLatestTokenPrice();
return (
ERC4337Utils.SIG_VALIDATION_SUCCESS,
USDC,
price
);
}
function _authorizeWithdraw() internal virtual override onlyOwner {}
}Last updated

