Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate EigenDA into Eliza #2926

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -945,4 +945,10 @@ ARBITRAGE_EVM_PRIVATE_KEY= # Private key for the wallet executi
FLASHBOTS_RELAY_SIGNING_KEY= # Signing key for Flashbots relay interactions
BUNDLE_EXECUTOR_ADDRESS= # Address of the bundle executor contract


# EigenDA Configuration
EVM_PRIVATE_KEY=
BASE_RPC_URL=https://base.drpc.org
# Optional: Default identifier to use for all operations (must be hex-encoded)
# If not provided, will use existing identifier or create a new one
# Example: 0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef
EIGENDA_IDENTIFIER=
1 change: 1 addition & 0 deletions agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
"@elizaos/plugin-zilliqa": "workspace:*",
"@elizaos/client-deva": "workspace:*",
"@elizaos/plugin-arbitrage": "workspace:*",
"@elizaos/plugin-eigenda": "workspace:*",
"readline": "1.3.0",
"ws": "8.18.0",
"yargs": "17.7.2"
Expand Down
23 changes: 23 additions & 0 deletions agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ import { nvidiaNimPlugin } from "@elizaos/plugin-nvidia-nim";
import { zxPlugin } from "@elizaos/plugin-0x";
import { hyperbolicPlugin } from "@elizaos/plugin-hyperbolic";
import { litPlugin } from "@elizaos/plugin-lit";
import { OpacityAdapter } from "@elizaos/plugin-opacity";
import { openWeatherPlugin } from "@elizaos/plugin-open-weather";
import { stargazePlugin } from "@elizaos/plugin-stargaze";
import { akashPlugin } from "@elizaos/plugin-akash";
import { quaiPlugin } from "@elizaos/plugin-quai";
import { eigendaPlugin } from "@elizaos/plugin-eigenda";
import Database from "better-sqlite3";
import fs from "fs";
import net from "net";
Expand Down Expand Up @@ -914,6 +920,18 @@ export async function initializeClients(
}

function getSecret(character: Character, secret: string) {
// Special handling for EigenDA secrets
if (secret === "EIGENDA_PRIVATE_KEY") {
return character.settings?.secrets?.EIGENDA_PRIVATE_KEY ||
character.settings?.secrets?.EVM_PRIVATE_KEY ||
process.env.EIGENDA_PRIVATE_KEY ||
process.env.EVM_PRIVATE_KEY;
}
if (secret === "BASE_RPC_URL") {
return character.settings?.secrets?.BASE_RPC_URL ||
process.env.BASE_RPC_URL ||
"https://base.drpc.org";
}
return character.settings?.secrets?.[secret] || process.env[secret];
}

