Skip to content

Latest commit

 

History

History
156 lines (91 loc) · 3.72 KB

File metadata and controls

156 lines (91 loc) · 3.72 KB

EntryPoint API

The following are APIs of EntryPoint contract. EntryPoint contract is a pre-deployed global contract on every EVM-compatible blockchain who wants to support ERC-4337. Thus, for the contract wallet and paymaster development, please follow the APIs of EntryPoint.

handleOps

function handleOps(userOperation[] calldata ops, address payable beneficiary) external {}

handleOps() is one of the core functions in EntryPoint. All UserOperation logic execution will be handled in this function.

  • Parameters:

    • ops: a batch of user operations to be execute
    • beneficiary: the address to receive the collected fees of all UserOperations.
  • Requirements:

    • paymasterData and signature included in UserOperation need to be valid.
  • Return:

    • N/A
  • Events:

    • an event emitted if the UserOperation "callData" reverted with non-zero length.
    event UserOperationRevertReason(
      bytes32 indexed requestId,
      address indexed sender,
      uint256 nonce,
      bytes revertReason
    )
    • an event emitted after each successful request. Only emitted in _handlePostOp().
    event UserOperationEvent(
      bytes32 indexed requestId,
      address indexed sender,
      address indexed paymaster,
      uint256 nonce,
      uint256 actualGasCost,
      uint256 actualGasPrice,
      bool success
    )

simulateValidation

function simulateValidation(UserOperation calldata userOp) external returns (uint256 preOpGas, uint256 prefund) {}

As stated in ERC-4337 specification,

Before accepting a UserOperation, bundlers must use an RPC method to locally simulate calling the simulateValidation() function of the entry point contract, to verify that the signature is correct and the operation actually pays fees.

  • Parameters:

    • userOp: the UserOperation which needs to be verified.
  • Requirements:

    • N/A
  • Return:

    • preOpGas: total gas used by validation (including contract creation)
    • prefund: the amount the wallet had to prefund (zero in case a paymaster pays).
  • Events:

    • N/A

getRequestId

function getRequestId(UserOperation calldata userOp) public returns (bytes32) {}
  • Parameters:

    • userOp: the UserOperation which need a requestId.
  • Requirements:

    • N/A
  • Return:

    • requestId is a unique identifier for a userOperation request. It is a hash over the content of the userOp (except the signature), the entrypoint and the chainId.
  • Events:

    • N/A

getSenderAddress

function getSenderAddress(bytes memory initCode, uint256 salt) public view returns (address) {}

Calculate the sender contract address that will be generated by the initCode and salt in the UserOperation.

  • Parameters:

    • initCode: the contract initCode to be passed into the UserOperation.

    • salt: the salt parameter, to be passed as "nonce" in the UserOperation.

    • [NOTICE]: The definition for initCode and runtime ByteCode is different, please take care here. You could check this article for reference.

  • Requirements:

    • N/A
  • Return:

    • sender contract address
  • Events:

    • N/A

getSenderStorage

function getSenderStorage(address sender) external view returns (uint256[] memory senderStorageCells) {}

During simulateValidation, allow these returned storage cells to be accessed. A wallet/paymaster are allowed to access their own deposit balance on the EntryPoint's storage, but no other account.

  • Parameters:

    • sender: sender waller contract address.
  • Requirements:

    • N/A
  • Return:

    • the storage cells used internally by the EntryPoint for this sender address.
  • Events:

    • N/A