@electrum-cash/network 3.2.0-r1 → 3.3.0-development.6103536979

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -15,7 +15,7 @@ Install the library with NPM:
15
15
 
16
16
  ## Usage
17
17
 
18
- ### Load library
18
+ ### Usage with NodeJS
19
19
 
20
20
  Before you can use the library you need to include it in your project.
21
21
 
@@ -33,6 +33,15 @@ If you want to use **multiple servers**, load the `ElectrumCluster` module:
33
33
  const { ElectrumCluster } = require('electrum-cash');
34
34
  ```
35
35
 
36
+ ### Usage on Web
37
+
38
+ To use the library on the web, use the ESM import syntax and include the `ElectrumTransport` import:
39
+
40
+ ```js
41
+ // Load the electrum library.
42
+ import { ElectrumClient, ElectrumTransport } from 'electrum-cash';
43
+ ```
44
+
36
45
  ### Connect to servers
37
46
 
38
47
  After you have loaded the appropriate module you need to initialize the module by configuring your **application identifier** and **protocol version**.
@@ -46,6 +55,15 @@ const electrum = new ElectrumClient('Electrum client example', '1.4.1', 'bch.ima
46
55
  await electrum.connect();
47
56
  ```
48
57
 
58
+ To connect to an electrum server from a web browser, use the `ElectrumTransport` import to use the WSS `port` and `scheme`:
59
+
60
+ ```js
61
+ const electrum = new ElectrumClient(
62
+ 'Electrum client example', '1.4.1', 'bch.imaginary.cash',
63
+ ElectrumTransport.WSS.Port, ElectrumTransport.WSS.Scheme
64
+ );
65
+ ```
66
+
49
67
  If you want to use multiple servers, initialize an `ElectrumCluster` and add some servers:
50
68
 
51
69
  *For more information on various cluster configurations, read the [cluster documentation](https://read.cash/@JonathanSilverblood/electrum-cash-strategic-use-of-clusters-83743111).*
@@ -65,6 +83,7 @@ electrum.addServer('electrum.imaginary.cash');
65
83
  await electrum.ready();
66
84
  ```
67
85
 
86
+
68
87
  ### Request information
69
88
 
70
89
  Once your `ElectrumClient` or `ElectrumCluster` is connected and ready, you can call methods: