Getting Started with Internet Computer blockchain DApp development (Part 1)

If you are a Web 2.0 developer, creating a decentralized application (DApp) is a different experience. For example, DApps on the Internet Computer (ICP) blockchain requires you to rent decentralized storage/computational (CPU) power in advance. This is different from AWS S3 or Lambda, where you register, input your credit card and use a free tier before receiving a monthly bill. On the blockchain, there is always a fee. It might not be a significant fee, but it's not free. On the bright side, if your app hits 10M users overnight, at least you don't end up with a surprise bill at the end of the month. You will never receive a bill from Dfinity or the Internet Computer.

This pendulum shift towards "credit loading" is why I created this article. Part 1 will help you, the developer, learn how to collect your free ICP utility tokens convert them into computational cycles so that you can later budget and deploy your app.

Step 0 - Install Node Version Manager

The Internet Computer documentation has an entire section dedicated to preliminary setting up your environment. One of those first steps is installing Node Package Manager (NPM). NPM is installed alongside Node, so I suggest going one extra step and first installing Node Version Manager (NVM). It's not that much more work and will enable you to install multiple versions of Node later.

Install Node and Node Package Manager (NPM) through Node Version Manager.

At the time of this article, I am using Node v14.17.x to complete this tutorial.

Step 1 - Install DFINITY Canister SDK

A canister is a WebAssembly (wasm) module that can run on the Internet Computer.

Note: I had to learn this the hard way. Make sure you're on Mac OS High Sierra (10.13). If you are on Mojave, you will need to upgrade your curl by typing brew install curl.

sh -ci "$(curl -fsSL https://sdk.dfinity.org/install.sh)"

Verify your work

which dfx

Step 2 - Collect Your Free Tokens!

**Dfinity gives each developer 15 trillion cycles (~ Est. $20) to build on the Internet Computer. ** Developers can claim free tokens via their Github account. Consider these utility tokens as your way of purchasing computational cycles on the Internet Computer.

If you're curious how many DApps you can build, it varies. Assuming it takes 100 billion cycles to deploy a canister, you can launch 100 canisters. By default, the dfx CLI allocates 3 trillion cycles for each new app deployment, but you can reduce that.

Note: The Github account must be at least 90 days old and have been active at least once in the past 30 days.

Visit Claim your Cycles Wallet to collect.

I hit an error prompt three times while trying to create a new wallet but be persistent and continue clicking "Create New Wallet."

Success!

dfx identity --network ic set-wallet --force enter-your-wallet-id-here  

Done

That's it! You now have $20 worth of credits to launch DApps on the Internet Computer. The next article will now focus on launching an app on the main net.

Step 3 - Verify Your Wallet Balance

Check your local environment how many cycles are associated with your DApp.

 dfx wallet balance | sed -e :a -e 's/\(.*[0-9]\)\([0-9]\{3\}\)/\1,\2/;ta'

Note: The sed after the | adds a thousands separator to make the numbers easier to read.

Check the Internet Computer main-net to verify how many cycles are associated with the DApp.

 dfx wallet --network ic balance | sed -e :a -e 's/\(.*[0-9]\)\([0-9]\{3\}\)/\1,\2/;ta'

As a final check, this command should demonstrate that althought you have compute cycles, you do not have any ICP tokens. They've already been converted for you.

dfx ledger --network ic balance

Next Article

In Part 2, we will discuss how to launch your first DApp on the Internet Computer.

Troubleshooting

Error: Failed to setup wallet caller.

Most likely you have some interference between different deployments. Just stop and start.

dfx stop

dfx start --background --clean

Resources