System Hooks

Learn about the System Hooks

System hooks are special functions that can be triggered by a call on a specific system address. The space for this special addresses is specified in the bootloader configuration.

System hooks have two distinct use cases:

  • Implementing precompiles like EVM. We currently support the following precompiles at their EVM addresses:
    • ecrecover
    • sha256
    • ripemd-160
    • identity
    • modexp
    • ecadd
    • ecmul
    • ecpairing
  • Implementing system contracts: formal contracts that implement some system functionality, like Era's nonce holder. Needed to support EraVM.
    • L1 messenger system hook
    • L2 Base token system hook
    • Contract deployer system hook

L1 Messenger System Hook

The L1 messenger system hook is responsible for sending messages to the L1. Users can call it using the special interface. The input should be encoded as calldata for the sendToL1(bytes) method following the Solidity ABI.

The implementation of the L1 messenger system hook does two things: decodes the input and records the message using the system method.

L2 Base Token System Hook

The L2 base token system implements only two methods: withdraw(address), withdrawWithMessage(address,bytes).

These are required to support EraVM-like base token withdrawals.

Contract Deployer System Hook

The contract deployer system hook implements only one method: setDeployedCodeEVM(address,bytes).

It allows setting arbitrary deployed EVM bytecode at any address, but can only be called by a special system address. It is used exclusively by protocol upgrade transactions approved through governance.


Made with ❤️ by the ZKsync Community