New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@somniaforge/sdk

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@somniaforge/sdk

SomniaForge SDK - Zero-config TypeScript toolkit for building real-time games on Somnia Network

beta
latest
npmnpm
Version
1.2.0-beta.1
Version published
Maintainers
1
Created
Source

SomniaForge SDK ⚡

npm version TypeScript License: MIT Beta

A TypeScript SDK for building real-time, fully on-chain games on Somnia Network

Zero-config setup • Sub-second transactions • Real-time WebSocket events

📖 Documentation🎮 Live Demo🛠️ Examples

🚧 Beta Disclaimer

⚠️ This SDK is currently in beta development phase.

  • Not production-ready: Expect breaking changes between versions
  • Active development: APIs and interfaces may change without notice
  • Testing recommended: Thoroughly test in development environments before any production use
  • Community feedback welcome: Please report issues and suggestions via GitHub Issues
  • Somnia Network testnet: Currently optimized for Somnia testnet environment

We appreciate early adopters and contributors helping us build the future of real-time Somnia Network gaming!

✨ Features

  • 🚀 Zero Configuration - Works out of the box with Somnia Network
  • Sub-second Transactions - Leverage Somnia's 1M+ TPS capability
  • 🔄 Real-time Events - WebSocket integration for instant game state updates
  • 🔗 Viem Integration - Modern Ethereum client with full TypeScript support
  • 🎮 Game Session Management - Create, join, and manage multiplayer sessions
  • 👤 Player Profiles - Registration, stats, and achievements system
  • 💰 Game Economy - Built-in token management and betting pools
  • 🏆 Leaderboards - Global rankings and tournament management
  • 🌐 Network Switching - Automatic Somnia network connection
  • 📱 Cross-platform - Works on web, mobile, and desktop
  • 🎨 React Components - Pre-built UI components for rapid development

🚀 Quick Start

Installation

npm install @somniaforge/sdk
# or
yarn add @somniaforge/sdk
# or
pnpm add @somniaforge/sdk

Basic Usage

import { SomniaForgeSDK } from '@somniaforge/sdk'

// Initialize the SDK
const sdk = new SomniaForgeSDK()

// Connect wallet and initialize
const connection = await sdk.initialize()
console.log('Connected to Somnia Network:', connection)

// Create a game session
const sessionId = await sdk.gameSession.createSession({
  maxPlayers: 4,
  entryFee: parseEther('0.01'),
  moveTimeLimit: 300 // 5 minutes
})

// Set up real-time event listeners
sdk.gameSession.setEventCallbacks({
  onPlayerJoined: (event) => {
    console.log('Player joined:', event.player)
  },
  onSessionStarted: (event) => {
    console.log('Game started:', event.sessionId)
  }
})

React Components

import {
  SomniaButton,
  GameCard,
  PlayerProfile,
  WalletConnectButton
} from '@somniaforge/sdk'

function GameApp() {
  return (
    <div>
      <WalletConnectButton onConnect={handleConnect} />
      <PlayerProfile address="0x..." />
      <GameCard
        title="Rock Paper Scissors"
        players={2}
        maxPlayers={2}
        status="waiting"
      />
      <SomniaButton variant="primary" onClick={createGame}>
        Create Game
      </SomniaButton>
    </div>
  )
}

🌐 Somnia Network Configuration

The SDK is pre-configured for Somnia Network testnet:

PropertyValue
NetworkSomnia Testnet
Chain ID50312 (0xc488)
RPC URLhttps://dream-rpc.somnia.network
WebSocketwss://dream-rpc.somnia.network/ws
Explorerhttps://shannon-explorer.somnia.network
CurrencySTT (Somnia Test Token)

🎮 Example: Rock Paper Scissors Game

import { SomniaForgeSDK, parseEther } from '@somniaforge/sdk'

const sdk = new SomniaForgeSDK()
await sdk.initialize()

// Create game session
const sessionId = await sdk.gameSession.createSession({
  maxPlayers: 2,
  entryFee: parseEther('0.001'),
  moveTimeLimit: 60
})

// Player joins and submits move
await sdk.gameSession.joinSession(sessionId)
const moveHash = sdk.gameSession.createMoveHash('rock', 'mysecret')
await sdk.gameSession.submitMove(sessionId, moveHash)

// Reveal phase
await sdk.gameSession.revealMove(sessionId, 'rock', 'mysecret')

📊 Bundle Size & Performance

FormatSizeGzippedPerformance
ESM~74KB9.4KBOptimized
CJS~40KB7.1KBLegacy Support
Target<100KB<15KB✅ Achieved
  • Tree-shakable: Import only what you need
  • Zero dependencies: Core functionality with minimal external deps
  • TypeScript native: Full type safety and IntelliSense support

📄 License

MIT License - see LICENSE file for details.

🆘 Support & Community

Built with ❤️ for the Somnia Network gaming ecosystem

🌟 Star us on GitHub🍴 Fork the project📖 Read the docs

Keywords

somnia-network

FAQs

Package last updated on 19 Sep 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts