Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hackathon Prep Guide (Accelerated Developer Journey) #2292

Merged
merged 60 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
019625a
accel dev journey
jessiemongeon1 Dec 1, 2023
03c62e7
accel dev journey
jessiemongeon1 Dec 1, 2023
01b6f0e
2 deploying first fullstack dapp
jessiemongeon1 Dec 8, 2023
e54fc71
2 deploying first fullstack dapp
jessiemongeon1 Dec 11, 2023
063b0bc
4: exploring the frontend
jessiemongeon1 Dec 13, 2023
63e7dbf
Integrating with tokens and authentication
jessiemongeon1 Dec 14, 2023
dab486a
Obtaining cycles and managing canisters
jessiemongeon1 Dec 14, 2023
e104e74
revisions and edits
jessiemongeon1 Dec 15, 2023
fa48e95
revisions and edits
jessiemongeon1 Dec 15, 2023
2b38c1e
add index page
jessiemongeon1 Dec 15, 2023
99f432f
add index page
jessiemongeon1 Dec 15, 2023
0daf72c
add index page
jessiemongeon1 Dec 15, 2023
e51a5f0
revisions and edits
jessiemongeon1 Dec 15, 2023
2a8165d
Update docs/tutorials/hackathon-prep-guide/1-what-is-icp.md
jessiemongeon1 Jan 4, 2024
89ce49c
Update docs/tutorials/hackathon-prep-guide/1-what-is-icp.md
jessiemongeon1 Jan 4, 2024
4cd3c65
Update docs/tutorials/hackathon-prep-guide/1-what-is-icp.md
jessiemongeon1 Jan 4, 2024
f541805
Update docs/tutorials/hackathon-prep-guide/2-deploying-first-fullstac…
jessiemongeon1 Jan 4, 2024
25d9887
Update docs/tutorials/hackathon-prep-guide/2-deploying-first-fullstac…
jessiemongeon1 Jan 4, 2024
0701aa4
Update docs/tutorials/hackathon-prep-guide/2-deploying-first-fullstac…
jessiemongeon1 Jan 4, 2024
c8ed333
Update docs/tutorials/hackathon-prep-guide/2-deploying-first-fullstac…
jessiemongeon1 Jan 4, 2024
ce31fbd
Update docs/tutorials/hackathon-prep-guide/3-exploring-the-backend.md
jessiemongeon1 Jan 4, 2024
b1c70ad
Update docs/tutorials/hackathon-prep-guide/3-exploring-the-backend.md
jessiemongeon1 Jan 4, 2024
118ce7e
Update docs/tutorials/hackathon-prep-guide/3-exploring-the-backend.md
jessiemongeon1 Jan 4, 2024
5c26f37
Update docs/tutorials/hackathon-prep-guide/3-exploring-the-backend.md
jessiemongeon1 Jan 4, 2024
7e4ddc0
Update docs/tutorials/hackathon-prep-guide/4-exploring-the-frontend.md
jessiemongeon1 Jan 4, 2024
30193ce
Update docs/tutorials/hackathon-prep-guide/4-exploring-the-frontend.md
jessiemongeon1 Jan 4, 2024
41ec628
Update docs/tutorials/hackathon-prep-guide/4-exploring-the-frontend.md
jessiemongeon1 Jan 4, 2024
53f751b
Update docs/tutorials/hackathon-prep-guide/5-integrating-with-tokens.md
jessiemongeon1 Jan 4, 2024
80987ad
Update docs/tutorials/hackathon-prep-guide/5-integrating-with-tokens.md
jessiemongeon1 Jan 4, 2024
9c4f8ef
Update docs/tutorials/hackathon-prep-guide/5-integrating-with-tokens.md
jessiemongeon1 Jan 4, 2024
0dd2380
Update docs/tutorials/hackathon-prep-guide/5-integrating-with-tokens.md
jessiemongeon1 Jan 4, 2024
03e1e26
Update docs/tutorials/hackathon-prep-guide/5-integrating-with-tokens.md
jessiemongeon1 Jan 4, 2024
ee70d02
Update docs/tutorials/hackathon-prep-guide/5-integrating-with-tokens.md
jessiemongeon1 Jan 4, 2024
b4c6829
Update docs/tutorials/hackathon-prep-guide/6-authentication.md
jessiemongeon1 Jan 4, 2024
c043716
Update docs/tutorials/hackathon-prep-guide/6-authentication.md
jessiemongeon1 Jan 4, 2024
9c93368
Update docs/tutorials/hackathon-prep-guide/6-authentication.md
jessiemongeon1 Jan 4, 2024
381b672
Update docs/tutorials/hackathon-prep-guide/9-sample-starter-projects.md
jessiemongeon1 Jan 4, 2024
139a639
Update sidebars.js
jessiemongeon1 Jan 4, 2024
ba59523
Update index.md
jessiemongeon1 Jan 4, 2024
be7e9d9
Apply suggestions from code review
jessiemongeon1 Jan 4, 2024
6dd038a
Apply suggestions from code review
jessiemongeon1 Jan 4, 2024
011eeab
Apply code review revisions
jessiemongeon1 Jan 4, 2024
9ff9ea6
Update docs/tutorials/hackathon-prep-course/10-resources.md
jessiemongeon1 Jan 9, 2024
a03dd10
Update docs/tutorials/hackathon-prep-course/3-exploring-the-backend.md
jessiemongeon1 Jan 9, 2024
6dcbb6c
Update docs/tutorials/hackathon-prep-course/7-obtaining-cycles.md
jessiemongeon1 Jan 9, 2024
20f1e51
Update docs/tutorials/hackathon-prep-course/5-integrating-with-tokens.md
jessiemongeon1 Jan 9, 2024
f5990ff
Update docs/tutorials/hackathon-prep-course/7-obtaining-cycles.md
jessiemongeon1 Jan 9, 2024
06820ee
Update docs/tutorials/hackathon-prep-course/7-obtaining-cycles.md
jessiemongeon1 Jan 9, 2024
2ebd5e4
Update docs/tutorials/hackathon-prep-course/7-obtaining-cycles.md
jessiemongeon1 Jan 9, 2024
9b9064c
Update 7-obtaining-cycles.md
jessiemongeon1 Jan 9, 2024
02fe099
Update 8-managing-canisters.md
jessiemongeon1 Jan 9, 2024
e2c5f05
Update 8-managing-canisters.md
jessiemongeon1 Jan 9, 2024
ee392a5
Update docs/tutorials/hackathon-prep-course/7-obtaining-cycles.md
jessiemongeon1 Jan 9, 2024
495fc8a
Update docs/tutorials/hackathon-prep-course/7-obtaining-cycles.md
jessiemongeon1 Jan 9, 2024
38e4550
Update 7-obtaining-cycles.md
jessiemongeon1 Jan 9, 2024
6d17195
✨ added warning
letmejustputthishere Jan 16, 2024
f740b13
Merge remote-tracking branch 'upstream/master' into accel-dev-journey
letmejustputthishere Jan 16, 2024
22f683a
🐛 fixed wrong exampels path
letmejustputthishere Jan 16, 2024
609f2e7
🩹 fixed broken link
letmejustputthishere Jan 16, 2024
0c8141c
🩹 link
letmejustputthishere Jan 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Overview

