erebos

erebos

  • Docs
  • Examples
  • API
  • Help
  • GitHub

›Swarm examples

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

Feeds examples

Feed APIs reference

Publishing a website with a permanent URL

import { BzzFeed } from '@erebos/bzz-feed'
import { BzzNode } from '@erebos/bzz-node'
import { pubKeyToAddress } from '@erebos/keccak256'
import { createKeyPair, sign } from '@erebos/secp256k1'

const BZZ_URL = 'http://localhost:8500'

// This setup is meant for demonstration purpose only - keys and signatures security must be handled by the application
const keyPair = createKeyPair()
const user = pubKeyToAddress(keyPair.getPublic('array'))
const signBytes = async bytes => sign(bytes, keyPair)
const bzz = new BzzNode({ url: BZZ_URL })
const bzzFeed = new BzzFeed({ bzz, signBytes })

// website will be accessible with the URL `${BZZ_URL}/bzz:/${feedHash}`
const feedHash = await bzzFeed.createManifest({
  user,
  name: 'my-awesome-website',
})

// This function can be called any time the website contents change
const publishContents = async contents => {
  // setFeedContent() uploads the given contents and updates the feed to point to the contents hash
  await bzzFeed.setContent(feedHash, contents, { defaultPath: 'index.html' })
}

// Example use of publishContents()
const setupContents = async () => {
  await publishContents({
    'index.html': { contentType: 'text/html', data: '<h1>Hello world</h1>' },
  })
}

Asynchronous messaging

The Timeline examples page provides an example of asynchronous messaging with Swarm feeds, using the Timeline protocol.

← File storage examplesCommunications examples →
  • Publishing a website with a permanent URL
  • Asynchronous messaging
Docs
Getting StartedAPI ReferenceCLI
Community
Gitter chatGitHub repositoryStar
Swarm
Official documentationHTTP gatewayDevelopment chat