This course introduces the basic principles and tools to define and develop a peer to peer (P2P) system, with a focus on Distributed Hash Tables and the distributed technology of blockchains and on the cryptocurencies. The first part of the course introduces the general concepts underlying any P2P system (topology, information diffusion,...). Cryptocurrencies and, more in general, blockchains, are a recent "killer application" in the area of P2P systems. The second part of the course presents and discusses the blockchain technology and the decentralized digital currencies (cryptocurrencies) such as Bitcoin, Ethereum and Algorand. The course introduces both the theory and principles at the basis of cryptocurrencies operations and practical examples of their use. This part introduces the cryptocurrency ecosystem and discusses the existing and potential interaction of cryptocurrencies with the banking, financial, legal and regulatory environment. Lastly the course details how innovative applications exploit blockchain technology