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

RequestRPC client (stateless)

Purpose

Class extending BaseRPC to handle stateless JSON-RPC 2.0 calls.

See HTTP transports documentation for possible transports and the StreamRPC class documentation to handle stateful JSON-RPC 2.0 calls.

Installation

npm install @erebos/rpc-request

Usage

import { RequestRPC } from '@erebos/rpc-request'
import { createTransport } from '@erebos/transport-http-node'

class MyAPI extends RequestRPC {
  constructor(url: string) {
    super(createTransport(url))
  }

  getUser(id: string): Promise<{ name: string }> {
    return this.request('getUser', [id])
  }
}

const api = new MyAPI('http://my-api-url')
api.getUser('1234')

Interfaces and types

type FetchFunction = <D = any, R = any>(data: D) => Promise<R>

RequestRPC class

See the BaseRPC documentation for inherited methods and properties.

new RequestRPC()

Arguments

  1. fetch: FetchFunction: function making the server call using the JSON-RPC request Object and returning the response.

.request()

Arguments

  1. method: string
  2. params: T = any

Returns Promise<R = any>

← RPC ErrorsStreamRPC client (stateful) →
  • Purpose
  • Installation
  • Usage
  • Interfaces and types
  • RequestRPC class
    • new RequestRPC()
    • .request()
Docs
Getting StartedAPI ReferenceCLI
Community
Gitter chatGitHub repositoryStar
Swarm
Official documentationHTTP gatewayDevelopment chat