Skip to content

Commit

Permalink
Merge branch 'master' into anchorlinks
Browse files Browse the repository at this point in the history
  • Loading branch information
meodai authored Dec 18, 2024
2 parents 47a49ab + cb31b58 commit 9f38e4e
Show file tree
Hide file tree
Showing 14 changed files with 75 additions and 234 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { MarkdownChipRow } from "/src/components/Chip/MarkdownChipRow";
import { GlossaryTooltip } from "/src/components/Tooltip/GlossaryTooltip";


# Introduction
# What are canisters?

<MarkdownChipRow labels={["Beginner", "Concept"]} />

Expand Down
4 changes: 1 addition & 3 deletions docs/tutorials/developer-journey/level-0/01-ic-overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { MarkdownChipRow } from "/src/components/Chip/MarkdownChipRow";
import { GlossaryTooltip } from "/src/components/Tooltip/GlossaryTooltip";


# 0.1 Overview of the Internet Computer
# 0.1 What is the Internet Computer?

<MarkdownChipRow labels={["Beginner", "Tutorial"]} />

Expand All @@ -17,8 +17,6 @@ import { GlossaryTooltip } from "/src/components/Tooltip/GlossaryTooltip";
<div class="text--center">
<iframe width="660" height="415" src="https://www.youtube.com/embed/oBUpJ4CqmN0?si=AUURfidaQIjqNK7Z" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe> </div>



The **Internet Computer Protocol (ICP)** is a secure and transparent blockchain-based network that can be used to host data and programs. Programs and their data hosted on ICP are referred to as **decentralized applications**, often abbreviated to **dapps**.

Dapps are created by the development and deployment of **smart contracts**, which are known as **canisters** on ICP. Each <GlossaryTooltip>canister</GlossaryTooltip> is hosted on an independent blockchain network running on **nodes** called a **subnet**.
Expand Down
2 changes: 0 additions & 2 deletions docs/tutorials/developer-journey/level-0/02-ic-terms.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import { GlossaryTooltip } from "/src/components/Tooltip/GlossaryTooltip";
<div class="text--center">
<iframe width="660" height="415" src="https://www.youtube.com/embed/3WpP8ux1zX0?si=PGD9uM-hR0WPYt5Y" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe> </div>



This page introduces some of the most commonly used terminology that developers should be aware of when building on the Internet Computer. This page covers many terms, but does not include every single term that is related to the Internet Computer. [View the full glossary of terms](/docs/current/references/glossary).

## Concepts
Expand Down
2 changes: 0 additions & 2 deletions docs/tutorials/developer-journey/level-0/03-dev-env.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import { GlossaryTooltip } from "/src/components/Tooltip/GlossaryTooltip";
<div class="text--center">
<iframe width="660" height="415" src="https://www.youtube.com/embed/fDMHUdo7m-k?si=FM4z1NwVGYUUyH1t" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe> </div>



Before you can begin the developer ladder, you need to set up a developer environment. A developer environment consists of tools and packages that are required to develop code projects. Usually, developer environments are stored and hosted on your local computer, but there are some situations where a virtual, web-based development environment exists.

