Introduction to Precompiles
What is a Precompile?
Precompiles are specialized EVM smart contracts with fixed addresses and predefined functionality. Unlike regular contracts, their code is embedded into the blockchain runtime, enabling highly efficient execution of specific tasks.
Context in Our Ecosystem
Our blockchain is built on a Substrate-based framework that utilizes pallets—modular components responsible for executing various aspects of the blockchain’s logic. While our core functionality runs within these pallets, we also support an EVM environment. Precompiles serve as a bridge between our native extrinsics (triggered by pallets) and the EVM, allowing smart contracts to access underlying blockchain functions seamlessly.
How Precompiles Work
Each precompile encapsulates a set of operations (such as managing decentralized identities, storage, role-based access control, token standards like ERC-20, and vesting mechanisms) as EVM-compatible smart contracts. They are deployed with preset values and built-in functions that convert EVM calls into substrate extrinsics. This allows developers to call these functionalities using familiar EVM interfaces, while the heavy lifting is done by the underlying substrate pallets.
Benefits
-
Efficiency: Direct integration into the runtime means that precompiles execute faster and more efficiently than equivalent logic implemented entirely in EVM bytecode.
-
Security & Stability: Because their functionality is defined at the protocol level, precompiles are rigorously tested and maintained, ensuring consistent performance and security.
-
Enhanced Interoperability: They allow for seamless interaction between native substrate features and EVM-based smart contracts, broadening the scope of decentralized applications built on our blockchain.
Overview of Precompile Modules
The subsequent pages in this documentation provide detailed information on some available precompiles:
- DID Precompile: Manages decentralized identities (called directly in sdk).
- Storage Precompile: Handles specialized storage operations (called directly in sdk).
- RBAC Precompile: Implements role-based access control features (called directly in sdk).
- ERC-20 Precompile: Facilitates standard ERC-20 token operations for native peaq.
- Vesting Precompile: Manages token vesting schedules and related functionalities. For an exhaustive list of all of our precompiles please view the peaq network node.
Summary
This introductory page sets the stage for understanding how precompiles integrate deeply with our Substrate-based blockchain. The following sections will dive into each precompile’s specifics, offering insights, usage examples, and best practices for harnessing their capabilities in your applications.