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

feat: new plugin nillionDB #2133

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 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
7 changes: 7 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,13 @@ CONFLUX_ESPACE_PRIVATE_KEY=
CONFLUX_ESPACE_RPC_URL=
CONFLUX_MEME_CONTRACT_ADDRESS=

# Nillion (nilDB) Configuration
NILLION_NILDB_ORG_DID= # Nillion (nilDB) organization decentralized identifier
NILLION_NILDB_SCHEMA_ID= # Nillion (nilDB) data schema
NILLION_NILDB_URLS= # Nillion (nilDB) Node URL
NILLION_NILDB_NODE_IDS= # Nillion (nilDB) Node IDs
NILLION_NILDB_NODE_JWTS= # Nillion (nilDB) Node JWTs (Bearer tokens)

# ZeroG
ZEROG_INDEXER_RPC=
ZEROG_EVM_RPC=
Expand Down
1 change: 1 addition & 0 deletions agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
"@elizaos/plugin-arthera": "workspace:*",
"@elizaos/plugin-allora": "workspace:*",
"@elizaos/plugin-opacity": "workspace:*",
"@elizaos/plugin-nillion": "workspace:*",
"@elizaos/plugin-akash": "workspace:*",
"readline": "1.3.0",
"ws": "8.18.0",
Expand Down
9 changes: 8 additions & 1 deletion agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ import {
webhookPlugin,
} from "@elizaos/plugin-coinbase";
import { coinmarketcapPlugin } from "@elizaos/plugin-coinmarketcap";
import { coingeckoPlugin } from "@elizaos/plugin-coingecko";
wtfsayo marked this conversation as resolved.
Show resolved Hide resolved
import { confluxPlugin } from "@elizaos/plugin-conflux";
import { createCosmosPlugin } from "@elizaos/plugin-cosmos";
import { cronosZkEVMPlugin } from "@elizaos/plugin-cronoszkevm";
Expand All @@ -66,6 +65,7 @@ import { imageGenerationPlugin } from "@elizaos/plugin-image-generation";
import { lensPlugin } from "@elizaos/plugin-lensNetwork";
import { multiversxPlugin } from "@elizaos/plugin-multiversx";
import { nearPlugin } from "@elizaos/plugin-near";
import { nillionPlugin } from "@elizaos/plugin-nillion";
import { nftGenerationPlugin } from "@elizaos/plugin-nft-generation";
import { createNodePlugin } from "@elizaos/plugin-node";
import { obsidianPlugin } from "@elizaos/plugin-obsidian";
Expand Down Expand Up @@ -763,6 +763,13 @@ export async function createAgent(
getSecret(character, "AKASH_WALLET_ADDRESS")
? akashPlugin
: null,
getSecret(character, "NILLION_NILDB_URLS") &&
getSecret(character, "NILLION_NILDB_NODE_IDS") &&
getSecret(character, "NILLION_NILDB_NODE_JWTS") &&
getSecret(character, "NILLION_NILDB_ORG_DID") &&
getSecret(character, "NILLION_NILDB_SCHEMA_ID")
? nillionPlugin
: null,
].filter(Boolean),
providers: [],
actions: [],
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-lensNetwork/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { Plugin } from "@elizaos/core";
import transfer from "./actions/transfer.ts";


