Created
September 24, 2020 16:51
-
-
Save vasco-santos/eac2a3d63b1ea87414d27385aa3d0148 to your computer and use it in GitHub Desktop.
libp2p Basic running setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Libp2p = require('libp2p') | |
const WebSockets = require('libp2p-websockets') | |
const WebRtcStar = require('libp2p-webrtc-star') | |
const { NOISE } = require('libp2p-noise') | |
const MPLEX = require('libp2p-mplex') | |
const node = await Libp2p.create({ | |
modules: { | |
transport: [WebSockets, WebRtcStar], | |
connEncryption: [NOISE], | |
streamMuxer: [MPLEX] | |
}, | |
addresses: { | |
listen: [ | |
'/ip4/127.0.0.1/tcp/8000/ws', | |
'/dns4/wrtc-star1.par.dwebops.pub/tcp/443/wss/p2p-webrtc-star' | |
] | |
}, | |
}) | |
// start libp2p | |
await node.start() | |
const advertiseAddrs = node.multiaddrs | |
console.log('libp2p is advertising the following addresses: ', advertiseAddrs) | |
// stop libp2p | |
await node.stop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment