Customizing Caldera Chains with Stateful Precompiles

Customizing Caldera Chains with Stateful Precompiles

We’re excited to introduce our latest feature, stateful precompiles, which will offer a new interface for developers to customize and add functionality to their Caldera chains without writing a single line of Solidity.

What are stateful precompiles?

To explain stateful precompiles, let’s first establish an understanding of EVM precompiles more broadly.

Precompiles are used to implement cryptographic operations and other functions in Ethereum that would be difficult and inefficient to implement with Solidity. These standard precompiles are stateless and typically leverage existing libraries. Put simply, precompiles are essentially a shortcut to execute a function implemented by the EVM itself, rather than an actual contract. They use the following simple interface:

Stateful precompiles build upon precompiles in the EVM by injecting state access into the execution function of a standard precompile. By doing so, stateful precompiles can maintain their own state space as well as interact with the EVM’s state, enabling a significantly wider range of functionality.

At a high level, implementing stateful precompiles on your Caldera chain only consists of the following steps:

  1. Generate the Precompile
  2. Setup precompile config
  3. Add Custom Code
  4. Set Gas Costs
  5. Register Precompile

By using the same language that implements the EVM, stateful precompiles can be executed faster and at a lower cost than programs written in Solidity and executed within the EVM interpreter. That means that anything you could previously build in a smart contract, you can now build more efficiently and cost-effectively in a stateful precompile.

Empowering developers

Now that you have the theory down, you might be wondering, “so what can I actually build with a stateful precompile?”

In practice, stateful precompiles can be used for all the following:

  • Mint the native coin of an EVM instance
  • Deploy more performant & gas-efficient smart contracts
  • Implement on-chain verifiable random functions
  • Construct an allowlist to restrict access on who can execute contract deployments
  • Enable contract secured revenue, a fee-splitting model that awards developers a percentage of all transaction fees paid to the network when users interact with their app on Caldera.

Ultimately, the possible implementations are only limited by your imagination, and we can't wait to see what our developer community comes up with.

Our hope is that these stateful precompiles introduce a new frontier for developer-friendly tooling in Web3, and brings us another step forward towards our goal of empowering developers to build applications without compromises.