erebos

erebos

  • Docs
  • Examples
  • API
  • Help
  • GitHub

›Swarm APIs and CLI

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

Postal Services over Swarm (Pss) API

Installation

npm install @erebos/api-pss

Usage

import { Pss } from '@erebos/api-pss'
import { createRPC } from '@erebos/rpc-ws-browser'
// or
import { createRPC } from '@erebos/rpc-ws-node'
// or any other StreamRPC factory

const rpc = createRPC('ws://localhost:8546')
const pss = new Pss(rpc)

Interfaces and types

hexInput

Input value supported by the Hex class exported by the @erebos/hex package.

hexValue

Hexadecimal-encoded string prefixed with 0x. This type is exported by the @erebos/hex package.

Hex

Hex class instance as exported by the @erebos/hex package.

PssEvent

interface PssEvent {
  key?: hexValue
  msg: Hex
}

Constants

EMPTY_ADDRESS

hexValue of the empty address (0x), can be used to broadcast a message to the entire network.

Pss class

new Pss()

Creates a Pss instance using the provided StreamRPC instance.

Arguments

  1. rpc: StreamRPC

.baseAddr()

Calls pss_baseAddr.

Returns Promise<hexValue>

.getPublicKey()

Calls pss_getPublicKey.

Returns Promise<hexValue>

.sendAsym()

Calls pss_sendAsym with the provided arguments:

Arguments

  1. key: string: public key of the peer
  2. topic: string: destination topic
  3. message: Hex | hexInput

Returns Promise<void>

.sendSym()

Calls pss_sendSym with the provided arguments:

Arguments

  1. keyID: hexValue: symmetric key ID generated using setSymmetricKey()
  2. topic: hexValue: destination topic
  3. message: Hex | hexInput

Returns Promise<void>

.sendRaw()

Calls pss_sendRaw with the provided arguments:

Arguments

  1. address: hexValue: full or partial peer address
  2. topic: hexValue: destination topic
  3. message: Hex | hexInput

Returns Promise<void>

.setPeerPublicKey()

Calls pss_setPeerPublicKey with the provided arguments:

Arguments

  1. key: hexValue: public key of the peer
  2. topic: hexValue
  3. address: hexValue

Returns Promise<void>

.setSymmetricKey()

Calls pss_setSymmetricKey with the provided arguments:

Arguments

  1. key: hexValue: public key of the peer
  2. topic: hexValue
  3. address: hexValue
  4. useForDecryption: boolean = false

Returns Promise<string>

.stringToTopic()

Calls pss_stringToTopic with the provided string and returns the generated topic.

Arguments

  1. str: string

Returns Promise<string>

.subscribeTopic()

Calls pss_subscribe with the provided topic and returns the subscription handle.

Arguments

  1. topic: hexValue
  2. handleRawMessages?: boolean = false

Returns Promise<hexValue>

.createSubscription()

Creates a RxJS Observable that will emit events matching the provided subscription handle as created by calling subscribeTopic() once subscribed to.

Arguments

  1. subscription: hexValue

Returns Observable<PssEvent>

.createTopicSubscription()

Shortcut for calling subscribeTopic() followed by createSubscription().

Arguments

  1. topic: hexValue
  2. handleRawMessages?: boolean

Returns Promise<Observable<PssEvent>>

← Bzz FS APICLI →
  • Installation
  • Usage
  • Interfaces and types
    • hexInput
    • hexValue
    • Hex
    • PssEvent
  • Constants
    • EMPTY_ADDRESS
  • Pss class
    • new Pss()
    • .baseAddr()
    • .getPublicKey()
    • .sendAsym()
    • .sendSym()
    • .sendRaw()
    • .setPeerPublicKey()
    • .setSymmetricKey()
    • .stringToTopic()
    • .subscribeTopic()
    • .createSubscription()
    • .createTopicSubscription()
Docs
Getting StartedAPI ReferenceCLI
Community
Gitter chatGitHub repositoryStar
Swarm
Official documentationHTTP gatewayDevelopment chat