A Deep Dive Into Skynet
Tech Deep Dives

A Deep Dive Into Skynet

Contributor: Decentralized storage and DeFi are still the buzzwords of the day — what's Skynet's role in all this?

A Deep Dive Into Skynet

Daftar Isi

Introducing Skynet

Decentralized storage — cloud storage that does not rely on any single entity — is becoming more and more important in this age of large-scale hacks, surveillance and deplatforming. By removing single-point-of-failure central servers from the equation, decentralized systems are more robust, secure, and censorship-resistant.

Skynet is an open protocol that allows for the decentralized hosting of applications and data. It is an innovation built on top of the Sia blockchain that introduces the portal. Portals can be used for uploading data, getting a persistent skylink and using this skylink to get the same data back from any other portal, even if the original portal used to upload goes down.
Most end-users use Skynet through webportals, publicly-accessible portals with a web UI. Examples of webportals include the de-facto standard portal siasky.net and community-run portals like sialoop.net, skyportal.xyz and others.
Skylinks are associated with data which is immutable and lasting as long as at least one public portal continues to pin the data. In cases where the data is expected to change, the developer of a skapp (Skynet App) may also use SkyDB and the registry, which essentially provide mutable data at a given key.

This enables a wide variety of complex applications to be built on Skynet that are secure, censorship-resistant and accessible from any portal (skapps themselves are stored on Skynet). Developers no longer need to concern themselves with setting up secure servers, databases, load balancers, etc. as all this functionality is already provided by the portals in a superior manner.

Join us in showcasing the cryptocurrency revolution, one newsletter at a time. Subscribe now to get daily news and market updates right to your inbox, along with our millions of other subscribers (that’s right, millions love us!) — what are you waiting for?

Benefits for Users

Skynet is not just for developers — it is also a better experience for users than the current web. Users no longer need to be concerned about losing data or getting locked out of a service. Additionally, the complexity that comes with using blockchain technologies, such as having to run a full node and dealing with buying/using cryptocurrency, has been abstracted away for users.

To use Skynet, all you need to do is access a public webportal, such as the ones listed above. A good webportal should give you the ability to upload a file, get a skylink and be able to download the file from any portal. You can also host applications by uploading a single directory (see “Deploying Apps” below). There is no centralized hosting service that is this easily usable while also making files and apps accessible from other hosting services!

Example Apps on Skynet

An example skapp that showcases the registry is Note To Self. The user has access to a single note which he can modify as many times as he wants — what is being modified is the registry entry corresponding to the user’s note. The actual content of the note is stored as a skylink each time, which then is stored in the registry entry.
An example of a DeFi (decentralized finance) skapp is Uniswap. From their “About” page: “Uniswap empowers developers, liquidity providers and traders to participate in a financial marketplace that is open and accessible to all.” Uniswap has a frontend hosted on Skynet, enabling the service to be widely distributed and resistant to attacks.
For more skapps, check out the Skynet App Store, itself a skapp hosted on Skynet. It is a great resource for finding what’s available in the ecosystem.
By the way: even though these apps appear to be hosted on the main webportal, siasky.net, they can be accessed with the same skylink through any webportal, such as the community-run skyportal.xyz. Try it! Just replace “siasky.net” with “skyportal.xyz” in the URL.

How Skynet Works

Skynet is built on top of the Sia blockchain. Sia utilizes smart contracts between renters, who own the data, and hosts, who store copies of the data (with a configurable redundancy). Hosts must periodically prove they still have the data, or they lose the collateral in the contract.
Skynet portals are basically just instances of siad (short for “Sia daemon,” this is the software that runs a Sia node) and can be run by any interested party, fairly cheaply. Instead of forming contracts with just a handful of hosts, portals have contracts with every available host, which is what allows all portals to access any pinned data.

Skylinks are 46-character strings that encode the metadata necessary for any portal to look up and retrieve the associated data. The metadata contains, among other things, the location of the data, which the portal uses to look for the hosts with that data.

