Ethereum Swarm: A Detailed Guide
Blockchains, such as Ethereum, allow the implementation of decentralized applications (DApps). The main idea of DApps consists of deploying an application in the form of smart contracts on an immutable blockchain, therefore eliminating trusted application servers and single points of failure. Ethereum Swarm is designed to enhance the emergence of DApps, and by extension the Web 3.0 paradigm, by serving as a decentralized data storage solution.
However, it is surprisingly difficult to make the Web 3.0 model workable in a purely decentralized way. There are two main reasons for this. Firstly, interacting with smart contracts is complicated and provides a very poor user experience. For this reason, most DApps provide a web interface, consisting of an off-chain front-end that is hosted on a traditional web server and served over the HTTP protocol. This, of course, introduces a trusted centralized component into the setup. Secondly, it is very expensive to store large amounts of data on a blockchain, which is why DApps usually require a way of storing some of their data off-chain. Again, using a database management system or a traditional filesystem goes against the decentralized model.
A solution to this dependency on centralized components can be found in decentralized storage solutions. The idea is simple: a peer-to-peer (P2P) network of collaborating nodes is used to pool resources. The P2P network acts as a distributed cloud storage solution with built-in redundancy. In theory, any type of data can be hosted and served from such a decentralized network, including off-chain DApp data and the files constituting the front-end for DApps.
Possibly the most well-know distributed storage solution is the Interplanetary Filesystem (IPFS), which uses a distributed hashtable data-structure to store content across a network of nodes. However, IPFS content is not guaranteed to be available, unless the original data owner keeps serving it from its own host. This is due to the fact that content propagation through the network is prioritized according to popularity and unpopular content may be garbage collected. The lack of incentives or nodes to host content is a general problem in decentralized storage solutions.
Ethereum Swarm Architecture
Swarm is Ethereum’s implementation of a decentralized file storage network. It is supported by the Ethereum Geth client and interacting with the storage network is closely linked to the Ethereum blockchain and requires an Ethereum account.
The above figure illustrates how Ethereum Swarm distributes data across the P2P network. Data is split up into blocks called chunks, which have a maximum size limit of 4K bytes. The network layer is agnostic to what these chunks represent, for instance, whether they are part of a file or any other piece of data. Chunks are distributed across the network and addressed by a 32-byte hash of their content. This ensures that data integrity can be verified, but, this introduces a problem with storing content that may be modified. Hash addressing is also not very user-friendly. For this reason, another layer, the Ethereum Name Service (ENS) allows users to register human-readable names for their content. ENS is implemented as a smart contract on the Ethereum network and can be considered the equivalent of the domain name service (DNS) that facilitates content naming in traditional internet services.
Ethereum Swarm differentiates itself from IPFS in that it does not just reference and (potentially cache) content made available on a content owner’s own storage. Instead, it actually constitutes a cloud service onto which content can be uploaded.
Currently, there is no guarantee uploaded content will remain available, as nodes may join and leave the network at will, or even reduce their storage capacity. A future incentive layer is planned, in order to compensate node owners for offering storage space. This is made possible by the close integration with Ethereum.
To connect to Ethereum Swarm a running instance of Geth is required. The Swarm client itself can be obtained from the Swarm download page for different platforms.
Once the Swarm executable has been installed, you can then connect to the network using an existing account managed by the running Geth instance:
- swarm –bzzaccount
Swarm then provides an endpoint on port 8500. Navigating to http://localhost:8500 in a browser will open up a search box for the Swarm network. More advanced usage options can be found in the official documentation.
Of course, web browsers do not currently support Swarm’s protocol natively. Therefore, the Ethereum Foundation provides a gateway service to allow Swarm hosted content to be accessed in the absence of a local Swarm client. The gateway can be accessed by placing content addresses in the following URL:
The post Ethereum Swarm: A Detailed Guide appeared first on Mycryptopedia.