Function createLibp2p

  • Returns a new instance of the Libp2p interface, generating a new PeerId if one is not passed as part of the options.

    The node will be started unless start: false is passed as an option.

    Example

    import { createLibp2p } from 'libp2p'
    import { tcp } from '@libp2p/tcp'
    import { mplex } from '@libp2p/mplex'
    import { noise } from '@chainsafe/libp2p-noise'

    // specify options
    const options = {
    transports: [tcp()],
    streamMuxers: [mplex()],
    connectionEncryption: [noise()]
    }

    // create libp2p
    const libp2p = await createLibp2p(options)

    Parameters

    Returns Promise<Libp2p>