Developers
Blueprint SDK Macros
Job Macro

Blueprint Jobs Macro System Documentation

The goal with the job macro is to provide an easy and intuitive interface for creating a task based AVS service.

Developers can specify jobs for their AVS to complete and streamline on-chain transaction submissions to protocols like Tangle or Eigenlayer. The system is flexible and allows developers to listen to events from a variety of sources such as Tangle's job submission/execution system, an EVM smart contract's events, periodic timers for cron-job like tasks, as well as custom event listeners.

These job functions are triggered every time the respective event listener fires, and can be synchronous or asynchronous.

The jobs system is continuously being improved and the API may continue to change. We welcome you to share feature requests and PRs on our github (opens in a new tab).

The #[job] Macro

The #[job] macro is used to define individual tasks or jobs within a blueprint. It allows you to specify various parameters and metadata for each job.

  • id: A unique identifier for the job.
  • params: A list of parameters that the job accepts.
  • result: The type of result the job produces (often represented by an underscore _).
  • event_listener: Specifies the event listener that triggers the job.

Non-Tangle Blueprint Jobs

For other restaking protocols and job verification mechanisms, developers should use or implement custom handlers.

An example of doing this to replicate Tangle's default implementation is as follows:

struct Context;
 
struct CustomTangleJobCallListener {
    instance: <contract_instance>,
}
 
impl EventListener for CustomJobCallListener {
    fn next_event();
    fn handle_event();
}
 
#[job(
    id = <job_id>,
    params(<parameters>),
    result(<result_type>),
    event_listener(
        listener = CustomTangleJobCallListener,
    )
)]
pub fn job_name(<parameters>, ctx: Context) -> Result<<return_type>, <error_type>> {
    // Job implementation
}

Examples

Incredible Squaring Simple

The basic Incredible Squaring blueprint includes a simple_squaring job that squares a given input value x. This job is triggered by the Tangle's JobCalled event.

Incredible Squaring Eigenlayer

Squaring Job

The Eigenlayer Incredible Squaring blueprint includes a compute_x_square job that squares a given input value x. This job is triggered by the NewTaskCreated event. The result is signed with a BLS key and sent to an external service for aggregating the BLS signatures.

Initialize Task Job

The Eigenlayer Incredible Squaring blueprint includes an initialize_task job, executed by the aggregator service, that initializes the task and sets up the necessary parameters for the squaring job. This job is triggered by the NewTaskCreated event.

MPC Keygen

This example demonstrates how to use the FROST keygen job to generate a new keypair for a multi-party computation (MPC) threshold signature scheme. The keypair can be used to sign messages in a distributed manner in subsequent jobs.

MPC Threshold Signature

This example demonstrates how to use the FROST signing job to sign a message using a multi-party computation (MPC) threshold signature scheme. The job requires a valid keypair generated by the keygen job.