npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@virtuals-protocol/game-dpsn-plugin

v1.0.0

Published

DPSN plugin for Virtuals Protocol Game Node

Downloads

2

Readme

🌐 DPSN Plugin for Virtuals Protocol

Decentralized Publish-Subscribe Network (DPSN) plugin for Virtuals Protocol agents

Virtuals Protocol Version License

📋 Overview

This plugin enables Virtuals Protocol agents to connect to, subscribe to, and interact with data streams available on the DPSN Data Streams Store.

Agents can leverage this plugin to consume real-time data for decision-making, reacting to events, or integrating external information feeds.

To provide personalized data streams for your agents, you can create and publish data into your own DPSN topics using the dpsn-client for game-node.

For more information, visit:

✨ Features

  • Seamless Integration: Connect your Virtuals Protocol agents to DPSN's decentralized pub/sub network
  • Real-time Data Processing: Subscribe to and process real-time data streams in your agents
  • Topic Management: Subscribe and unsubscribe to DPSN topics programmatically
  • Event-based Architecture: Use event emitters to handle incoming messages efficiently

🚀 Installation

# From within your Virtuals Protocol project
npm install @virtuals-protocol/plugin-dpsn

⚙️ Configuration

Add the following environment variables to your .env file:

Note: The EVM private key is used only for signing authentication messages, this process do not execute any kind of onchain transaction nor incurs any txn fees.

  • Setup env:
  cd /plugins/dpsnPlugin/
  cp .env.example .env
EVM_WALLET_PRIVATE_KEY=your_evm_wallet_private_key_here
DPSN_URL=betanet.dpsn.org
VIRTUALS_API_KEY=your_virtuals_api_key_here

📚 Usage

Basic Setup

import DpsnPlugin from '@virtuals-protocol/plugin-dpsn';
import { GameAgent } from '@virtuals-protocol/game';

// Initialize the DPSN Plugin
const dpsnPlugin = new DpsnPlugin({
  credentials: {
    privateKey: process.env.EVM_WALLET_PRIVATE_KEY || '<YOUR_PRIVATE_KEY>',
    dpsnUrl: process.env.DPSN_URL || '<YOUR_DPSN_URL>',
    chainOptions: {
      network: 'testnet',
      wallet_chain_type: 'ethereum',
    },
  },
});

// Create a Virtuals Protocol agent with the DPSN plugin
const agent = new GameAgent(process.env.VIRTUALS_API_KEY || '', {
  name: 'DPSN Bot',
  goal: 'A bot that consumes realtime data from DPSN',
  description: 'A bot that processes real-time data streams from DPSN',
  workers: [
    dpsnPlugin.getWorker(),
  ],
});

// Initialize the agent
await agent.init();

Subscribing to a Topic

// Define the topic you want to subscribe to
const TOPIC = '0xe14768a6d8798e4390ec4cb8a4c991202c2115a5cd7a6c0a7ababcaf93b4d2d4/BTCUSDT/ticker';

// Get the DPSN worker from the agent
const dpsnWorker = agent.getWorkerById(agent.workers[0].id);

// Register a message handler for incoming DPSN messages
dpsnPlugin.onMessage(({ topic, message }) => {
  console.log('Topic:', topic);
  console.log('Message:', message);
  // Process your message here
});

// Subscribe to a DPSN topic
await dpsnWorker.runTask(`subscribe to topic ${TOPIC}`, {
  verbose: true,
});

Unsubscribing and Cleanup

// Unsubscribe from a topic
await dpsnWorker.runTask(`unsubscribe to topic ${TOPIC}`, {
  verbose: true,
});

// Disconnect from DPSN when done
await dpsnPlugin.disconnect();

📖 API Reference

DpsnPlugin

The main plugin class that provides DPSN functionality.

Constructor

constructor(options: IDpsnPluginOptions)

Options:

  • id (optional): The worker ID
  • name (optional): The worker name
  • description (optional): The worker description
  • credentials: Required connection credentials
    • privateKey: Your DPSN private key
    • dpsnUrl: The DPSN server URL
    • chainOptions: Blockchain configuration
    • connectionOptions (optional): Additional connection options
    • initOptions (optional): Additional initialization options
    • contractAddress (optional): DPSN contract address

Methods

  • async initialize(): Promise<void> - Initialize the DPSN client
  • async onMessage(handler: (data: { topic: string; message: any }) => void): Promise<void> - Register a message handler
  • offMessage(handler: (data: { topic: string; message: any }) => void): void - Remove a message handler
  • getWorker(data?: {...}): GameWorker - Get the GameWorker instance with DPSN functions
  • async disconnect(): Promise<void> - Disconnect from DPSN and cleanup resources

Game Functions

The plugin provides these built-in functions for use in Virtuals Protocol agents:

  • subscribe_to_topic - Subscribe to a DPSN topic to receive messages
  • unsubscribe_to_topic - Unsubscribe from a DPSN topic to stop receiving messages

📢 Publishing Data using DPSN

To learn about creating topics, managing ownership, and publishing data to DPSN:

→ Visit the DPSN Publishing Guide

🔗 Related Projects

📝 Example

Check out a complete example of using the DPSN Plugin with Virtuals Protocol:

import { GameAgent } from '@virtuals-protocol/game';
import DpsnPlugin from '@virtuals-protocol/plugin-dpsn';
import dotenv from 'dotenv';

dotenv.config();

// Define the topic you want to subscribe to
const TOPIC = '0xe14768a6d8798e4390ec4cb8a4c991202c2115a5cd7a6c0a7ababcaf93b4d2d4/BTCUSDT/ticker';

// Initialize the DPSN plugin
const dpsnPlugin = new DpsnPlugin({
  credentials: {
    privateKey: process.env.EVM_WALLET_PRIVATE_KEY || '<YOUR_PRIVATE_KEY>',
    dpsnUrl: process.env.DPSN_URL || '<YOUR_DPSN_URL>',
    chainOptions: {
      network: 'testnet',
      wallet_chain_type: 'ethereum',
    },
  },
});

// Create a Virtuals Protocol agent
const agent = new GameAgent(process.env.VIRTUALS_API_KEY || '', {
  name: 'DPSN Bot',
  goal: 'A bot that consumes realtime data from DPSN',
  description: 'A bot that consumes realtime data from DPSN',
  workers: [
    dpsnPlugin.getWorker(),
  ],
});

(async () => {
  // Set up logging
  agent.setLogger((agent, message) => {
    console.log(`---------[${agent.name}]--------`);
    console.log(message);
    console.log('\n');
  });

  // Initialize the agent
  await agent.init();
  const dpsnWorker = agent.getWorkerById(agent.workers[0].id);

  // Register a message handler
  dpsnPlugin.onMessage(({ topic, message }) => {
    console.log('Topic:', topic);
    console.log('Message:', message);
  });

  try {
    // Subscribe to a topic
    await dpsnWorker.runTask(`subscribe to topic ${TOPIC}`, {
      verbose: true,
    });

    // Handle cleanup on SIGINT
    process.on('SIGINT', async () => {
      console.log('Unsubscribing and disconnecting from DPSN...');
      await dpsnWorker.runTask(`unsubscribe to topic ${TOPIC}`, {
        verbose: true,
      });
      await dpsnPlugin.disconnect();
      process.exit(0);
    });
  } catch (error) {
    console.error('Error:', error);
    await dpsnPlugin.disconnect();
    process.exit(1);
  }
})();

In case of any queries, please reach out to the DPSN team on Telegram 📥.