The Internet Computer (ICP) is a transparent and secure blockchain network that enables developers to create and deploy fully decentralized applications. Decentralized applications are created through deploying smart contracts, which are known as **canisters** on ICP. Canisters are highly scalable to directly serve user experiences. Each canister on the Internet Computer is hosted on an independent version of the blockchain network called a **subnet**.
The Internet Computer (ICP) is a transparent and secure blockchain network that enables developers to create and deploy fully decentralized applications. Decentralized applications are created through deploying smart contracts, which are known as **canisters** on ICP. Canisters are highly scalable to directly serve user experiences. Each canister on the Internet Computer is hosted on an independent version of the blockchain network called a **subnet**. **Subnets** can seamlessly communicate with each other.

## Vision of the Internet Computer

Expand All @@ -15,10 +15,12 @@ You can learn more about the vision of the Internet Computer in the [ICP deck](h
## Architecture of the Internet Computer Protocol
### Subnets

An subnet is a collection of nodes that run their own instance of the Internet Computer Protocol's consensus algorithm, essentially running their own blockchain. Each subnet consists of node machines, or nodes, which are used to host canister smart contracts. Each canister's code, along with its state and computation, is replicated across every node on the subnet.
A subnet is a collection of nodes that run their own instance of the Internet Computer Protocol's consensus algorithm, essentially running their own blockchain. Each subnet consists of node machines, or nodes, which are used to host canister smart contracts. Each canister's code, along with its state and computation, is replicated across every node on the subnet.

Subnets are designed to be highly scalable and host canister smart contracts efficiently. Each subnet operates concurrently with and independently of the other subnets, but can communicate asynchronously with other subnets. Multiple independent subnets run in parallel, allowing the Internet Computer to break through the single-machine barrier that limits traditional blockchains.

![Subnets](./_attachments/subnets.png)

### Deterministic decentralization

The term deterministic decentralization refers to a concept used to maximize the decentralization and diversity of each subnet on ICP. Deterministic decentralization measures and maximizes the decentralization of every layer of the ICP infrastructure by maximizing the number of different node providers, data centers, geographies, and jurisdictions. The purpose of deterministic decentralization is to ensure that the network remains diverse and decentralized.
Expand Down Expand Up @@ -58,7 +60,7 @@ Users can be onboarded into the ICP ecosystem seamlessly through dozens of diffe

- [Developer Journey video series](https://www.youtube.com/watch?v=3WpP8ux1zX0).

- [ICP Zero to Dapp workshop series](https://www.youtube.com/watch?v=P3ngpMedCTE).
- [ICP Zero to Dapp workshop series](https://youtube.com/playlist?list=PLfEHHr3qexv8hKOJBV1XR10XhUKkyPIBp&si=KqnDuEgJZt51q4e4).

- [Motoko Bootcamp](https://www.motokobootcamp.com/).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ To learn more about ICP, a specific feature or workflow, or get help from other

- [ICP developer documentation.](/docs/current/home)

- [ICP Zero to Dapp Hackathon.](https://www.encode.club/zero-to-dapp-hackathon)

- [ICP developer journey tutorial series.](https://internetcomputer.org/docs/current/tutorials/developer-journey/)

- [ICP developer journey video series.](https://www.youtube.com/watch?v=oBUpJ4CqmN0)
Expand All @@ -16,7 +18,9 @@ To learn more about ICP, a specific feature or workflow, or get help from other

- [Developer tooling working group](https://www.google.com/calendar/event?eid=MHY0cjBubmlnYXY1cTkzZzVzcmozb3ZjZm5fMjAyMzEwMDVUMTcwMDAwWiBjX2Nnb2VxOTE3cnBlYXA3dnNlM2lzMWhsMzEwQGc&ctz=Europe/Zurich).

- [Motoko bootcamp](https://github.com/motoko-bootcamp/bootcamp-2022), a week-long crash course to learning all things Motoko.
- [Motoko Bootcamp - The DAO Adventure](https://github.com/motoko-bootcamp/dao-adventure) - Discover the Motoko language in this 7 day adventure and learn to build a DAO on the Internet Computer.

- [Motoko Bootcamp - Discord community](https://discord.gg/YbksCUxdzk) - A community for and by Motoko developers to ask for advice, showcase projects and participate in collaborative events.

- [Motoko developer working group](https://www.google.com/calendar/event?eid=ZWVnb2luaHU0ZjduMTNpZHI3MWJkcWVwNWdfMjAyMzEwMTJUMTUwMDAwWiBjX2Nnb2VxOTE3cnBlYXA3dnNlM2lzMWhsMzEwQGc&ctz=Europe/Zurich).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,11 @@ A frontend canister hosts the portion of an application that is used to interact

Before continuing, it is important to learn about the several different types of identities and authentication methods that you'll encounter while developing on ICP.

- **Developer identity**: An identity created using dfx, which contains a private/public key pair, and has a principal data type derived from the public key. It can be compared to a Bitcoin or Ethereum wallet address.
- **Developer identity**: An identity created using dfx, which contains a private/public key pair, and has a principal derived from the public key.

- **Principals**: A generic identifier that can be used for users, canisters, and potentially other future concepts.
- **Principals**: A generic identifier that can be used for users, canisters, and potentially other future concepts. It can be compared to a Bitcoin or Ethereum wallet address. Each principal can control multiple accounts in the ICP (and other) ledgers.

- **Principal identifiers**: A principal associated with a user principal ID. Principal identifiers are related to account identifiers, but use a different format. Each principal identity can control multiple accounts in the ICP (and other) ledgers.

- **Account identifier**: The identifier associated with your ICP ledger account, as specified in the ledger specification.
- **Account identifier**: The identifier associated with your ICP ledger account, as specified in the [ledger specification](https://internetcomputer.org/docs/current/references/ledger#_accounts).

- **Wallets**: Wallets are used to store forms of currency or other assets, such as cycles, ICP, or NFTs. Developers primarily use a cycles wallet to send cycles to and from canisters.

Expand All @@ -119,7 +117,7 @@ You can learn more about identities and principals [here](/docs/current/tutorial

### Cycles and cycles wallets

Cycles are used to measure and pay for the resources that are used by a canister, such as the memory, storage, and compute power. For canisters deployed locally, cycles are not charged for the resources used to run that canister on your local hardware. However, once a canister is deployed to the mainnet, cycles are charged to pay for the resources being used on the network. This is known as the ICP's 'reverse gas model', which enables developers to pay for the gas costs of their dapp, rather than end-users having to pay gas fees when using a dapp.
Cycles are used to measure and pay for the resources that are used by a canister, such as the memory, storage, and compute power. For canisters deployed locally, cycles can be fabricated. However, once a canister is deployed to the mainnet, real cycles are charged to pay for the resources being used on the network. This is known as the ICP's 'reverse gas model', which enables developers to pay for the gas costs of their dapp, rather than end-users having to pay gas fees when using a dapp. This helps aid in onboarding new users onto dapps deployed on ICP, since there aren't prerequisites such as needing a cryptowallet containing tokens to interact with a dapp.

To get cycles, you can convert ICP tokens into cycles, or you can obtain a [cycles coupon](/docs/current/tutorials/developer-journey/level-1/1.4-using-cycles#acquiring-cycles-using-a-cycles-coupon) if you haven't previously received one before.

Expand Down Expand Up @@ -168,18 +166,14 @@ Before you can deploy your first dapp on ICP, you will need to set up your devel

- [x] Download and install [git](https://git-scm.com/downloads).

- [x] Download and install the React framework with the command `npm install --save react react-dom`.

- [x] Download and install the TypeScript language compiler with the command `npm install --save-dev typescript ts-loader`.

- [x] Download and install [Node.js](https://nodejs.org/en).

Then, to download the template project, first create a new directory, then download the project template using the commands:

```
mkdir react-project
cd react-project
npx degit rvanasa/vite-react-motoko
npx degit rvanasa/vite-react-motoko react-project
```

Then you will need to start a local replica with `dfx` using the command:
Expand Down Expand Up @@ -215,6 +209,10 @@ URLs:
backend: http://127.0.0.1:4943/?canisterId=a4tbr-q4aaa-aaaaa-qaafq-cai&id=asrmz-lmaaa-aaaaa-qaaeq-cai
```

In this example, the frontend of the dapp is deployed to a canister locally. To make changes to the frontend canister, the canister must be redeployed each time a change is made to see the changes reflected at the canister's web browser URL. For quicker feedback loops for changes, this example uses a local development server that features hot module reloading.

For backend canisters, [`mo-dev`](https://github.com/dfinity/motoko-dev-server) enables hot module reloading for backend canisters, which removes the need to redeploy a backend canister to see changes reflected.

Before interacting with the React interface running in the frontend canister, start the local development server with the command:

```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ First, the code defines an actor called `Backend`. In Motoko, programs consist o
actor class Backend() {
```

Next, the code defines a variable (`var`) called `counter` with a value of `0`. This variable is defined with the word `stable`, which indicates it is a **stable variable**. A stable variable is a variable defined within an actor which uses the `stable` keyword in the variable's declaration. This indicates that the data stored in the variable should be stored using stable storage. This tutorial will go further into stable storage in the section [stable memory](#stable-memory) If this stable keyword is not used, the variable is defined as flexible by default.
Next, the code defines a variable (`var`) called `counter` with a value of `0`. This variable is defined with the word `stable`, which indicates it is a **stable variable**. A stable variable is a variable defined within an actor which uses the `stable` keyword in the variable's declaration. This indicates that the data stored in the variable should be persisted during canister upgrades. This tutorial will go further into stable storage in the section [stable memory](#stable-memory) If this stable keyword is not used, the variable is defined as flexible by default.

```motoko
stable var counter = 0;
Expand Down Expand Up @@ -132,7 +132,7 @@ When developing a project, certain third-party canisters may be beneficial to in

When integrating with third-party canisters, it is important to test the integration locally to assure that the integration is accurate and correct. Performing tests locally is beneficial since tests executed in a local developer environment do not cost cycles, use non-production data, and have a faster completion time when run locally.

To test the integration with a third-party canister locally, dfx supports pulling a third-party canister from the mainnet via the `dfx deps` workflow. Using this workflow, you can pull a canister from the mainnet by configuring your project's `dfx.json` file to include a `dependency` of the canister you'll be pulling. Then, define the pullable canister as type `pull` and include the canister's ID on the mainnet. For example, to pull the Internet Identity canister with canister ID of `rdmx6-jaaaa-aaaaa-aaadq-cai`, the following `dfx.json` file can be used:
To test the integration with a third-party canister locally, dfx supports pulling a third-party canister from the mainnet via the [`dfx deps`](https://fnoix-mqaaa-aaaam-abtca-cai.icp0.io/docs/current/developer-docs/setup/pulling-canister-dependencies) workflow. Using this workflow, you can pull a canister from the mainnet by configuring your project's `dfx.json` file to include a `dependency` of the canister you'll be pulling. Then, define the pullable canister as type `pull` and include the canister's ID on the mainnet. For example, to pull the Internet Identity canister with canister ID of `rdmx6-jaaaa-aaaaa-aaadq-cai`, the following `dfx.json` file can be used:


```json
Expand Down Expand Up @@ -167,7 +167,7 @@ For more information on using third-party canisters, check out the documentation

When calls are made on ICP, there are two primary types: query calls and update calls.

**Query calls** are calls that do not alter the state of a canister, making them 'read-only' operations. Query calls are used to query the current state of a canister or make a call to a method that operates on the canister's state. They are executed synchronously and answered immediately once received. Query calls are executed on a single node within a subnet. The backend canister in this example uses the following query call, defined by the keyword `query` as seen above:
**Query calls** are calls that do not alter the state of a canister, making them 'read-only' operations. Query calls are used to query the current state of a canister or make a call to a method that operates on the canister's state. They are executed synchronously and answered immediately once received. Query calls are executed on a single node within a subnet. Query methods can be called in replicated mode as update calls. The backend canister in this example uses the following query call, defined by the keyword `query` as seen above:

```motoko
public query func get() : async Nat {
Expand Down Expand Up @@ -206,7 +206,7 @@ For example, a simple service description that defines a service without any pub
service : {}
```

A service description that does not have any pubic methods is not very useful. To add a public method, you can add a simple `ping` method:
A service description that does not have any public methods is not very useful. To add a public method, you can add a simple `ping` method:

```
service : {
Expand Down Expand Up @@ -281,7 +281,7 @@ Additionally, Mops is defined as the project's package manager in the project's
...
```

To add additional packages to your project's dependencies, you can use the command `maps add` then the package name:
To add additional packages to your project's dependencies, you can use the command `mops add` then the package name:

```
mops add base
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ In this `vite-react-motoko` example, a JavaScript agent is used. An agent is a l

In addition to the JavaScript agent, DFINITY has developed and maintains a Rust agent, and the ICP community supports several agents for .NET, Go, Python, Ruby, and more.

In your `vite-react-motoko` example, the JavaScript agent file is scored at `src/declarations/frontend/index.js`. This file is generated as part of the `npm run setup` command, and contains the following content:
In your `vite-react-motoko` example, the JavaScript agent file is stored at `src/declarations/frontend/index.js`. This file is generated as part of the `npm run setup` command, and contains the following content:

```javascript
import { Actor, HttpAgent } from "@dfinity/agent";
Expand Down Expand Up @@ -284,15 +284,21 @@ export const createActor = (canisterId, options = {}) => {
export const frontend = createActor(canisterId);
```

In this code, the constructor first creates an HTTPAgent which wraps the JavaScript API, then uses it to encode calls through the public API. If the deployment is on the mainnet, the root key of the replica is fetched. Then, an actor is created using the automatically generated Candid interface for the canister and is passed the canister ID and the HTTPAgent.
In this code, the constructor first creates an `HTTPAgent` which wraps the JavaScript API, then uses it to encode calls through the public API. If the deployment is on the local testnet, the root key of the replica is fetched. Then, an actor is created using the automatically generated Candid interface for the canister and is passed the canister ID and the `HTTPAgent`.

You can learn more about agents in the documentation [here](/docs/current/developer-docs/agents/).

### HTTPS interfaces
### Serving HTTP content

Smart contract canisters are able to serve HTTP content natively, allowing for dapp frontends to be served directly in a web browser using the canister's URL at `http://<canister id>.ic0.app` and `http://<canister id>.raw.ic0.app`. Frontend canisters can be used to deliver HTML, CSS and JavaScript pages, and answer API requests.

If a canister wants to serve HTTP content, it should implement a method that consumes a HTTP request, which contains a URL, HTTP method and headers, then outputs a HTTP response that contains a status, headers and the response body. The canister method can return HTML, CSS and JavaScript content as part of the HTTP response.

### HTTPS outcalls

On ICP, canisters can communicate directly with external servers or other blockchains through the use of HTTPS outcalls. This is a unique feature of ICP, since traditionally, other blockchain networks are only able to communicate with external servers through blockchain oracles, or third-party entities that relay calls from the blockchain to an external server, then route the response back to the blockchain.

HTTPS outcalls allow smart contract canisters on ICP to make calls directly to external HTTPS servers. Then, the response of these HTTPS calls can be used by the smart contract in a safe way that doesn't result in the a replica state divergence.
HTTPS outcalls allow smart contract canisters on ICP to make calls directly to external HTTPS servers. Then, the response of these HTTPS calls can be used by the smart contract in a safe way that doesn't result in a replica state divergence.

HTTPS outcalls provide the ability for different use cases and have several advantages compared to using oracles to handle external requests. Some of these are HTTPS outcalls use a stronger trust model since there are no external intermediaries required for the canister to communicate with external servers. Using HTTPS outcalls for communicating with external servers makes using canisters feel much closer to a "traditional" programming workflow that may not use blockchains or oracles. Most real-world dapps have a need for accessing data stored in off-chain entities, since most digital data is still stored in traditional 'Web 2' services.

Expand Down
Loading
Loading