Documentation for Nodes in the EigenLayer-AVS system.
This document provides a comprehensive overview of Nodes in the AVA SDK JS. Nodes are the fundamental building blocks of workflows, representing individual tasks or actions that can be performed as part of an automated process. This page details the various types of nodes available, their configuration options, and how to use them effectively in your workflows.
For information about how nodes fit into the larger workflow system, see Workflow System. For details on how workflows are triggered, see Triggers. For information about workflow execution, see Executions.
Nodes are modular components that perform specific operations within a workflow. Each node represents a discrete task, such as transferring ETH, interacting with a smart contract, making API calls, or controlling the flow of execution. Nodes are connected by edges to form a directed graph, which defines the execution flow of a workflow.
Sources:
In the AVA SDK, nodes are created using the NodeFactory, which provides a consistent interface for creating nodes of different types. Each node has a unique identifier, a name, a type, and type-specific configuration data.
Sources:
The AVA SDK supports a variety of node types, each designed for specific operations. These can be categorized into three main groups:
The following table summarizes the available node types:
| Category | Node Type | Description |
|---|---|---|
| Blockchain Interaction | ETHTransfer | Transfers ETH to a specified address |
| Blockchain Interaction | ContractWrite | Executes write operations on smart contracts |
| Blockchain Interaction | ContractRead | Reads data from smart contracts |
| External API | RestAPI | Makes HTTP requests to REST APIs |
| External API | GraphQLQuery | Executes GraphQL queries |
| Flow Control | Branch | Implements conditional logic |
| Flow Control | Filter | Filters data based on conditions |
| Flow Control | Loop | Iterates over collections |
| Utility | CustomCode | Executes user-defined code |
Sources:
Sources:
These nodes interact with blockchain networks to perform operations such as transferring ETH or interacting with smart contracts.
The ETHTransferNode is used to transfer ETH from the workflow's smart wallet to a specified destination address.
Configuration properties:
destination: The recipient's Ethereum addressamount: The amount of ETH to transfer (in wei)Sources:
The ContractWriteNode is used to execute state-changing operations on smart contracts, such as transferring tokens or updating contract state.
Configuration properties:
contractAddress: The address of the smart contractcallData: The encoded function call datacontractAbi: The ABI of the smart contractSources:
The ContractReadNode is used to read data from smart contracts without changing state.
Configuration properties:
contractAddress: The address of the smart contractcallData: The encoded function call datacontractAbi: The ABI of the smart contractSources:
These nodes interact with external APIs to fetch or send data.
The RestAPINode is used to make HTTP requests to REST APIs.
Configuration properties:
url: The URL of the API endpointmethod: The HTTP method (GET, POST, PUT, DELETE, etc.)body: The request body (for POST, PUT requests)headersMap: Headers to include in the requestSources:
The GraphQLQueryNode is used to execute GraphQL queries.
Configuration properties:
url: The URL of the GraphQL endpointquery: The GraphQL query stringvariablesMap: Variables to include in the querySources:
These nodes control the execution flow of the workflow based on conditions or collections.
The BranchNode implements conditional logic by evaluating expressions and determining which branch of the workflow to execute.
Configuration properties:
conditionsList: A list of conditions to evaluateSources:
The FilterNode filters data based on a specified expression.
Configuration properties:
expression: The filtering expressioninput: The input data to filterSources:
The LoopNode iterates over a collection and executes a specified node for each item.
Configuration properties:
input: The collection to iterate overiterVal: The variable name for the current itemiterKey: The variable name for the current indexSources:
The CustomCodeNode executes user-defined code.
Configuration properties:
lang: The language of the code (currently only JavaScript is supported)source: The source code to executeSources:
The NodeFactory provides a convenient way to create nodes. It offers two methods:
createNodes(nodeConfigs: NodeConfig[]): Creates multiple nodes from an array of configurationscreate(nodeConfig: NodeConfig): Creates a single node from a configurationSources:
Node data properties can include template expressions that are evaluated at runtime. Templates use the {{ expression }} syntax and can reference outputs from previous nodes, trigger data, and context variables.
In this example:
{{apContext.configVars.bot_token}} references a configuration variable{{ chatId }} references a variable in the context{{ checkPrice.data.toString() }} references the output of a previous node named "checkPrice"Sources:
When a workflow is executed, each node is processed in the order defined by the workflow's edges. Each node type produces a specific output structure that can be referenced by subsequent nodes.
Each node type produces different output structures:
| Node Type | Output Structure | Description |
|---|---|---|
| ETHTransferNode | { transactionHash: string } | Hash of the transaction |
| ContractWriteNode | { userOp: UserOp, txReceipt: TransactionReceipt } | User operation and transaction receipt |
| ContractReadNode | { dataList: Value[] } | Array of return values |
| RestAPINode | { data: any } | Response data |
| GraphQLQueryNode | { data: any } | Query result data |
| BranchNode | { conditionId: string } | ID of the matched condition |
| FilterNode | { data: any } | Filtered data |
| LoopNode | { data: string } | Aggregated results |
| CustomCodeNode | { data: any } | Returned data from the code |
Sources:
If a node execution fails, the error is captured in the execution record, and the workflow may continue or stop depending on the workflow configuration. Error information includes:
Sources:
The following example creates a workflow that:
Sources:
This example creates a workflow that monitors for ERC-20 token transfers to a specific address and sends a notification when a transfer over a certain amount occurs:
Sources:
Nodes are the fundamental building blocks of workflows in the AVA SDK. They enable a wide range of operations, from blockchain interactions to external API calls and flow control. By combining different node types and connecting them with edges, you can create complex automation workflows that respond to various triggers and perform actions based on conditions and data.
By understanding the different node types and their configuration options, you can leverage the full power of the AVA SDK to create sophisticated automation solutions for your blockchain applications.