New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@windingtree/off-chain-adapter-swarm

Package Overview
Dependencies
Maintainers
4
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@windingtree/off-chain-adapter-swarm

Swarm-based storage that can be used as an off-chain data adapter in @windingtree/wt-js-libs

  • 4.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
increased by50%
Maintainers
4
Weekly downloads
 
Created
Source

Winding Tree Off Chain Data Adapter - Ethereum Swarm

Greenkeeper badge

Swarm-based storage that can be used in Winding Tree wt-js-libs.

Installation

npm install @windingtree/off-chain-adapter-swarm
# or
git clone https://github.com/windingtree/off-chain-adapter-swarm
nvm install
npm install

Usage

import { WtJsLibs } from '@windingtree/wt-js-libs';
import SwarmAdapter from '@windingtree/off-chain-adapter-swarm';

const libs = WtJsLibs.createInstance({
  onChainDataOptions: {
    provider: 'http://localhost:8545',
  },
  offChainDataOptions: {
    adapters: {
      'bzz-raw': {
        options: {
          swarmProviderUrl: 'http://localhost:8500',
        },
        create: (options) => {
          return new SwarmAdapter(options);
        },
      },
    },
  },
});

Optionally, you can provide a caching backend for the adapter to avoid repeated requests. (Note: in this example, cache expiration is not specified as bzz-raw resources are immutable.)


import bluebird from 'bluebird';
import redis from 'redis';
bluebird.promisifyAll(redis.RedisClient.prototype);

const redisClient = redis.createClient();

const libs = WtJsLibs.createInstance({
  onChainDataOptions: {
    provider: 'http://localhost:8545',
  },
  offChainDataOptions: {
    adapters: {
      'bzz-raw': {
        options: {
          swarmProviderUrl: 'http://localhost:8500',
          cache: {
            set: (hash, dataJson) => redisClient.setAsync(hash, dataJson);
            get: (hash) => redisClient.getAsync(hash);
          }
        }
        create: (options) => {
          return new SwarmAdapter(options);
        },
      },
    },
  },
});

You can also optionally specify a timeout in milliseconds for communication with Swarm gateway:

import { WtJsLibs } from '@windingtree/wt-js-libs';
import SwarmAdapter from '@windingtree/off-chain-adapter-swarm';

const libs = WtJsLibs.createInstance({
  onChainDataOptions: {
    provider: 'http://localhost:8545',
  },
  offChainDataOptions: {
    adapters: {
      'bzz-raw': {
        options: {
          swarmProviderUrl: 'http://localhost:8500',
          timeout: 2000,
        }
        create: (options) => {
          return new SwarmAdapter(options);
        },
      },
    },
  },
});

Keywords

FAQs

Package last updated on 22 Jul 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc