As part of a grant from Dfinity, I'm in the process of porting SkyDocs to the Internet Computer platform.

The Internet Computer is a decentralized platform that extends the internet. It's able to host frontend software and run backend code.

Originally SkyDocs was developed for Sia Skynet. Skynet is able to host SkyDocs and uses Skynet for document storage.

The plan is to host SkyDocs on Skynet and the Internet Computer, two places is more decentralized than one! It will also be possible to store your data on the Internet Computer backend instead of Skynet. But you can also run the app from IC and store your data on Skynet.

This blog is about my first experience with Dfinity Internet Computer.

Windows

My main development platform is Windows. But the Dfinity SDK is only available for Linux and Mac. Luckily it's very easy to run Linux apps using the Windows Subsystem for Linux (WSL). I've installed Ubuntu 20 from the Windows Store and installed Dfinity SDK v0.8.1. Version 0.8.1. did not work with Ubuntu v18, so make sure you're using Ubuntu 20 or later.

Getting started

The Internet Computer introduces a lot of new terms/concepts. It can be a bit overwhelming when starting a new project. One thing that really stands out is the very extensive documentation on https://sdk.dfinity.org/ I was happily surprised that everything is documented very well.

Some concepts explained:

Canisters

Canisters can be viewed as small containers that run some code. They are compiled to WebAssembly bytecode. Canisters can run code, host assets and communicate with other Canisters. You can think of it like a combination of a SmartContract with the Actor model. More info: https://medium.com/dfinity/software-canisters-an-evolution-of-smart-contracts-internet-computer-f1f92f1bfffb

Motoko

Motoko is the programming language for a Canister. It's used to execute code, write data to storage etc. If your Canister is only hosting static assets, you don't need any Motoko in your Canister, you can create a static asset Canister. More info: https://sdk.dfinity.org/docs/language-guide/motoko.html

ICP

ICP is the native token of the Internet Computer

Cycles

ICP can be converted to Cycles. Cycles are used to pay for a Canister's resources (CPU, Memory etc).

Local Deploys

After doing some testing on the hello world example, I decided to try to deploy Skynet to the IC. This was actually pretty easy, I only needed to add one file to dfx.json. It defines what Canisters my project uses and where to find the assets to host in my Canister.

{
  "version": 1,
  "dfx": "0.8.1",
  "canisters": {
    "skydocs_assets": {
      "type": "assets",
      "source": [
        "publish/SkyDocs.Blazor/wwwroot"
      ]
    }
  },
  "defaults": {
    "build": {
      "packtool": "",
      "args": ""
    }
  },
  "networks": {
    "local": {
      "bind": "127.0.0.1:8000",
      "type": "ephemeral"
    }
  }
}

As you can see in the above json, I have 1 Canister that is op type asset and will serve the files in the wwwroot directory. Adding this file to my project was all I needed to do.

Running dfx deploy will deploy the app to the local instance of the Internet Computer. In this quickstart guide you can read how to start a local instance of the Internet Computer https://sdk.dfinity.org/docs/quickstart/local-quickstart.html

The local instance runs on http://localhost:8000, getting a specific instance of a Canister requires you to supply the CanisterID as a query string parameter: http://localhost:8000/?canisterId=rno2w-sqaaa-aaaaa-aaacq-cai

Deploying to the Internet Computer

After doing some testing on the local instance, I was ready to deploy to the Internet Computer mainnet.

This should be as easy as running, dfx deploy --network ic But you need Cycles to pay for your Canister.

You can get some free Cycles to test out the Internet Computer by using the faucet https://faucet.dfinity.org/ It will give you for about $100 of Cycles.

There are two options when using the faucet. You can send the Cycles to a Cycles Canister or use the Dank XTC token. A Cycles Canister is a Canister who's only job it is to pay for another Canister. You can convert ICP to Cycles and send them to a Cycles Wallet Canister. More info here: https://sdk.dfinity.org/docs/quickstart/network-quickstart.html

I did not have a Cycles Wallet yet, so it sounded easier to use the Dank XTC token. It's a token that is tied to your Internet Computer Principal Identity and can pay for all your Canisters. You don't need a Cycles Wallet Canister

One important note is that when using the Dank XTC token, you need to deploy your app with the --no-wallet option: dfx deploy --network ic --no-wallet More info in this blog post: https://medium.com/dank-ois/deploying-a-canister-to-the-ic-mainnet-using-cycles-token-xtc-af8667c5d49

Result

Eventually this resulted in SkyDocs being hosted on the IC. Check it out here: https://c3qag-6yaaa-aaaah-aaqta-cai.raw.ic0.app/

NOTE: Currently I'm only hosting the SkyDocs assets on the Internet Computer. In the coming weeks, I'll integrate more functionality of the Internet Computer into SkyDocs.