Layer LogoLayer AVS Docs
About

How Layer AVSs work

Layer contract flow

Build your AVS

Layer is the easiest platform to build and run AVSs quickly and securely. Most web3 applications rely on centralized infrastructure and legacy systems to function, undermining the goal of decentralized applications. Instead of relying on these systems, Layer leverages Ethereum security via Eigenlayer to enable fully customizable AVSs that can run arbitrary functions off-chain and be verified on-chain in a decentralized manner. Through the power of WASM, Layer allows you to build full-stack decentralized applications.

What is an AVS?

AVSs (Actively Validated Services) are computational services that are run offchain and that can be verified onchain. Traditional smart contracts are limited in that they are only designed to run verifiable onchain functions. However, most real-world applications rely on offchain processes to function. Because blockchains are opaque to the validity of offchain data, there needs to be some way to verify offchain processes. This is where AVSs come in.

Layer AVSs enable the execution of off-chain computational processes and bring the results of these processes onchain in a verifiable way. To achieve this, AVSs use node participants called operators to run their processes. When a process is run offchain by an operator, the results are then checked by a verifier contract which verifies that multiple operators have run the process and that the result is accurate. AVSs can configure their operator set and parameters in their onchain contracts.

AVSs can be any offchain process that can be run and verified by an operator, including simple mathematical computations, price oracles, decentralized front-ends, defi applications, and even decentralized AI agents. By leveraging economic security from Ethereum, Layer AVSs enable a new generation of applications and general compute that can be decentralized at every point, both off and onchain.

WASM

Web Assembly (WASM) is a high-performance, low-level binary format that can be compiled from code written in a variety of languages. It provides a secure, sandboxed environment, ensuring safe execution by isolating code from the host system. WASM can even be run in web browsers at near-native speed. With the power of WASM, Layer AVSs are lightning-fast, lightweight, and easy to build.

Layer AVSs use onchain, WASM-based smart contracts to configure an AVS. The contracts are written in Rust and compiled to WebAssembly. These WebAssembly binaries are deployed to the chain and can be executed via messages onchain. WASM-based smart contracts are designed for ease of use, security, and composability.

Services

Services are the core functionality of an AVS on Layer. They consist of WASM components, which contain the logic to be run offchain. Services are compiled to WebAssembly and runs in a WASI (WebAssembly System Interface) environment.

AVS developers can create services using WASM components for operators to run offchain and verify onchain, enabling an ecosystem of decentralized computation and applications. AVS WASM components can be any arbitrary computational processes an AVS may need to function.

While other AVS platforms require thousands of lines of code across multiple files to run a simple computational task, a Service using layer can be built in only a few lines in a single file. Visit the Layer Squaring Service Example to see how lightweight and powerful building a service with Layer can be.

How it works

The following customizable contracts are used to create a Layer AVS:

Task Queue Contract

This contract manages the lifecycle of tasks, from submission to completion. Tasks are triggered by onchain events that are configured to meet the needs of the AVS. Operators listen for these task triggers and run the AVS's WASM component offchain.

Operator Contract

This contract is in charge of the operators that run the offchain WASI components. Only the operators specified in this contract can submit the results of their offchain computations and be verified. This contract also sets the voting parameters and quorom consensus thresholds for operators.

Verifier Contract

When a task is complete, operators submit the results to the verifier contract and come to a consensus on the validity of the results. This contract interfaces with the operator's contract to ensure that only specified operators are allowed to submit results.

The Flow

Layer contract flow

Here's how these components interact in a typical AVS workflow:

  1. A task is submitted to the Task Queue Contract onchain.

  2. Operators listen for tasks in the queue and run the WASI components off-chain.

  3. Operators submit their results to the Verifier Contract.

  4. The Verifier Contract checks with the Operators Contract to ensure the operators are eligible to vote.

    • If a quorum is reached (enough operators agree on the result), the Validators Contract notifies the Task Queue Contract of the task's completion.
    • The Task Queue Contract marks the task as complete and makes the result available.

In the Squaring Service example, the task is submitted onchain with an input number (in this case, let's use the number 4). Operators runs the AVS, and submit the result (16, which is 4 times 4). The verifier contract compares the results and ensures that the operators agree that 16 is the agreed result. The task is marked complete, and the result is made available onchain.

Layer security

Security for AVSs and operators on Layer and their incentive to run reliably and truthfully relies on a system of economic security called Commitments. To learn more about Layer security, visit the Commitments page.

On this page