This project implements a database adapter for ElizaOS, enabling decentralized storage of agent data using the Storacha network.
- Storacha: A decentralized storage network built on IPFS and w3up, providing secure and efficient data storage with content addressing.
- ElizaOS: An AI agent operating system for building, deploying, and managing intelligent agents. Learn more.
Ensure you have the following before getting started:
- Node.js 22+
- pnpm 9+
- Git for version control
- A code editor (VS Code recommended)
- Storacha delegation token (Learn how to create one)
- Create a New Repository: Use the Storacha Eliza Starter Kit template, which includes the database adapter:
-
Copy the Example Environment File:
cp .env.example .env
-
Generate the
STORACHA_AGENT_PRIVATE_KEY
:w3 key create
- Copy the private key (e.g.,
MgCYJE...Ig3Kk=
) and add it toSTORACHA_AGENT_PRIVATE_KEY
. - Copy the Agent DID key (e.g.,
did:key:...
) to create the Agent Delegation.
- Copy the private key (e.g.,
-
Generate the
STORACHA_AGENT_DELEGATION
:- Replace
AGENT_DID_KEY
with your DID Key and execute:
w3 delegation create AGENT_DID_KEY --can 'store/add' --can 'filecoin/offer' --can 'upload/add' --can 'space/blob/add' --can 'space/index/add' | base64
- Copy the base64 encoded content and add it to
STORACHA_AGENT_DELEGATION
.
- Replace
Steps required only if you are starting with a fresh version of the main Eliza Starter Kit.
-
Install the Database Adapter:
pnpm add @storacha/elizaos-adapter
-
Update the Database Configuration: Modify the database configuration to load the Database Adapter:
if (process.env.STORACHA_AGENT_DELEGATION && process.env.STORACHA_AGENT_PRIVATE_KEY) { const db = new StorachaDatabaseAdapter({ agentPrivateKey: process.env.STORACHA_AGENT_PRIVATE_KEY, delegation: process.env.STORACHA_AGENT_DELEGATION, }); return db; } else if ...
-
Integrate the Database Adapter into the Agent Runtime:
--- a/agent/src/index.ts +++ b/agent/src/index.ts @@ -7,6 +7,7 @@ import { LensAgentClient } from "@elizaos/client-lens"; import { SlackClientInterface } from "@elizaos/client-slack"; import { TelegramClientInterface } from "@elizaos/client-telegram"; import { TwitterClientInterface } from "@elizaos/client-twitter"; +import { DatabaseAdapter } from "@storacha/elizaos-adapter"; import { AgentRuntime, CacheManager, @@ -677,8 +678,12 @@ async function startAgent( fs.mkdirSync(dataDir, { recursive: true }); } - db = initializeDatabase(dataDir) as IDatabaseAdapter & - IDatabaseCacheAdapter; + db = new DatabaseAdapter({ + agentPrivateKey: process.env.STORACHA_AGENT_PRIVATE_KEY, + delegation: process.env.STORACHA_AGENT_DELEGATION, + }); await db.init();
- Create Memory Storage Adapter for ElizaOS
- Integrate with Storacha Client Using Existing Delegation
- Data redundancy - all data is stored in Filecoin L1
- Make It Work with ElizaOS and ElizaStarter
- Provide Developer Documentation
- Add GitHub SSO Onboarding and Free-Tier Storage via Stripe
- Implement Agent Data Sharing Mechanisms
- Add Encrypted Agent Storage with Lit Protocol
- Handle Mutability for Stored Data
This project is licensed under the MIT & Apache-2.0 licenses.