Javascript/Typescript SDK
Javascript/Typescript SDK for interacting with the Ava Protocol EigenLayer AVS.
Overview#
This Javascript/Typescript SDK provides a client for interacting with the Ava Protocol AVS, allowing you to manage smart wallets and tasks. It is built on top of gRPC and provides methods for authentication, wallet management, and task management.
The code of this open source project is available at https://github.com/AvaProtocol/ava-sdk-js
Installation#
To install the SDK, use npm or yarn:
npm install ava-sdk-js
Or with Yarn:
yarn add ava-sdk-js
Usage#
Importing the SDK#
import Client from 'ava-sdk-js';
import { ClientOption, RequestOptions } from 'ava-sdk-js/types';
Client Initialization#
To initialize the client, you need to provide a ClientOption
object with the endpoint:
const client = new Client({
endpoint: 'https://your-endpoint.com',
});
Authentication#
Signature Authentication#
Authenticate using a signature:
const response = await client.authWithSignature('address', 'signature', expiredAtEpoch);
console.log(response.authKey);
Wallet Management#
List Smart Wallets#
Retrieve a list of smart wallets:
const wallets = await client.listSmartWallets({ authKey: 'your-auth-key' });
console.log(wallets);
Create Wallet#
Create a new smart wallet:
const wallet = await client.createWallet({ salt: 'your-salt', factoryAddress: 'factory-address' }, { authKey: 'your-auth-key' });
console.log(wallet);
Task Management#
Create Task#
Create a new task:
const taskId = await client.createTask(payload, { authKey: 'your-auth-key' });
console.log(taskId);
List Tasks#
List all tasks associated with a smart wallet:
const tasks = await client.listTasks('smart-wallet-address', { authKey: 'your-auth-key' });
console.log(tasks);
Get Task#
Retrieve a specific task by ID:
const task = await client.getTask('task-id', { authKey: 'your-auth-key' });
console.log(task);
Cancel Task#
Cancel a task by ID:
const success = await client.cancelTask('task-id', { authKey: 'your-auth-key' });
console.log(success);
Delete Task#
Delete a task by ID:
const success = await client.deleteTask('task-id', { authKey: 'your-auth-key' });
console.log(success);
Types#
The SDK exports several types for easier use:
ClientOption
RequestOptions
SmartWallet
TaskType
CreateWalletReq
GetKeyResponse
ListTasksResponse
CancelTaskResponse
DeleteTaskResponse
CreateTaskResponse
Additional Exports#
The SDK also exports the getKeyRequestMessage
function for advanced use cases.
Error Handling#
The SDK methods throw errors when operations fail. Ensure to handle these errors appropriately in your application.
License#
This SDK is licensed under the Apache License 2.0.
SDK API References#
authWithSignature#
Authenticate using a signature signed by the user's EOA(MetaMask, WalletConnect, etc.) wallet.
Parameters#
Name | Type | Description |
---|---|---|
address | string | The user's address. |
signature | string | The signature for authentication. |
expiredAtEpoch | number | The expiration epoch for the signature. |
Returns#
Promise<GetKeyResponse>
- The authentication key response.
listSmartWallets#
Retrieve a list of smart wallets.
Parameters#
Name | Type | Description |
---|---|---|
options | RequestOptions | Request options, including authentication. |
Returns#
Promise<SmartWallet[]>
- A list of smart wallets associated with the user.
createWallet#
Create a new smart wallet.
Parameters#
Name | Type | Description |
---|---|---|
salt | string | The salt value for wallet creation. |
factoryAddress | string | The factory address (optional). |
options | RequestOptions | Request options, including authentication. |
Returns#
Promise<SmartWallet>
- Details of the created wallet.
createTask#
Create a new task for automation.
Parameters#
Name | Type | Description |
---|---|---|
payload | any | The task payload including trigger, nodes, and edges. |
options | RequestOptions | Request options, including authentication. |
Returns#
Promise<string>
- The ID of the created task.
listTasks#
Retrieve a list of tasks associated with a smart wallet.
Parameters#
Name | Type | Description |
---|---|---|
address | string | The smart wallet address. |
options | RequestOptions | Request options, including authentication. |
Returns#
Promise<Task[]>
- A list of tasks for the specified wallet.
getTask#
Retrieve details of a specific task.
Parameters#
Name | Type | Description |
---|---|---|
id | string | The ID of the task to retrieve. |
options | RequestOptions | Request options, including authentication. |
Returns#
Promise<TaskType>
- Details of the specified task.
cancelTask#
Cancel an existing task.
Parameters#
Name | Type | Description |
---|---|---|
id | string | The ID of the task to cancel. |
options | RequestOptions | Request options, including authentication. |
Returns#
Promise<boolean>
- True if the task was successfully canceled, otherwise false.
deleteTask#
Delete an existing task.
Parameters#
Name | Type | Description |
---|---|---|
id | string | The ID of the task to delete. |
options | RequestOptions | Request options, including authentication. |
Returns#
Promise<boolean
- True if the task was successfully deleted, otherwise false.