export const LensPlugin: Plugin = {
export const lensPlugin: Plugin = {
name: "Lens",
description: "Lens Plugin for Eliza",
actions: [transfer],
evaluators: [],
providers: [],
};

export default LensPlugin;
export default lensPlugin;
179 changes: 179 additions & 0 deletions packages/plugin-nillion/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
# @elizaos/plugin-nillion

A plugin for storing and retrieving data from Nillion's nilDB within the ElizaOS
ecosystem.

## Description
The Nillion plugin enables seamless integration with the decentralized nilDB
database backed by secure multi-party computation (MPC). The plugin provides
functionality to store and retrieve secrets to/from nilDB. When you store your
data in nilDB nodes, your data are secret shared in a way that none of the nodes
can learn anything about your secrets. Then, when all the secret shares are
combined, you can retrieve your original data.

## Configuration

To get started with nilDB read [our docs](https://nillion-docs-git-feat-fe-svsvd-nillion.vercel.app/build/secretVault-secretDataAnalytics/overview).

To get credentials contact [Georgios Pentafragkas](mailto:[email protected]).

The plugin requires the following environment variables to be set:
```bash
NILLION_NILDB_ORG_DID=<Org_ID>
NILLION_NILDB_SCHEMA_ID=<Schema_ID>
NILLION_NILDB_NODE_URLS=<URL_1>,<URL_2>,<URL_3>
NILLION_NILDB_NODE_IDS=<Node_ID_1>,<Node_ID_2>,<Node_ID_3>
NILLION_NILDB_NODE_JWTS=<Node_JWT_1>,<Node_JWT_2>,<Node_JWT_3>
```

## Installation

```bash
pnpm install @elizaos/plugin-nillion
```

## Usage

### Basic Integration

```typescript
import { nillionPlugin } from "@elizaos/plugin-nillion";
```

### Store Secret Example

```typescript
// The plugin automatically handles secret uploads when triggered
// through natural language commands like:

"Upload the following secret to Nillion: MyPassword123"
"Upload my secret 'foo' to nilDB"
"Store this the word PRIVACY on nillion's database"
```

### Retrieve Secret Example

```typescript
// The plugin automatically handles secret retrieval when triggered
// through natural language commands like:

"Retrieve the secret from Nillion with id 59591970-f6d1-490f-839a-02a1e8ba2a3e"
"Download my secret with id 59591970-f6d1-490f-839a-02a1e8ba2a3e from nilDB"
"Load the secret corresponding to id 59591970-f6d1-490f-839a-02a1e8ba2a3e from nillion's database"
```

## API Reference

### Actions

#### 1. NILLION_UPLOAD

Uploads secrets to Nillion's nilDB.

**Aliases:**
- UPLOAD_SECRET_TO_NILLION
- UPLOAD_SECRET_TO_NILDB
- STORE_SECRET_ON_NILLION
- STORE_SECRET_ON_NILDB
- SAVE_SECRET_TO_NILLION
- SAVE_SECRET_TO_NILDB
- UPLOAD_TO_NILLION
- UPLOAD_TO_NILDB
- STORE_ON_NILLION
- STORE_ON_NILDB
- SHARE_SECRET_ON_NILLION
- SHARE_SECRET_ON_NILDB
- PUBLISH_SECRET_TO_NILLION
- PUBLISH_SECRET_TO_NILDB

**Input Content:**
```typescript
interface UploadContent {
secret: string;
}
```

#### 2. NILLION_RETRIEVE

Retrieve secrets from Nillion's nilDB.

**Aliases:**
- RETRIEVE_SECRET_FROM_NILLION
- RETRIEVE_SECRET_FROM_NILDB
- GET_SECRET_FROM_NILLION
- GET_SECRET_FROM_NILDB
- LOAD_SECRET_FROM_NILLION
- LOAD_SECRET_FROM_NILDB
- RETRIEVE_FROM_NILLION
- RETRIEVE_FROM_NILDB
- LOAD_FROM_NILLION
- LOAD_FROM_NILDB

**Input Content:**
```typescript
interface RetrieveContent {
id: string;
}
```

## Common Issues & Troubleshooting

**Configuration Issues**
- Verify all required environment variables are set properly
(`NILLION_NILDB_URLS`, `NILLION_NILDB_NODE_IDS`, `NILLION_NILDB_NODE_JWTS`
should all have three comma separated values.)
- Ensure RPC endpoints are accessible
- Confirm NILLION_NILDB_ORG and NILLION_NILDB_SCHEMA_ID are set correctly
(one value each.)

## Security Best Practices

**Environment Variables**
- Never commit private keys to version control
- Use secure environment variable management
- Rotate private keys periodically

## Development Guide

### Setting Up Development Environment

1. Clone the repository
2. Install dependencies:

```bash
pnpm install
```

3. Build the plugin:

```bash
pnpm run build
```

4. Run the plugin:

```bash
pnpm run dev
```

## Future Enhancements

- Currently, we only upload a string. This can be extended to allow any custom schema.

We welcome community feedback and contributions to help prioritize these enhancements.

## Contributing

Contributions are welcome! Please see the [CONTRIBUTING.md](CONTRIBUTING.md) file for more information.

## Credits

This plugin integrates with and builds upon several key technologies:
- [Nillion's nilDB](https://nillion-docs-git-feat-fe-svsvd-nillion.vercel.app/build/secretVault-secretDataAnalytics/overview): Decentralized database

Special thanks to:
- The Eliza community for their contributions and feedback.

## License

This plugin is part of the Eliza project. See the main project repository for license information.
34 changes: 34 additions & 0 deletions packages/plugin-nillion/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "@elizaos/plugin-nillion",
"version": "0.1.0",
"type": "module",
"main": "dist/index.js",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
"import": {
"@elizaos/source": "./src/index.ts",
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
}
},
"scripts": {
"build": "tsup --format esm --dts",
"dev": "tsup --format esm --dts --watch",
"test": "vitest"
},
"dependencies": {
"@elizaos/core": "workspace:*",
"@nillion/nilql": "0.0.0-alpha.4",
"zod": "3.23.8"
},
"devDependencies": {
"tsup": "8.3.5"
},
"files": [
"dist"
]
}
Loading
Loading