An example of this is the [playground](https://m7sm4-2iaaa-aaaab-qabra-cai.ic0.app/), which is a web-based, virtual developer environment that can be used by developers without having to set up a local environment. Deploying to the playground is ICP's equivalent of deploying to a testnet network.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import { GlossaryTooltip } from "/src/components/Tooltip/GlossaryTooltip";
<div class="text--center">
<iframe width="660" height="415" src="https://www.youtube.com/embed/mwbRRk9T5Nw?si=NtENTs0fdoAZ_abL" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe> </div>



Smart contracts on the Internet Computer are known as **canisters**. A <GlossaryTooltip>canister</GlossaryTooltip> contains both the source code and software state. A canister's source code is compiled into a WebAssembly module and is associated with a module of stable memory.

When a dapp is written to be deployed on ICP, the source code is compiled into a WebAssembly module. Then, that WebAssembly module is deployed and executed inside of the canister. Once a canister is deployed, end-users can interact with the canister through the CLI or through a frontend client such as a web browser.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import { GlossaryTooltip } from "/src/components/Tooltip/GlossaryTooltip";
<div class="text--center">
<iframe width="660" height="415" src="https://www.youtube.com/embed/sZxbRAwYYMw?si=GufwOp4xBqa2F4JA" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe> </div>



When developing canisters, the most common development workflow is to use a software development kit (SDK). The Internet Computer SDK is the most commonly used, which natively supports Motoko and Rust out of the box.

Since ICP supports dapps that have been compiled into WebAssembly modules, many different programming languages can be used for <GlossaryTooltip>canister</GlossaryTooltip> development. However, a canister development kit (CDK) needs to be used. A CDK is an adapter used by the IC SDK that provides a programming language with the necessary features and tools required to create and manage canisters. The IC SDK comes bundled with CDKs for Motoko and Rust. Additionally, there are several community created CDKs for additional languages, such as Python and TypeScript, that can be installed separately.
Expand Down
2 changes: 0 additions & 2 deletions docs/tutorials/developer-journey/level-0/06-intro-dfx.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import { GlossaryTooltip } from "/src/components/Tooltip/GlossaryTooltip";
<div class="text--center">
<iframe width="660" height="415" src="https://www.youtube.com/embed/J5rhdzjuq6k?si=3o1NdIWr0TeNYSkU" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe> </div>



`dfx` is a command line utility that is used to interact with the IC SDK. It is the primary tool that is used for creating, managing, and deploying dapps onto the Internet Computer.

The `dfx` parent command has several flags and subcommands that can be used to perform a wide array of operations. First, you'll take a look at basic usage of the command, then you'll get started creating your first project using dfx.
Expand Down
14 changes: 7 additions & 7 deletions docs/tutorials/developer-journey/level-0/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ import { MarkdownChipRow } from "/src/components/Chip/MarkdownChipRow";

<MarkdownChipRow labels={["Beginner", "Tutorial"]} />

- [0.1 Overview of the Internet Computer](/docs/current/tutorials/developer-journey/level-0/ic-overview): In order to understand how to develop dapps on ICP, the first step in the developer ladder is to take a look at the architecture of ICP and how it functions. This module covers:
- Overview of The Internet Computer Protocol:
- [0.1 What is the Internet Computer?](/docs/current/tutorials/developer-journey/level-0/ic-overview): In order to understand how to develop dapps on ICP, the first step in the developer ladder is to take a look at the architecture of ICP and how it functions. This module covers:
- What is the Internet Computer?:
- Protocol stack:
- Peer-to peer layer.
- Consensus layer.
- Message routing layer.
- Execution layer.
- Overview of chain-key cryptography:
- Chain-key cryptography:
- Threshold signature schemes.
- Overview of canisters and smart contracts.
- Overview of tokens:
- Canister smart contracts.
- Tokens:
- ICP.
- Cycles.
- Overview of governance:
- Governance:
- Network Nervous System.
- Service Nervous System.
- Overview of Internet Identity.
- Internet Identity.

- [0.2 Internet Computer terminology](/docs/current/tutorials/developer-journey/level-0/ic-terms): This page introduces some of the most commonly used terminology that developers should be aware of when building on the Internet Computer. This module covers the following terms:
- Concepts:
Expand Down
128 changes: 29 additions & 99 deletions docs/tutorials/developer-journey/level-1/1.4-using-cycles.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import { GlossaryTooltip } from "/src/components/Tooltip/GlossaryTooltip";
<div class="text--center">
<iframe width="660" height="415" src="https://www.youtube.com/embed/eynEk3Bz7QY?si=EBRlMgOyjHQKkPy4" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe> </div>



If you recall from the previous module, [Internet Computer terminology](/docs/current/tutorials/developer-journey/level-0/ic-terms), cycles are used to measure the resources, such as memory, storage, and compute power, that are used by a <GlossaryTooltip>canister</GlossaryTooltip>. When a canister is deployed on the mainnet, cycles are 'charged' for every action that a canister performs.

To obtain cycles, the Internet Computer Protocol's utility token, ICP, can be converted into cycles and transferred into a canister to be used to pay for that canister's consumed resources. Cycles have a fixed price in [XDR](https://internetcomputer.org/docs/current/references/glossary#xdr) in order to make canister costs predictable and independent of the price of ICP. One trillion cycles always correspond to one XDR.
Expand Down Expand Up @@ -91,8 +89,13 @@ The principal will resemble the following format:
tsqwz-udeik-5migd-ehrev-pvoqv-szx2g-akh5s-fkyqc-zy6q7-snav6-uqe
```

## Acquiring cycles

## Acquiring cycles using a cycles coupon
:::danger
Cycles are required to deploy to the mainnet. If you only plan to deploy to your local environment for testing, cycles are not required. The following tutorials will focus on local deployment to assure anyone can complete this tutorial series.

You may skip this tutorial if you do not plan to deploy to the mainnet.
:::

Cycles can be obtained by converting ICP tokens into cycles. There are a few ways to obtain ICP tokens, such as:

Expand All @@ -101,129 +104,56 @@ Cycles can be obtained by converting ICP tokens into cycles. There are a few way
- Receiving a grant of ICP tokens through the DFINITY Foundation.
- Receiving ICP tokens in return for providing resources as a node provider.

For new developers, a free cycles coupon can be obtained and redeemed for 10T free cycles that can be used to get started with dapp deployment. For this tutorial, you'll be obtaining and using that free cycles coupon.

This coupon is good for new developers since it doesn't require that you transfer ICP tokens into cycles, and doesn't require a purchase of tokens to get started.

First, navigate to the website [https://faucet.dfinity.org](https://faucet.dfinity.org).

To obtain a coupon code to use the cycles faucet, you need to put in a written request for the coupon via the [Discord](https://discord.internetcomputer.org) server.

Click on the **REQUEST CYCLES** button on the faucet web page to join the Discord server.

![Getting Coupon](../_attachments/faucet_step_1.png)

Once inside the Discord server, navigate into the `#cycles-faucet` channel.

![Cycles-faucet](../_attachments/cycles-faucet.png)

In this channel, execute the following slash command:

```
/request
```
You need to obtain [ICP tokens](https://internetcomputer.org/icp-tokens), then convert them into cycles using `dfx`. However, when participating at DFINITY events like [hackathons](https://dfinity.org/hackathons) or working on a [developer grant](https://dfinity.org/grants), you will receive a coupon which you can redeem to claim free cycles from the [cycles faucet](https://anv4y-qiaaa-aaaal-qaqxq-cai.ic0.app/).

This command will make a call to the IC Cycles Faucet Bot. This bot will prompt you to fill out a survey in the channel.
:::tip
Each developer identity has both a **principal** and a **ledger account identifier**.

Once the survey has been completed, our team will review your submission. If accepted, the faucet bot will send you a private message with a coupon code.
A principal has the format `itk7v-ihlxk-ktdrh-fcnst-vkoou-orj77-52ogl-jqwj5-zpfdv-az3lr-xqe` and is used for canister ownership, management, and holding cycles.

:::info
Please ensure that your Discord settings are set to allow direct messages from other users. If you do not have this setting enabled, you will not receive a direct message from the faucet bot.
A ledger account identifier has the format `e213184a548871a47fb526f3cba24e2ee2fbbc8129c4ab497ef2ce535130a0a4` and is used to send and receive tokens like ICP.
:::

Head back to the [https://faucet.dfinity.org](https://faucet.dfinity.org) webpage.

Now, click **NEXT STEP** to continue.

Now that you have a coupon code, enter your coupon code within the faucet UI.

![Enter Coupon](../_attachments/faucet_step_3.png)
First, get your account's ledger account ID:

Click **NEXT STEP** to continue.

Return to your terminal window. If you closed the window in the process, run the following commands to start `dfx` and use your previously created identity:

```bash
dfx start --clean --background
dfx identity use DevJourney
```

This workflow utilizes the **cycles ledger** feature. If you'd like to use the **cycles wallet** instead, [view the cycles wallet documentation](/docs/current/developer-docs/defi/cycles/cycles-wallet).

:::caution
The cycles ledger is supported by default in [`dfx` version 0.22.0 and newer](/docs/current/developer-docs/getting-started/install).
:::

Then, redeem your coupon with the command:

```bash
dfx cycles --network ic redeem-faucet-coupon COUPON_CODE
```

Replace **COUPON_CODE** with the cycles coupon code sent to you by the DFINITY faucet bot.

Verify your cycles balance with the command:

```bash
dfx cycles --network ic balance
dfx ledger account-id
```

This should return an output showing 10T cycles associated with your identity.

## Converting ICP tokens to cycles

If you've already redeemed a cycles coupon in the past, or if you've already used the cycles from your coupon, you can convert ICP tokens into cycles.

Before you can convert ICP tokens into cycles, first you need to obtain ICP tokens. ICP tokens can be purchased through a crypto exchange, or they can be received through other activities such as participating in the NNS governance and receiving grants from the DFINITY foundation.
Then, send ICP tokens to this ledger account ID. You can obtain [ICP tokens](https://internetcomputer.org/icp-tokens) from an [exchange](https://coinmarketcap.com/currencies/internet-computer/markets) or through a [developer grant](https://dfinity.org/grants). If you are using an exchange, initiate a withdrawal transaction, then enter the ledger account ID as the "destination" address to send ICP tokens to.

To get your account ID so you know where to send your ICP tokens, run the command:
After you have sent ICP tokens to your ledger account, check the ICP balance.

```bash
dfx ledger account-id
```

This will display your account number on the ICP ledger, which will resemble the following:

```bash
e213184a548871a47fb526f3cba24e2ee2fbbc8129c4ab497ef2ce535130a0a4
dfx ledger balance --network=ic
```

Once you have sent some ICP to this account ID, you can verify that they were received by checking the balance with the command:
Converting ICP to cycles is done through the **cycles ledger**, a ledger canister that enables developer identities to convert, hold, send, and receive cycles.

```bash
dfx ledger --network ic balance
```
The price of cycles is fixed against the price of [XDR](/docs/current/references/glossary#xdr), where 1 trillion cycles equals 1 XDR.

This will output something like this:
Cycles are measured in very large numbers, such as billions and trillions. When you talk about cycle transfers and replenishment, you will usually operate with trillions of cycles.

```bash
12.49840000 ICP
```
:::danger
These commands must be run with the `--network=ic` flag. The cycles ledger is not necessary for local development and therefore not part of the local replica.
:::

Once you have your ICP tokens ready, you will need to convert them into cycles. To convert ICP into cycles using the cycles ledger, use the command:
Next, convert ICP into cycles. Replace `AMOUNT` with the number of ICP tokens you want to convert into cycles.

```
dfx cycles convert --amount AMOUNT --network ic
dfx cycles convert --amount AMOUNT --network=ic
```

:::info
This workflow utilizes the **cycles ledger** feature. If you'd like to use the **cycles wallet** instead, [view the cycles wallet documentation](/docs/current/developer-docs/defi/cycles/cycles-wallet).
:::info Calculating how many cycles you need

Please note that the cycles wallet will be removed from dfx in a future release.
:::
The amount of cycles that your canister will use depends on a variety of factors. Cycles are charged for storage, compute, update messages, special features, and more. To get an approximation, you can view the [detailed cycles cost table](/docs/current/developer-docs/gas-cost) or use the [cycles pricing calculator](/docs/current/developer-docs/cost-estimations-and-examples).

Replace the **AMOUNT** with the number of ICP to convert into cycles.
:::

To verify that your ICP was converted into cycles properly, query the balance of the wallet with the command:
Lastly, confirm that the ICP was properly converted into cycles by checking the cycles balance.

```bash
dfx cycles balance --network ic
```

This should return your balance in cycles:

```bash
6.951 TC (trillion cycles).
dfx cycles balance --network=ic
```

## Resources
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ import { GlossaryTooltip } from "/src/components/Tooltip/GlossaryTooltip";
<div class="text--center">
<iframe width="660" height="415" src="https://www.youtube.com/embed/OKbxWiA0QR8?si=hPUzZWR0PJ2XRCru" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe> </div>


:::danger
If you did not obtain cycles in the previous tutorial, [1.4 Acquiring and using cycles](/docs/current/tutorials/developer-journey/level-1/1.4-using-cycles), then you can skip this module and continue with the rest of the tutorial series.
:::

Now that you have some <GlossaryTooltip>cycles</GlossaryTooltip> to pay for your <GlossaryTooltip>canister</GlossaryTooltip>'s resources, you can deploy your dapp on the mainnet. When a canister is deployed to the mainnet, it's code will be hosted on the nodes that make up one of the mainnet's subnets. The canister will be hosted on these nodes until it is manually uninstalled by the developer, or until it runs out of cycles and is uninstalled automatically.

Expand All @@ -29,6 +31,10 @@ You will be building off of the previous two modules, [1.3 Developing your first

## Deploying to the mainnet

:::danger
If you did not obtain cycles in the previous tutorial, [1.4 Acquiring and using cycles](/docs/current/tutorials/developer-journey/level-1/1.4-using-cycles), then you can skip this module and continue with the rest of the tutorial series.
:::

To deploy your dapp to the mainnet, first assure that your terminal window is open and you've navigated into the directory of your `poll` dapp that you created in module [1.3 Developing your first dapp](/docs/current/tutorials/developer-journey/level-1/1.3-first-dapp).

Then, assure that all necessary packages are installed for the project's frontend with the command:
Expand Down Expand Up @@ -101,7 +107,7 @@ Uploading assets to asset canister...
Deployed canisters.
```

If you manually converted ICP tokens into cycles, and your cycles balance doesn't contain enough cycles to complete this deployment, you can convert more ICP into cycles with the command:
If your cycles balance doesn't contain enough cycles to complete this deployment, you can convert more ICP into cycles with the command:


```bash
Expand All @@ -110,8 +116,6 @@ dfx cycles convert 1.005 --network ic

This command converts an additional 1.005 ICP tokens to cycles.

If you used the free cycles coupon, this step is not applicable.

Now, let's use your dapp! To access the dapp's frontend, first you need to get the canister's URL. To get this, run the command:

```bash
Expand Down
Loading

0 comments on commit 9f38e4e

Please sign in to comment.