# Kinto EntryPoint

**Deployment Address**

\*\*Mainnet: \*\* [<mark style="color:purple;">0x2843C269D2a64eCfA63548E8B3Fc0FD23B7F70cb</mark>](https://explorer.kinto.xyz/address/0x2843C269D2a64eCfA63548E8B3Fc0FD23B7F70cb)

**Code**: [<mark style="color:purple;">EntryPoint.sol</mark>](https://github.com/KintoXYZ/account-abstraction/blob/61f677923ad7ed0ed5b87d2c20100a7079dba63a/contracts/core/EntryPoint.sol)

***

## Basics

* Serves as a single EntryPoint implementation for Account Abstraction (EIP-4337).
* Manages user operations, including validation, execution, and compensation for operations.
* Supports aggregated operations from multiple aggregators.
* Implements functionalities related to stake management and nonce management.
* Provides interface support checks and utilities for handling delegate calls and reverts

***

### State Functions

```
setWalletFactory(address _walletFactory) external

handleOps(UserOperation[] calldata ops, address payable beneficiary) public nonReentrant

handleAggregatedOps(UserOpsPerAggregator[] calldata opsPerAggregator, address payable beneficiary) public nonReentrant

getSenderAddress(bytes calldata initCode) public

delegateAndRevert(address target, bytes calldata data) external
```

***

1. **setWalletFactory** (**Admin only**)

Sets the wallet factory address.

```solidity
function setWalletFactory(address _walletFactory) external;
```

| Parameter        | Type      | Explanation                        |
| ---------------- | --------- | ---------------------------------- |
| `_walletFactory` | `address` | The address of the wallet factory. |

2. **handleOps**

Handles an array of user operations.

```solidity
function handleOps(UserOperation[] calldata ops, address payable beneficiary) public nonReentrant;
```

| Parameter     | Type                       | Explanation                  |
| ------------- | -------------------------- | ---------------------------- |
| `ops`         | `UserOperation[] calldata` | Array of user operations.    |
| `beneficiary` | `address payable`          | Address to receive the fees. |

3. **handleAggregatedOps**

Handles aggregated operations from multiple aggregators.

```solidity
function handleAggregatedOps(UserOpsPerAggregator[] calldata opsPerAggregator, address payable beneficiary) public nonReentrant;
```

| Parameter          | Type                              | Explanation                         |
| ------------------ | --------------------------------- | ----------------------------------- |
| `opsPerAggregator` | `UserOpsPerAggregator[] calldata` | Array of operations per aggregator. |
| `beneficiary`      | `address payable`                 | Address to receive the fees.        |

4. **getSenderAddress**

Gets the address of a sender based on the provided initialization code.

```solidity
function getSenderAddress(bytes calldata initCode) public;
```

| Parameter  | Type             | Explanation              |
| ---------- | ---------------- | ------------------------ |
| `initCode` | `bytes calldata` | The initialization code. |

5. **delegateAndRevert**

Delegates a call to another contract and reverts.

```solidity
function delegateAndRevert(address target, bytes calldata data) external;
```

| Parameter | Type             | Explanation                             |
| --------- | ---------------- | --------------------------------------- |
| `target`  | `address`        | The target address of the delegatecall. |
| `data`    | `bytes calldata` | The data to be sent in the call.        |

***

## View Function

<pre><code>supportsInterface(bytes4 interfaceId) public view virtual override returns (bool)

<strong>getUserOpHash(UserOperation calldata userOp) public view returns (bytes32)
</strong></code></pre>

***

1. **supportsInterface**

Checks if the contract supports an interface.

```solidity
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool);
```

| Parameter     | Type     | Explanation               |
| ------------- | -------- | ------------------------- |
| `interfaceId` | `bytes4` | The interface identifier. |

2. **getUserOpHash**

Gets the hash of a user operation.

```solidity
function getUserOpHash(UserOperation calldata userOp) public view returns (bytes32);
```

| Parameter | Type                     | Explanation         |
| --------- | ------------------------ | ------------------- |
| `userOp`  | `UserOperation calldata` | The user operation. |

***

## Events

1. **FailedOp** Emitted when an operation fails.

   ```solidity
   event FailedOp(uint256 opIndex, string reason);
   ```
2. **FailedOpWithRevert** Emitted when an operation fails with a revert reason.

   ```solidity
   event FailedOpWithRevert(uint256 opIndex, string reason, bytes returnData);
   ```
3. **PostOpRevertReason** Emitted when a post-operation reverts.

   ```solidity
   event PostOpRevertReason(bytes32 userOpHash, address sender, uint256 nonce, bytes revertReason);
   ```
4. **UserOperationRevertReason** Emitted when a user operation reverts.

   ```solidity
   event UserOperationRevertReason(bytes32 userOpHash, address sender, uint256 nonce, bytes revertReason);
   ```
5. **AccountDeployed** Emitted when an account is deployed.

   ```solidity
   event AccountDeployed(bytes32 userOpHash, address sender, address factory, address paymaster);
   ```
6. **BeforeExecution** Emitted before execution of operations.

   ```solidity
   event BeforeExecution();
   ```
7. **SignatureAggregatorChanged** Emitted when the signature aggregator is changed.

   ```solidity
   event SignatureAggregatorChanged(address aggregator);
   ```
8. **UserOperationEvent** Emitted for each user operation event.

   ```solidity
   event UserOperationEvent(bytes32 userOpHash, address sender, address paymaster, uint256 nonce, bool success, uint256 actualGasCost, uint256 actualGas);
   ```
9. **PostOpReverted** Emitted when a post-operation is reverted.

   ```solidity
   event PostOpReverted(bytes reason);
   ```
10. **SenderAddressResult** Emitted for the result of `getSenderAddress`.

    ```solidity
    event SenderAddressResult(address sender);
    ```
11. **DelegateAndRevert** Emitted when `delegateAndRevert` is called.

    ```solidity
    event DelegateAndRevert(bool success, bytes ret);
    ```


---

# 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://docs.kinto.xyz/kinto-the-modular-exchange/building-on-kinto/smart-contract-reference/kinto-entrypoint.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.
