DevelopersBuild a Tangle Blueprint

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.

Blueprint Workspace Structure

Tangle Blueprints are structured as Rust workspaces with multiple packages:

  1. Library Package: Contains the core logic of your Blueprint, including job definitions.
  2. Binary Package: Contains the entry point for your Blueprint runner.

Key Files

lib/src/lib.rs

This file contains the core logic of your Blueprint, including job definitions. Jobs are the main computational tasks that your Blueprint will execute. Here’s an example of a simple “Hello World” job:

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

For more details on creating jobs, see our Blueprint Job Documentation.

bin/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 Blueprint Runner. 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. Router Configuration: It sets up the router that directs job calls to the appropriate handlers.
  4. Producer Setup: It configures producers that listen for events and prepare them for processing.
  5. Consumer Setup: It configures consumers that handle processed results.
  6. Background Services: It initializes optional background services required for jobs.
  7. Blueprint Runner: It starts the Blueprint Runner, which orchestrates all components.

Blueprint Runner Architecture

The Blueprint Runner is the core component that orchestrates the execution of your Blueprint. It consists of several key components:

Router

The router is responsible for directing job calls to the appropriate job handlers based on job IDs. When a job is called, the router identifies the correct handler and passes the job parameters to it.

Producers

Producers listen for events (such as on-chain events from Tangle Network) and prepare them for processing. They convert raw event data into a format that can be processed by your job handlers.

Consumers

Consumers handle the results of processed jobs. They can perform actions such as sending transactions, updating state, or triggering other processes based on job results.

Background Services

Background services are optional components that run continuously in the background. They can perform tasks such as monitoring, data collection, or periodic operations that are required for your jobs.

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 library package. Learn more about Jobs.

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

  3. Customize your Blueprint Runner with additional producers, consumers, and background services to handle more complex scenarios.

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

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

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

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

  8. Learn about about advanced options when Deploying Blueprints.

For more advanced topics and in-depth information, check out our other documentation pages and the Rust async book.

Feedback and Support

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

Last updated on