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.

    Type Parameters

    Parameters

    Returns Promise<Libp2p<T>>

    Example

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

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

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