6.2.13 • Published 2 days ago

@railgun-community/waku-relayer-client-web v6.2.13

Weekly downloads
-
License
MIT
Repository
-
Last release
2 days ago

RAILGUN Relayer Client with Waku networking layer

This package is meant specifically for browsers.

yarn add @railgun-community/waku-relayer-client-web

The Basics

// Initialize the Relayer Client
await WakuRelayerClient.start(...)

// Wait for Relayers to connect (5-10 sec) and client to collect fees.
// Relayers broadcast fees through the privacy-safe Waku network.

// Get relayer with lowest fee for a given ERC20 token.
const selectedRelayer = await WakuRelayerClient.findBestRelayer(...)

// Create Relayed transaction and send through selected Relayer.
const relayerTransaction = await RelayerTransaction.create(...)
await RelayerTransaction.send(...)

Webpack configuration

Some dependencies of this package, such as Waku and libp2p, make an assumption that they are running in a Node.js environment. This is not the case in a browser environment, so we need to configure Webpack to ignore some sub-dependencies that are not relevant in the browser.

webpack.config.js

module.exports = {
  //...
  resolve: {
    alias: {
      // Waku uses these Node.js-specific sub-dependencies, which we ignore:
      'default-gateway': false,
      '@achingbrain/nat-port-mapper': false,
    }
  },
};

If you are using Next.js:

/** @type {import('next').NextConfig} */
module.exports = {
  webpack: (config, options) => {
    if (options.isServer) {
      // If your Next.js component is running in the server, we need to avoid
      // loading a WASM module.
      config.resolve.alias['@railgun-community/curve25519-scalarmult-wasm'] =
        '@railgun-community/curve25519-scalarmult-rsjs';
    } else {
      // If your Next.js component is running in the browser, we need to avoid
      // loading some modules which call Node.js APIs such as `child_process`.
      config.resolve.alias['default-gateway'] = false;
      config.resolve.alias['@achingbrain/nat-port-mapper'] = false;
    }
    return config;
  },
};
6.2.13

2 days ago

6.2.10

1 month ago

6.2.11

1 month ago

6.2.12

1 month ago

6.2.9

1 month ago

6.2.5

1 month ago

6.2.4

1 month ago

6.2.7

1 month ago

6.2.6

1 month ago

6.2.8

1 month ago

6.2.1

1 month ago

6.2.3

1 month ago

6.2.2

1 month ago

6.2.0

1 month ago

6.1.7

1 month ago

6.1.6

2 months ago

6.1.4

2 months ago

6.1.3

2 months ago

6.1.5

2 months ago

6.1.0

2 months ago

6.1.2

2 months ago

6.1.1

2 months ago

6.0.4

3 months ago

6.0.3

3 months ago

6.0.2

4 months ago

6.0.1

4 months ago

6.0.0

4 months ago

5.0.0

4 months ago

4.8.6

4 months ago

4.8.5

4 months ago

4.8.4

4 months ago