ElizaOS Plugin
Add decentralized storage to any ElizaOS agent with a single import. The SDK handles uploads, listing, status checks, and x402 payments automatically.
Install
Terminal
npm install @w3stor/sdk @elizaos/core @x402/fetch @x402/evm viemSetup
Pass a private key and the SDK creates an x402 payment signer for paid operations on Base Sepolia USDC.
import { createW3StorPlugin } from "@w3stor/sdk/elizaos";
const w3storPlugin = await createW3StorPlugin({ privateKey: process.env.PRIVATE_KEY, // x402 payments handled automatically});
// Plugin includes three actions:// STORE_ON_FILECOIN — Upload files// LIST_STORED_FILES — List stored files// CHECK_STORAGE_STATUS — Check replicationUsing a viem Account
Pass a viem account directly if you already have one.
import { createW3StorPlugin } from "@w3stor/sdk/elizaos";import { privateKeyToAccount } from "viem/accounts";
const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`);
const w3storPlugin = await createW3StorPlugin({ account });Character Registration
Register the plugin with your ElizaOS character to enable storage capabilities.
import type { Character } from "@elizaos/core";import { createW3StorPlugin } from "@w3stor/sdk/elizaos";
const w3storPlugin = await createW3StorPlugin({ privateKey: process.env.PRIVATE_KEY,});
export const storageAgent: Character = { name: "StorageBot", plugins: [w3storPlugin], system: "You are a decentralized storage assistant. Help users upload files to IPFS and Filecoin, check storage status, and manage their data.", bio: [ "Decentralized storage agent powered by Filecoin and IPFS", "Supports x402 micropayments for trustless file operations", ], style: { all: ["concise", "technical but friendly", "always include CIDs in responses"], chat: ["helpful", "proactive about checking replication status"], },};Example Conversation
A typical multi-turn conversation with a w3stor-enabled agent:
User: "Hey, can you store this CSV file for me?"Agent: "Of course! I'll upload it to IPFS and replicate across Filecoin SPs." [STORE_ON_FILECOIN] "Done! Your file is stored: - CID: bafkreihdwdcefgh4dqkjv67uzcmw7ojee6xedzd - Size: 245 KB - Status: pinned (replicating to 3 SPs) Cost: $0.0008 USDC via x402"
User: "How's the replication going?"Agent: [CHECK_STORAGE_STATUS] "Your file (bafkrei...) is fully replicated: - f01234: committed (sector 5891) - f05678: committed (sector 3204) - f09012: committed (sector 7712) All 3/3 SPs confirmed!"