Using a Bware Labs endpoint in code
Listed below you can find a simple code snippet demonstrating how to use a Bware Labs generated endpoint in your javascript code
1
init: function() {
2
ws_provider = new Web3(new Web3.providers.WebsocketProvider ('wss://'
3
+ 'eth-api.bwarelabs.com/ws/69231efa-e959-4fb0-ad08-9141cda9ea4d'));
4
ws_provider.eth.net.getNetworkType().then((networkID) => {
5
switch (networkID) {
6
case "main":
7
this.chainID = ChainId.MAINNET;
8
this.network = 'homestead';
9
break;
10
case "rinkeby":
11
this.chainID = ChainId.RINKEBY;
12
this.network = 'rinkeby';
13
break;
14
default:
15
this.chainID = ChainId.MAINNET;
16
this.network = 'homestead';
17
}
18
logger.info(`Listening on the ${networkID} network...`);
19
});
20
oracle_provider = new ethers.providers.WebSocketProvider('wss://'
21
+ 'eth-api.bwarelabs.com/ws/69231efa-e959-4fb0-ad08-9141cda9ea4d', this.network);
22
},
23
Copied!
Last modified 2mo ago
Copy link