Expand Down Expand Up @@ -984,6 +1002,7 @@ export async function createAgent(
opacityProverUrl: process.env.OPACITY_PROVER_URL,
modelProvider: character.modelProvider,
token: token,
eigenDAPrivateKey: process.env.EIGENDA_PRIVATE_KEY,
});
elizaLogger.log("Verifiable inference adapter initialized");
elizaLogger.log("teamId", process.env.OPACITY_TEAM_ID);
Expand Down Expand Up @@ -1294,6 +1313,10 @@ export async function createAgent(
getSecret(character, "ARBITRAGE_BUNDLE_EXECUTOR_ADDRESS")
? arbitragePlugin
: null,
getSecret(character, "EIGENDA_PRIVATE_KEY") &&
getSecret(character, "BASE_RPC_URL")
? eigendaPlugin
: null,
]
.flat()
.filter(Boolean),
Expand Down
4 changes: 2 additions & 2 deletions characters/eternalai.character.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "TrollDetective.Exe",
"plugins": [],
"clients": ["twitter"],
"modelProvider": "eternalai",
"clients": [],
"modelProvider": "openai",
"settings": {
"secrets": {},
"voice": {
Expand Down
2 changes: 1 addition & 1 deletion client/src/lib/info.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version": "0.1.9-alpha.1"}
{"version": "0.1.9"}
6 changes: 6 additions & 0 deletions packages/plugin-eigenda/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*

!dist/**
!package.json
!readme.md
!tsup.config.ts
167 changes: 167 additions & 0 deletions packages/plugin-eigenda/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
# @elizaos/plugin-eigenda - EigenDA Plugin for Eliza

The EigenDA plugin enables interaction with EigenDA's data availability layer through Eliza. It provides functionality for uploading data, retrieving data, and checking upload status on the EigenDA network.

## Features

- Upload data to EigenDA network
- Retrieve data using job ID, request ID, or batch header hash + blob index
- Check upload status
- Automatic identifier management
- Automatic balance monitoring and top-up
- Support for text, JSON, and binary data

## Installation

```bash
npm install @elizaos/plugin-eigenda
```

## Configuration

The plugin requires certain environment variables to be set. You can set these in your `.env` file or through your runtime environment:

```env
# Required
EVM_PRIVATE_KEY=your_private_key

# Optional (defaults provided)
API_URL=http://3.220.4.143:5000
BASE_RPC_URL=https://base.drpc.org
CREDITS_CONTRACT_ADDRESS=0x0CC001F1bDe9cd129092d4d24D935DB985Ce42A9
EIGENDA_IDENTIFIER=your_hex_identifier # Optional: Use a specific identifier for all operations
```

### Environment Variables

| Variable | Required | Default | Description |
|----------|----------|---------|-------------|
| `EVM_PRIVATE_KEY` | Yes | - | Private key for signing transactions |
| `API_URL` | No | `http://3.220.4.143:5000` | EigenDA API endpoint |
| `BASE_RPC_URL` | No | `https://base.drpc.org` | Base network RPC URL |
| `CREDITS_CONTRACT_ADDRESS` | No | `0x0CC001F1bDe9cd129092d4d24D935DB985Ce42A9` | Credits contract address on Base |
| `EIGENDA_IDENTIFIER` | No | - | Hex-encoded identifier to use for all operations |

## Usage

### Uploading Data

```typescript
// Upload text data
await runtime.execute("UPLOAD_DATA", {
content: "Hello, EigenDA!"
});

// Upload JSON data
await runtime.execute("UPLOAD_DATA", {
content: JSON.stringify({
name: "Test Object",
values: [1, 2, 3]
})
});

// Upload with specific identifier (overrides EIGENDA_IDENTIFIER from env)
await runtime.execute("UPLOAD_DATA", {
content: "Hello, EigenDA!",
identifier: "0x1234567890abcdef"
});
```

### Checking Status

```typescript
await runtime.execute("GET_STATUS", {
jobId: "abc123def456"
});
```

### Retrieving Data

```typescript
// Retrieve by job ID
await runtime.execute("RETRIEVE_DATA", {
jobId: "abc123def456"
});

// Retrieve by request ID
await runtime.execute("RETRIEVE_DATA", {
requestId: "xyz789"
});

// Retrieve by batch header hash and blob index
await runtime.execute("RETRIEVE_DATA", {
batchHeaderHash: "0xabcdef...",
blobIndex: 0
});
```

## Important Notes

1. **Processing Time**: Data uploads typically require 5-10 minutes of processing time before they are available for retrieval.

2. **Balance Management**: The plugin automatically checks your balance and tops up with 0.01 ETH if it falls below the threshold.

3. **Identifiers**: The plugin handles identifiers in the following priority:
- Uses identifier provided in the action call if specified
- Uses `EIGENDA_IDENTIFIER` from environment if set
- Uses an existing identifier from the account if available
- Creates a new identifier if none exists

4. **Data Types**: The plugin supports:
- Text data
- JSON data (automatically stringified)
- Binary data

## Example Workflow

```typescript
// 1. Upload data
const uploadResult = await runtime.execute("UPLOAD_DATA", {
content: "Hello, EigenDA!"
});
const jobId = uploadResult.content.job_id;

// 2. Check status
await runtime.execute("GET_STATUS", {
jobId
});

// 3. Retrieve data (after processing is complete)
await runtime.execute("RETRIEVE_DATA", {
jobId
});
```

## Error Handling

The plugin includes comprehensive error handling for:
- Invalid configuration
- Network issues
- Insufficient balance
- Invalid data formats
- Failed uploads/retrievals

Error messages are descriptive and include specific details about what went wrong.

## Development

### Building

```bash
npm run build
```

### Testing

```bash
npm test
```

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## Support

For support, please open an issue in the repository or contact the EigenDA team.

3 changes: 3 additions & 0 deletions packages/plugin-eigenda/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import eslintGlobalConfig from "../../eslint.config.mjs";

export default [...eslintGlobalConfig];
39 changes: 39 additions & 0 deletions packages/plugin-eigenda/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "@elizaos/plugin-eigenda",
"version": "0.1.0",
"description": "EigenDA plugin for Eliza",
"type": "module",
"main": "./dist/index.js",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.cjs"
}
},
"files": [
"dist"
],
"scripts": {
"build": "tsup",
"dev": "tsup --watch",
"clean": "rimraf dist",
"typecheck": "tsc --noEmit",
"lint": "eslint src/",
"lint:fix": "eslint src/ --fix"
},
"dependencies": {
"@elizaos/core": "workspace:*",
"ethers": "^6.11.1",
"axios": "^1.6.7",
"zod": "^3.22.4"
},
"devDependencies": {
"@types/node": "^20.11.19",
"rimraf": "^5.0.5",
"tsup": "^8.0.2",
"typescript": "^5.3.3"
}
}
1 change: 1 addition & 0 deletions packages/plugin-eigenda/src/abi/Credits.json

Large diffs are not rendered by default.

Loading
Loading