erebos

erebos

  • Docs
  • Examples
  • API
  • Help
  • GitHub

›Utility libraries

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

Hexadecimal encoding

Purpose

Many of Ethereum and Swarm APIs require inputs or output values to be encoded as an hexadecimal string prefixed with 0x, therefore many of Erebos APIs also have this requirement.
The @erebos/hex package is used by other Erebos packages to ease the interactions with some APIs by providing an abstraction on top of it.
The Hex class is a container for the prefixed hexadecimal string, exposed in its value property, but also handles strings, objects and buffers as input and output values in order to simplify application-level interactions.

Installation

npm install @erebos/hex

Usage

import { Hex } from '@erebos/hex'

const fromString = Hex.from('Hello world!')
fromString.value // '0x48656c6c6f20776f726c6421'

const fromHex = Hex.from('0x48656c6c6f20776f726c6421')
fromHex.toString() // 'Hello world!'

Interfaces and types

hexValue

enum HexValue {}
type hexValue = HexValue & string

hexInput

type hexInput = hexValue | string | Record<string, any> | Buffer | Array<number>

API

isHexValue()

Arguments

  1. value: any

Returns boolean

Hex class

new Hex()

Arguments

  1. value: hexInput | Hex

Hex.from()

Arguments

  1. value: hexInput | Hex

Returns Hex

.value

Returns hexValue

.equals()

Arguments

  1. other: hexInput | Hex

Returns boolean

.toBuffer()

Returns Buffer

.toBytesArray()

Returns Array<number>

.toObject()

Returns Record<string, any>

.toString()

Returns string

← Timeline APIKeccak256 hashing →
  • Purpose
  • Installation
  • Usage
  • Interfaces and types
    • hexValue
    • hexInput
  • API
    • isHexValue()
  • Hex class
    • new Hex()
    • Hex.from()
    • .value
    • .equals()
    • .toBuffer()
    • .toBytesArray()
    • .toObject()
    • .toString()
Docs
Getting StartedAPI ReferenceCLI
Community
Gitter chatGitHub repositoryStar
Swarm
Official documentationHTTP gatewayDevelopment chat