# Paymaster Interfaces

```
  function validatePaymasterUserOp
    (UserOperation calldata userOp, bytes32 userOpHash, uint256 maxCost)
    external returns (bytes memory context, uint256 validationData);

function postOp
    (PostOpMode mode, bytes calldata context, uint256 actualGasCost)
    external;

enum PostOpMode {
    opSucceeded, // user op succeeded
    opReverted, // user op reverted. still has to pay for gas.
    postOpReverted // user op succeeded, but caused postOp to revert
}
```

```
// add a paymaster stake (must be called by the paymaster)
function addStake(uint32 _unstakeDelaySec) external payable

// unlock the stake (must wait unstakeDelay before can withdraw)
function unlockStake() external

// withdraw the unlocked stake
function withdrawStake(address payable withdrawAddress) external
```

\
To handle the transactions sponsored by paymasters, the entry point has to maintain a specific deposit mechanism, which is distinct from the staking system. This deposit serves as a pool from which `UserOperation` expenses are debited.

Below is the outline for the interface the entry point needs to support, aiding paymasters and, if necessary, accounts in handling their deposits:\
\
interface EntryPointDepositManagement {

```
// Event emitted when funds are deposited into the EntryPoint by a paymaster or account
event Deposited(address indexed paymaster, uint256 amount);

// Event emitted when funds are withdrawn from the EntryPoint by a paymaster or account
event Withdrawn(address indexed paymaster, uint256 amount);

/**
 * Deposit funds into the EntryPoint.
 * @param amount The amount of ETH (or other token) to be deposited.
 */
function deposit(uint256 amount) external payable;

/**
 * Withdraw funds from the EntryPoint.
 * @param amount The amount of ETH (or other token) to be withdrawn.
 */
function withdraw(uint256 amount) external;

/**
 * Query the deposited amount of a given paymaster or account.
 * @param addr Address of the paymaster or account.
 * @return The amount of ETH (or other token) deposited by the given address.
 */
function getDeposit(address addr) external view returns (uint256);
```

}\
\
This interface allows for:

* Depositing funds to the EntryPoint.
* Withdrawing funds from the EntryPoint.
* Checking the deposit balance of any paymaster or account.

The separation of deposit (for transaction costs) and stake (locked funds to ensure compliance) ensures a dual layer of financial security and transaction guarantee for the system.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mau-eth.gitbook.io/mau/account-abstraction/required-entry-point-contract-functionality/paymaster-extension/paymaster-interfaces.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
