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:
- Rust (opens in a new tab)
- Forge (opens in a new tab)
- Tangle (opens in a new tab)
cargo-tangle
CLI tool
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:
-
Jobs: Define the main computational tasks of your Blueprint. For more details on creating jobs, see our Blueprint Job Documentation.
-
Reports: Define offchain reporting logic for the custom slashing functionality of your Blueprint. Learn more about reports in our Blueprint Report Documentation.
-
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:
- Environment Setup: It loads the configuration, initializes the logger, and sets up error handling.
- Client Initialization: It creates a connection to the Tangle Network using the provided RPC endpoint.
- Registration: It checks if the node should run registration (implementation pending).
- Event Handler Creation: It instantiates the event handler for the
say_hello
job. - 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
Next Steps
Congratulations! You've created, built, and deployed your first Tangle Blueprint. Here are some suggestions for what to do next:
-
Explore more complex job implementations in your
lib.rs
file. Learn more about Jobs and the Job Macro system. -
Implement reporting mechanisms using the Reports Macro to ensure the integrity of your AVS.
-
Dive deeper into Event Listeners to understand how to trigger your jobs and reports based on various events.
-
Learn about Context and Context Extensions to manage dependencies and state in your Blueprint.
-
If you're interested in building for EigenLayer, check out our guide on Building an EigenLayer AVS.
-
Implement tests for your Blueprint using
tokio::test
. Learn more about Testing Blueprints. -
Explore the Tangle network's features and how they interact with your Blueprint. Understand EVM and Native Addresses and EVM to Substrate transfers.
-
Familiarize yourself with EVM Precompiles available on Tangle Network.
-
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!