Home / Wiki / L / libp2p

libp2p

Cryptocurrency and Digital AssetsUpdated 13 Nov 2026

libp2p is an open-source networking framework for building peer-to-peer applications. It provides a set of interchangeable modules for the jobs every decentralised network must do: identifying peers, finding them, connecting through different transports, encrypting traffic, sharing one connection between many conversations and spreading messages across the network. Developers pick the modules they need instead of writing their own networking code from scratch.

The project began inside the InterPlanetary File System (IPFS) at Protocol Labs and was later split out so other projects could use it. It now underpins the consensus clients of Ethereum, the Filecoin network and chains built with Polkadot's Substrate framework, among others. Implementations exist in several languages, including Go, Rust, JavaScript and Nim, and they share common specifications so that nodes written in different languages can talk to one another.

01

libp2p in plain terms

Think of a building kit for a postal service where there is no central post office. Each house needs a way to prove who lives there, to find other houses, to choose a road, to seal its letters so nobody can read them, and to pass gossip along to neighbours. libp2p supplies a ready-made part for each of those jobs, and builders can swap parts depending on the neighbourhood.

A blockchain that uses libp2p does not have to invent all of this. Its developers can focus on the rules of the ledger and rely on the kit to keep thousands of computers around the world in touch with each other, even when some of them sit behind home routers or move between networks.

02

How a libp2p connection is made

  1. A node starts up with its key pair and peer ID and listens on one or more multiaddresses.
  2. It finds other peers through a bootstrap list, a distributed hash table or local discovery.
  3. It opens a raw connection over a chosen transport, then upgrades it with an encrypted channel, verifying the other side's peer ID.
  4. The two peers agree on a multiplexer and open separate streams for each application protocol, such as block requests or gossip.
  5. If either side sits behind a router, the nodes may use a relay or attempt hole punching to establish a direct link.

Each step is negotiated, so two nodes that support different sets of modules can still find a combination they both understand.

03

Main components

  • Peer identity. Each node has a peer ID derived from a cryptographic key pair, so peers can verify who they are talking to without a central authority.
  • Multiaddresses. A self-describing address format that combines network protocol, IP address, port and transport in one string, so the same software can handle many kinds of connection.
  • Transports. Support for TCP, QUIC, WebSockets, WebTransport and WebRTC, letting nodes run in data centres, on home machines and inside web browsers.
  • Secure channels and multiplexing. Connections are encrypted with protocols such as Noise or TLS, and multiplexers such as yamux let many streams share one connection.
  • Peer discovery and routing. A Kademlia-based distributed hash table, local network discovery and bootstrap lists help nodes find each other and locate content.
  • Publish-subscribe. The gossipsub protocol spreads messages such as new blocks and transactions efficiently across large networks while limiting spam.
04

Use in blockchains

Ethereum's proof-of-stake consensus layer, launched with the Beacon Chain in December 2020, uses libp2p and gossipsub to share blocks, attestations and other messages between validators. Ethereum's execution layer still uses an older, separate networking stack called devp2p. Filecoin uses libp2p for storage deals and block propagation, and Substrate-based chains in the Polkadot ecosystem build on its Rust implementation. Several other networks, from layer-1 chains to data availability systems, have adopted it for the same reasons: tested code, shared improvements and interoperability between clients.

Because the core building blocks are shared, a security fix or performance gain in libp2p can benefit many networks at once. Ethereum researchers, for example, have contributed changes to gossipsub to make it more resistant to spam and to denial-of-service attacks.

05

Design trade-offs and criticism

libp2p's flexibility is also a source of complexity. Supporting many transports and protocols increases the amount of code to audit, and implementations in different languages can lag behind one another in features. Peer-to-peer gossip exposes nodes' network addresses, which can be used to map validators or to target them with attacks, and connecting through firewalls and home routers remains difficult despite techniques such as hole punching and relays. Some projects therefore prefer smaller, purpose-built networking stacks. Supporters argue that a common, well-studied framework is safer than many teams each writing their own.

Last updated 13 Nov 2026