Skip to content
Switch branches/tags
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

libp2p hex logo

The Nim implementation of the libp2p Networking Stack.


An implementation of libp2p in Nim. Also provides a Nim wrapper of the Libp2p Go daemon.

Project Status

The current native Nim libp2p implementation support is experimental and shouldn't be relied on for production use. It is under active development and contributions are highly welcomed. :)

Check our examples folder to get started!

Table of Contents


libp2p is a networking stack and library modularized out of The IPFS Project, and bundled separately for other tools to use.

libp2p is the product of a long and arduous quest of understanding; a deep dive into the internet's network stack and the peer-to-peer protocols from the past. Building large scale peer-to-peer systems has been complex and difficult in the last 15 years and libp2p is a way to fix that. It is a "network stack", a suite of networking protocols that cleanly separates concerns and enables sophisticated applications to only use the protocols they absolutely need, without giving up interoperability and upgradeability.

libp2p grew out of IPFS, but it is built so that lots of people can use it, for lots of different projects.

  • Learn more about libp2p at and follow our evolving documentation efforts at
  • Here is an overview of libp2p and its implementations in other programming languages.


nimble install libp2p




The specification is available in the docs/api folder.

Getting Started

Please read the guide.

Tutorials and Examples

Example code can be found in the examples folder.

Direct Chat Tutorial

  • Part I: Set up the main function and use multi-thread for processing IO.
  • Part II: Dial remote peer and allow customized user input commands.
  • Part III: Configure and establish a libp2p node.

Using the Go Daemon

Please find the installation and usage intructions in

Examples can be found in the examples/go-daemon folder;


Clone and Install dependencies:

git clone
cd nim-libp2p
nimble install



Run unit tests

# run all the unit tests
nimble test


List of packages currently in existence for nim-libp2p:



Secure Channels

Stream Multiplexers


Data Types


Packages that exist in the original libp2p specs and are under active development:

  • libp2p-daemon
  • libp2p-webrtc-direct
  • libp2p-webrtc-star
  • libp2p-websockets
  • libp2p-spdy
  • libp2p-bootstrap
  • libp2p-kad-dht
  • libp2p-mdns
  • libp2p-webrtc-star
  • libp2p-delegated-content-routing
  • libp2p-delegated-peer-routing
  • libp2p-nat-mgnr
  • libp2p-utils

** Note that the current stack reflects the minimal requirements for the upcoming Eth2 implementation.

Tips and tricks

enable expensive metrics:

nim c -d:libp2p_expensive_metrics some_file.nim

use identify metrics

nim c -d:libp2p_agents_metrics -d:KnownLibP2PAgents=nimbus,lighthouse,prysm,teku some_file.nim

specify gossipsub specific topics to measure

nim c -d:KnownLibP2PTopics=topic1,topic2,topic3 some_file.nim


The libp2p implementation in Nim is a work in progress. We welcome contributors to help out! Specifically, you can:

  • Go through the modules and check out existing issues. This would be especially useful for modules in active development. Some knowledge of IPFS/libp2p may be required, as well as the infrastructure behind it.
  • Perform code reviews. Feel free to let us know if you found anything that can a) speed up the project development b) ensure better quality and c) reduce possible future bugs.
  • Add tests. Help nim-libp2p to be more robust by adding more tests to the tests folder.

Core Developers

@cheatfate, Dmitriy Ryajov, Giovanni Petrantoni, Zahary Karadjov


Licensed and distributed under either of


at your option. These files may not be copied, modified, or distributed except according to those terms.