Precompile Utilities
Helper functions for bridging Go logic with EVM state and ABI standards
The Precompile Utilities package provides essential abstraction layers for developers building stateful precompiles on Maroo. It simplifies the complex task of decoding Solidity-encoded arguments into Go structures and handles the low-level mechanics of emitting EVM-compatible events from within Go code. These utilities ensure that custom precompiles behave indistinguishably from standard smart contracts to external indexers and dApps.
Key Features
Seamless Event Emission
Injects logs directly into the EVM StateDB, supporting indexed topics and data packing.
ABI-to-Struct Mapping
Converts generic EVM input arguments into strongly-typed Go structs via JSON intermediate representation.
Architecture
graph TD
A[EVM Call] -->|Args| B(Precompile Run)
B -->|Unpack| C{ParseStructFromAbi}
C -->|JSON Marshal/Unmarshal| D[Go Struct]
D --> E[Business Logic]
E -->|Result| F{EmitEvent}
F -->|Pack Topics/Data| G[StateDB Log]
G --> H[Tx Receipt] Data flow from EVM execution to Go logic and back to EVM logs
Bridging the Gap
utils package solves this by leveraging JSON as a universal interchange format, allowing developers to define input expectations using standard Go struct tags rather than manual byte slicing.Observability via Events
EmitEvent function abstracts the complexity of topics (indexed parameters) and data (non-indexed parameters). It automatically validates the arguments against the provided ABI, ensuring that the emitted logs are always strictly typed and parseable by standard Ethereum tooling.