The other piece of the puzzle, SkyDB and the Registry, is functionality that lives on the hosts and essentially allows for mutable (changeable) data. The registry is composed of entries which can be updated. When a user asks a portal for a given registry entry, the portal again contacts every host looking for the data. Though a registry entry can only hold 113 bytes of arbitrary data, it is enough for skylinks or even user credentials and enables some very powerful applications such as a decentralized version of Dropbox.

Building a Basic Skynet App

In this section we’ll briefly lay out the recommended steps required to build a Skynet app from scratch; see also this tutorial for more detailed instructions.
First, you’ll need to make sure you’re in an NPM project, so make sure you run npm init if you haven’t already (install NPM first if you need to). Then, you’ll want to install the Javascript SDK:

npm install skynet-js

Followed by installing Webpack (our recommended method of bundling your app, along with the SDK and dependencies, into a single minified JS file):

npm install webpack webpack-cli --save-dev

Now you can start adding HTML, JS, and optionally CSS files (see our workshop for examples). Important: The HTML and CSS files should be placed in the dist/ folder and have the entrypoint index.html, while JS should be placed in dir/ with the index.js entry.

In your Javascript you can make use of the Skynet API by importing skynet-js and creating a client:

import { SkynetClient } from 'skynet-js'

const client = new SkynetClient()

From now on you can use the client to make API calls (see the Skynet docs for full documentation).

When you’re ready, build the project with Webpack by running:

npx webpack

This will generate a dist/main.js Javascript bundle which is the source script, referenced by our dist/index.html file.

Deploying Apps

To make your application accessible across Skynet you will need to upload it to a Skynet portal. For the purposes of this guide we will be using siasky.net. There are three steps to upload your skapp:
  1. Select “Do you want to upload the entire directory”?
  1. Click “Browse.”
  1. Select dist.
  1. Now use the produced skylink to navigate to your skapp!

Deploying DeFi Frontends on Skynet

You can deploy frontends for e.g. DeFi applications in the same manner as laid out in “Deploying Apps” above.

Make sure that your application is contained within a single folder with the index.html entrypoint. Any relative links in your application to other files (for example, from index.html to index.js) should be relative, and should not assume the portal that the skapp is running on. This will ensure that the application can be run from any portal (a process which happens automatically after the skapp is uploaded to any single portal!).

For examples of existing DeFi services hosted on Skynet, check out this video!

The Future of Skynet

Developments are in the pipeline that will make the existing, centralized web feel like the Stone Age. For example, with the help of the community, we are building an identity skapp which provides consistent user IDs across Skynet. It will allow other applications to request permissions and access to certain user data and the identity application will, if authorized, grant credentials to those skapps.

Further down the line we will be introducing content monetization, allowing developers, artists, curators and other contributors to get paid for their work. This development is particularly exciting as it will introduce sustainable funding into the ecosystem and differentiate it even further from the centralized web.

Consider the extent to which the current web is filled with ads and paid referrals. Such strategies will still be possible on Skynet, but we hope to enable creators to focus on making the best work possible instead of focusing on monetization, a barrier which many talented artists struggle with. Content monetization will introduce incentives for high-quality content and increase competition, which in turn will improve the experience of the end user.

This article contains links to third-party websites or other content for information purposes only (“Third-Party Sites”). The Third-Party Sites are not under the control of CoinMarketCap, and CoinMarketCap is not responsible for the content of any Third-Party Site, including without limitation any link contained in a Third-Party Site, or any changes or updates to a Third-Party Site. CoinMarketCap is providing these links to you only as a convenience, and the inclusion of any link does not imply endorsement, approval or recommendation by CoinMarketCap of the site or any association with its operators. This article is intended to be used and must be used for informational purposes only. It is important to do your own research and analysis before making any material decisions related to any of the products or services described. This article is not intended as, and shall not be construed as, financial advice. The views and opinions expressed in this article are the author’s [company’s] own and do not necessarily reflect those of CoinMarketCap.
3 people liked this article