Developers
Build a Tangle Blueprint AVS

Getting Started with Tangle Blueprints

Welcome to the Tangle Blueprint tutorial! This guide will walk you through creating a simple Hello World Blueprint for Tangle. By the end of this tutorial, you'll have a basic understanding of how to create, build, and deploy a Tangle Blueprint.

What are Tangle Blueprints?

Tangle Blueprints are specifications for Actively Validated Services (AVS) on the Tangle Network. An AVS is an off-chain service that runs arbitrary computations for a user-specified period of time. Blueprints provide a useful abstraction, allowing developers to create reusable service infrastructures similar to smart contracts.

Prerequisites

Before you begin, ensure you have the following installed:

Creating my First Blueprint

See the CLI Quickstart for instructions on creating a blueprint.

Key Files

src/lib.rs

This file contains the core logic of your Blueprint, including job definitions, report structures, and event listeners. Here's an example of a simple "Hello World" job:

  1. Jobs: Define the main computational tasks of your Blueprint. For more details on creating jobs, see our Blueprint Job Documentation.

  2. Reports: Define offchain reporting logic for the custom slashing functionality of your Blueprint. Learn more about reports in our Blueprint Report Documentation.

  3. Event Listeners: Set up listeners to react to on-chain events, offchain events, cron-job like listeners, and even custom event triggers. For a deep dive into event listeners, check out our Event Listener Documentation.

Here's a basic example incorporating these elements:

This job takes an optional who parameter and returns a greeting.

src/main.rs

This file serves as the entry point for your Actively Validated Service (AVS) node. It sets up the runtime environment, initializes the necessary components, and starts the event watcher. Here's a breakdown of its key responsibilities:

  1. Environment Setup: It loads the configuration, initializes the logger, and sets up error handling.
  2. Client Initialization: It creates a connection to the Tangle Network using the provided RPC endpoint.
  3. Registration: It checks if the node should run registration (implementation pending).
  4. Event Handler Creation: It instantiates the event handler for the say_hello job.
  5. Event Watcher: It starts the Substrate event watcher, which listens for relevant events on the Tangle Network.

This sets up the AVS node, initializes the environment, and starts the event watcher.

Building Your Project

To build your project, run:

cargo build

This command compiles your Rust code and checks for any errors.

Deploying Your Blueprint

See deploying your blueprint.

Next Steps

Congratulations! You've created, built, and deployed your first Tangle Blueprint. Here are some suggestions for what to do next:

  1. Explore more complex job implementations in your lib.rs file. Learn more about Jobs and the Job Macro system.

  2. Implement reporting mechanisms using the Reports Macro to ensure the integrity of your AVS.

  3. Dive deeper into Event Listeners to understand how to trigger your jobs and reports based on various events.

  4. Learn about Context and Context Extensions to manage dependencies and state in your Blueprint.

  5. If you're interested in building for EigenLayer, check out our guide on Building an EigenLayer AVS.

  6. Implement tests for your Blueprint using tokio::test. Learn more about Testing Blueprints.

  7. Explore the Tangle network's features and how they interact with your Blueprint. Understand EVM and Native Addresses and EVM to Substrate transfers.

  8. Familiarize yourself with EVM Precompiles available on Tangle Network.

  9. Learn about Deploying Contracts with Hardhat for more advanced contract deployment scenarios.

For more advanced topics and in-depth information, check out our other documentation pages and the Rust async book (opens in a new tab).

If you encounter any issues or have questions, please don't hesitate to open an issue on our GitHub repository (opens in a new tab). We're here to help you succeed in building with Tangle Blueprints!

For more advanced topics and in-depth information, check out our other documentation pages and the Rust async book (opens in a new tab).

Feedback and Support

If you encounter any issues or have questions, please don't hesitate to open an issue on our GitHub repository (opens in a new tab). We're here to help you succeed in building with Tangle Blueprints!