StateReceiver
The IStateReceiver
interface is designed to handle state updates received from a higher-level entity, typically on the L2 side of the childchain. This user guide will explain how to interact with the functions provided by the IStateReceiver
interface.
Functions
onStateReceive()
This function is called when the contract receives a state update. It processes the incoming state, allowing the contract to react to changes in the higher-level state.
Parameters
counter
(uint256): A counter value associated with the state update.sender
(address): The entity's address sending the state update.data
(bytes): The calldata associated with the state update.
Usage
To handle a state update in your contract, you must implement the onStateReceive() function. The higher-level entity will call this function when a state update is sent.
For example, you might implement onStateReceive() as follows:
contract MyStateReceiver is IStateReceiver {
function onStateReceive(uint256 counter, address sender, bytes calldata data) external override {
// Process the incoming state update
// ...
}
}
This function allows your contract to react to state updates, enabling communication between your contract and higher-level state providers. By implementing the IStateReceiver
interface, you can ensure that your contract stays current with broader ecosystem changes.