Client SDK and Examples

This page documents the client SDKs for interacting with the EigenLayer-AVS system and provides examples of their usage.

This page documents the client SDKs for interacting with the EigenLayer-AVS system and provides examples of their usage. The SDK allows developers to create applications that communicate with the Aggregator service, manage tasks, interact with smart wallets, and utilize the distributed task execution capabilities of the EigenLayer-AVS network.

For information about the Aggregator component itself, see Aggregator.

SDK Overview#

The EigenLayer-AVS system currently provides a JavaScript/Node.js client SDK for interacting with the Aggregator service. The SDK is built on top of gRPC and provides a simple interface for performing all operations supported by the Aggregator.

Sources:

Installation and Setup#

To use the JavaScript SDK, you need to install the required dependencies:

Then you can import the SDK in your application:

SDK Configuration#

The SDK requires configuration to connect to the appropriate Aggregator endpoint based on your environment:

Sources:

SDK Architecture#

The SDK is composed of several core components that handle different aspects of interacting with the EigenLayer-AVS system:

gRPC Client#

The SDK uses gRPC to communicate with the Aggregator service. The gRPC client is initialized with the appropriate endpoint:

Authentication#

The SDK implements an authentication mechanism using wallet signatures to authenticate with the Aggregator:

Sources:

Core SDK Functions#

The JavaScript SDK provides several core functions for interacting with the Aggregator service:

Authentication and Key Management#

  • generateApiToken() - Generates an API token for authenticating subsequent requests

Smart Wallet Management#

  • getWallets() - Lists all smart wallets owned by the user
  • createWallet() - Creates a new smart wallet with the specified salt

Task Management#

  • createTask() - Creates a new task
  • listTask() - Lists all tasks created by specified smart wallets
  • getTask() - Gets details of a specific task
  • cancelTask() - Cancels a running task
  • deleteTask() - Permanently deletes a task

Task Execution#

  • triggerTask() - Manually triggers a task execution
  • listExecutions() - Lists all executions of a task
  • getExecution() - Gets details of a specific execution

Sources:

Task Data Model#

The SDK interacts with the Task data model, which consists of:

Sources:

Example: Creating and Authenticating a Client#

Sources:

Example: Managing Smart Wallets#

Sources:

Example: Creating a Task#

The following example demonstrates creating a task that monitors a price oracle and triggers a notification:

Example code:

Sources:

Example: Advanced Task with Event Monitoring#

The following example shows how to create a task that monitors blockchain events and sends notifications:

Sources:

Example: Monitoring External API Services#

This example demonstrates how to create a task that periodically monitors AAVE liquidity rates using GraphQL and REST APIs:

Sources:

SDK Task Management Operations Table#

The following table summarizes the main task management operations available in the SDK:

OperationFunctionDescription
Create TaskcreateTaskCreates a new task with specified nodes, edges, and trigger
List TaskslistTaskLists tasks created by specified smart wallets
Get TaskgetTaskGets details of a specific task by ID
Trigger TasktriggerTaskManually triggers execution of a task
Cancel TaskcancelTaskCancels a running task
Delete TaskdeleteTaskPermanently deletes a task

Sources:

Available Trigger Types#

The SDK supports various trigger types for tasks:

Trigger TypeDescriptionExample
ManualTask must be manually triggered by the user{ manual: true }
BlockTask triggered at specified block intervals{ block: { interval: 2 } }
CronTask triggered according to cron schedule{ cron: { schedule: ["0 */5 * * *"] } }
Fixed TimeTask triggered at specific timestamps{ fixed_time: { epochs: [timestamp1, timestamp2] } }
EventTask triggered when specified blockchain events occur{ event: { expression: "trigger1.data.topics[0] == 0x..." } }

Sources:

Node Types#

The SDK supports various node types for task execution:

Node TypeDescriptionExample Use Case
ContractWriteExecutes a write operation on a smart contractToken transfers, contract state updates
ContractReadReads data from a smart contractReading token balances, contract state
RestAPIMakes HTTP requests to REST APIsFetching external data, sending notifications
GraphQLQueryExecutes GraphQL queriesFetching data from Graph Protocol
BranchConditional logic for task flowExecuting actions based on conditions
CustomCodeExecutes custom JavaScript codeData transformation, complex calculations

Sources:

Testing and Debugging Tasks#

The SDK provides several methods to debug and monitor task executions:

  1. listExecutions() - Lists all executions of a task
  2. getExecution() - Gets detailed execution information, including steps and results
  3. Console logging - The example code includes extensive console logging for debugging

For detailed information about task execution and monitoring, see Task Engine.

Sources:

Feature this wiki to auto refresh weekly

Try DeepWiki on your private codebase with Devin