@fileverse/agents

2.0.1 • Public • Published

Fileverse Agents

Access the Fileverse middleware, programmatically. Fileverse's middleware is expanding from powering self-sovereign human collaboration to also enabling multi-agent coordination with crypto primitives guaranteed 💛

Documentation

Overview

With the Fileverse Agents SDK, your agents will have the ability to read, write, and organize data onchain and on IPFS.

Out of the box and by default, your agent will get its own:

  • Safe Smart Account / Multisig: gasless transactions, make your Agent customisable
  • Smart Contract on Gnosis: public and permissionless registry of all the agent's outputs
  • Storage space on IPFS: decentralised and content addressing focused for your agent's outputs
  • Human-readable .md output: markdown is a format accessible by anyone, humans and other agents

Installation

npm install @fileverse/agents

Usage

import { Agent } from '@fileverse/agents';
import { privateKeyToAccount } from 'viem/accounts';
import { PinataStorageProvider } from '@fileverse/agents/storage';

// Create storage provider
const storageProvider = new PinataStorageProvider({
  jwt: process.env.PINATA_JWT,
  gateway: process.env.PINATA_GATEWAY
});

// Initialize agent
const agent = new Agent({
  chain: process.env.CHAIN, // required - options: gnosis, sepolia
  viemAccount: privateKeyToAccount(process.env.PRIVATE_KEY), // required - viem account instance
  pimlicoAPIKey: process.env.PIMLICO_API_KEY, // required - see how to get API keys below
  storageProvider // required - storage provider instance
});

// setup storage with namespace
// This will generate the required keys and deploy a portal or pull the existing 
await agent.setupStorage('my-namespace'); // file is generated as the creds/${namespace}.json in the main directory

const latestBlockNumber = await agent.getBlockNumber();
console.log(`Latest block number: ${latestBlockNumber}`);

// create a new file 
const file = await agent.create('Hello World');
console.log(`File created: ${file}`);

// get the file
const fileData = await agent.getFile(file.fileId);
console.log(`File: ${fileData}`);

// update the file
const updatedFile = await agent.update(file.fileId, 'Hello World 2');
console.log(`File updated: ${updatedFile}`);

// delete the file
const deletedFile = await agent.delete(file.fileId);
console.log(`File deleted: ${deletedFile}`);

How to get API Keys

Chains Supported

gnosis
sepolia

PS: Remember to put creds directory in your .gitignore file as you don't want to commit your private keys related to your portal to the repo.

PS: We don't support encryption of files yet. Please implement it on the application level if needed. We plan to add support for it in the future with other storage networks as well.

Package Sidebar

Install

npm i @fileverse/agents

Weekly Downloads

83

Version

2.0.1

License

MIT

Unpacked Size

51.8 kB

Total Files

14

Last publish

Collaborators

  • nadeem-fileverse
  • mbj36
  • vijaykrishnavanshi
  • _joshuaonwuzu
  • kylengn