erebos

erebos

  • Docs
  • Examples
  • API
  • Help
  • GitHub

›RPC tools

Docs

  • Introduction
  • Getting started

Swarm examples

  • File storage examples
  • Feeds examples
  • Communications examples

Swarm APIs and CLI

  • Swarm client
  • Individual APIs
  • Bzz API
  • Bzz Feed API
  • Bzz FS API
  • Pss API
  • CLI

Data structures

  • Data structures
  • Feed lists
  • Document synchronization
  • Timeline

Timeline protocol

  • Timeline specification
  • Timeline example
  • Timeline API

Utility libraries

  • Hexadecimal encoding
  • Keccak256 hashing
  • SECP256k1 signing
  • Hierarchical Deterministic wallet

RPC tools

  • RPC clients, handler and transport
  • Base RPC class and types
  • RPC Errors
  • RequestRPC client (stateless)
  • StreamRPC client (stateful)
  • RPC handler
  • RPC client over HTTP
  • RPC client over WebSocket
  • RPC client over IPC
  • RPC client for browsers
  • RPC client for Node
  • RPC client for Electron
  • HTTP transport
  • WebSocket transport
  • IPC transport
  • Electron transport
Edit

Base RPC class and types

Purpose

Abstract class to handle JSON-RPC 2.0 calls, used by the RequestRPC and StreamRPC classes.

Installation

npm install @erebos/rpc-base

Usage

import { BaseRPC } from '@erebos/rpc-base'

class MyRPC extends BaseRPC {
  request(...params: any): Promise<any> {
    // ...
  }
}

Interfaces and types

RPCID

type RPCID = string | number | null

RPCRequest

interface RPCRequest<T = any> {
  jsonrpc: '2.0'
  method: string
  id?: RPCID
  params?: T
}

RPCErrorObject

interface RPCErrorObject<T = any> {
  code: number;
  message?: ?string;
  data?: T;
}

RPCResponse

interface RPCResponse<T = any, E = any> {
  jsonrpc: '2.0'
  id: RPCID
  result?: T
  error?: RPCErrorObject<E>
}

BaseRPC class

new BaseRPC()

Arguments

  1. canSubscribe: boolean = false: whether subscription calls (using a stateful connection) are supported by the implementation or not.

.canSubscribe

Returns boolean

.createID()

Returns string: an unique ID for RPC calls.

.request()

⚠️ This is an abstract method, it must be implemented by extending classes

Arguments

  1. method: string
  2. params?: P = any

Returns Promise<T = any>

← RPC clients, handler and transportRPC Errors →
  • Purpose
  • Installation
  • Usage
  • Interfaces and types
    • RPCID
    • RPCRequest
    • RPCErrorObject
    • RPCResponse
  • BaseRPC class
    • new BaseRPC()
    • .canSubscribe
    • .createID()
    • .request()
Docs
Getting StartedAPI ReferenceCLI
Community
Gitter chatGitHub repositoryStar
Swarm
Official documentationHTTP gatewayDevelopment chat