Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
jessiemongeon1 committed Nov 22, 2024
2 parents af319b0 + 2270aca commit 55595f2
Show file tree
Hide file tree
Showing 29 changed files with 1,146 additions and 684 deletions.
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -598,15 +598,19 @@ The [Ecosystem Helper](https://mvw4g-yiaaa-aaaam-abnva-cai.icp0.io/) is an oncha

The list of tags is not final, and will be updated as the project evolves. For now, the following tags are available:

- `Wallet`
- `AI`
- `Chain Fusion`
- `Bitcoin`
- `NFT`
- `SocialFi`
- `Ethereum`
- `DAO`
- `DeFi`
- `Enterprise`
- `Games`
- `DAO`
- `Metaverse`
- `NFT`
- `SocialFi`
- `Tools / Infrastructure`
- `Wallet`

### Object schema

Expand All @@ -617,7 +621,7 @@ The list of tags is not final, and will be updated as the project evolves. For n
oneLiner: string, // short description of the project
website: string, // URL starting with `https://`
tags: ('Wallet' | 'Bitcoin' | 'NFT' | 'SocialFi' | 'DeFi' | 'Games' | 'DAO' | 'Metaverse' | 'Tools / Infrastructure')[],
tags: ('AI' | 'Chain Fusion' | 'Bitcoin' | 'Ethereum' | 'DAO' | 'DeFi' | 'Enterprise' | 'Games' | 'Metaverse' | 'NFT' | 'SocialFi' | 'Tools / Infrastructure' | 'Wallet')[],
description: string, // description of the project
stats: string, // eg. "10,000 users"
logo: string, // url to logo file, eg. /img/showcase/awesome-icp-project_logo.webp
Expand Down
2 changes: 1 addition & 1 deletion docs/developer-docs/developer-tools/ide/gitpod.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ In this example, we'll use the [DFINITY examples repo](https://github.com/dfinit

- #### Step 8: To deploy your canister, first assure that your project has a `dfx.json` file.

[Learn more about the `dfx.json` file](/docs/current/developer-docs/smart-contracts/write/default-template)
[Learn more about the `dfx.json` file](/docs/current/developer-docs/smart-contracts/write/overview)

![Gitpod step 8](./_attachments/gitpod8.png)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ This test will do the following:

- Defines a test method that accepts two arguments. Inside this method, `expect` is used to check the result of the backend canister's `greet` function against the expected result.

This test is written for the [default backend canister](/docs/current/developer-docs/smart-contracts/write/default-template).
This test is written for the [default backend canister](/docs/current/developer-docs/smart-contracts/write/overview).

To run this test, you will need to deploy your project and generate the necessary declarations for your canister. [Learn more about creating and deploying a project](https://internetcomputer.org/docs/current/tutorials/developer-journey/level-2/2.5-unit-testing#end-to-end-e2e-testing).

Expand Down
92 changes: 18 additions & 74 deletions docs/developer-docs/smart-contracts/call/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,86 +26,56 @@ A query method can be called as both an update and a query, whereas update metho
| Goes through consensus | Does not go through consensus |
| Synchronous response | Synchronous response |
| Executed on all nodes of a subnet | Executed on a single node |

| Cost cycles | Free |

See the reference on [ingress messages](/docs/current/references/ingress-messages) for a more technical discussion of this topic.

## Update calls

Update calls are executed on all nodes of a <GlossaryTooltip>subnet</GlossaryTooltip> since the result of the call must go through consensus. This makes them slower than query calls. They are submitted asynchronously and answered synchronously.
Update calls are executed on all nodes of the <GlossaryTooltip>subnet</GlossaryTooltip> that the canister is deployed on since the result of the call must go through consensus. This makes them slower than query calls. They are submitted asynchronously and answered synchronously.

:::danger
Update calls do not go through consensus on the local replica.
:::

### Making update calls

To make a update call to a canister, use the [`dfx canister call`](/docs/current/developer-docs/developer-tools/cli-tools/cli-reference/dfx-canister#dfx-canister-call) command with the `--update` flag:


- `dfx canister call --update <canister_name> <method_name>` : Make an update call to a canister deployed locally. The local replica must be running to create a canister locally. Start it with `dfx start --background`.
- `dfx canister call --update <canister-name> <method_name>` : Make an update call to a canister deployed locally. The local replica must be running to create a canister locally. Start it with `dfx start --background`.

- `dfx canister call --update <canister_name> <method_name> --network=playground`: Make an update call to a canister deployed on the playground. Making update calls to canisters deployed on the playground is free, but canisters are temporary and will be removed after 20 minutes.
- `dfx canister call --update <canister-name> <method_name> --network=playground`: Make an update call to a canister deployed on the [playground](/docs/current/developer-docs/smart-contracts/deploy/overview#testnets). Making update calls to canisters deployed on the playground is free, but canisters are temporary and will be removed after 20 minutes.

- `dfx canister call --update <canister_name> <method_name> --network=ic`: Make an update call to a canister deployed on the mainnet. Update calls will cost [cycles](/docs/current/developer-docs/gas-cost).
- `dfx canister call --update <canister-name> <method_name> --network=ic`: Make an update call to a canister deployed on the mainnet. Update calls will cost [cycles](/docs/current/developer-docs/gas-cost).


### Using update calls from within canisters

<AdornedTabs groupId="language">
<TabItem value="motoko" label="Motoko" default>

```motoko
actor Counter {
stable var counter = 0;
public func inc() : async () {
counter += 1;
};
};
```motoko file=../../../references/samples/motoko/counter/src/Main.mo#L10-L13
```

</TabItem>

<TabItem value="rust" label="Rust">

```rust
use candid::types::number::Nat;
use std::cell::RefCell;

thread_local! {
static COUNTER: RefCell<Nat> = RefCell::new(Nat::from(0_u32));
}

#[ic_cdk::update]
fn inc() {
COUNTER.with(|counter| *counter.borrow_mut() += 1_u32);
}
```rust file=../../../references/samples/rust/counter/src/lib.rs#L14-L19
```

</TabItem>

<AdornedTab value={"typescript"} label="TypeScript" endAdornment={<BetaChip />}>

```typescript
Azle code coming soon.

[Learn more about Azle.](https://demergent-labs.github.io/azle/)
```

</AdornedTab>

<AdornedTab value={"python"} label="Python" endAdornment={<BetaChip />}>

```python
Kybra code coming soon.

[Learn more about Kybra.](https://demergent-labs.github.io/kybra/)
```
:::caution
Kybra canisters must be deployed from a Python virtual environment. [Learn more in the Kybra docs](/docs/current/developer-docs/backend/python/).
:::

</AdornedTab>

Expand All @@ -119,11 +89,11 @@ Query calls, also referred to as non-replicated queries, are executed on a singl

To make a query call to a canister, use the [`dfx canister call`](/docs/current/developer-docs/developer-tools/cli-tools/cli-reference/dfx-canister#dfx-canister-call) command with the `--query` flag:

- `dfx canister call --query <canister_name> <method_name>`: Make a query call to a canister deployed locally. The local replica must be running to create a canister locally. Start it with `dfx start --background`.
- `dfx canister call --query <canister-name> <method_name>`: Make a query call to a canister deployed locally. The local replica must be running to create a canister locally. Start it with `dfx start --background`.

- `dfx canister call --query <canister_name> <method_name> --network=playground`: Make a query call to a canister deployed on the playground. Query calls are free, but canisters are temporary and will be removed after 20 minutes.
- `dfx canister call --query <canister-name> <method_name> --network=playground`: Make a query call to a canister deployed on the [playground](/docs/current/developer-docs/smart-contracts/deploy/overview#testnets). Query calls are free, but canisters are temporary and will be removed after 20 minutes.

- `dfx canister call --query <canister_name> <method_name> --network=ic`: Make a query call to a canister deployed on the mainnet. Query calls are free.
- `dfx canister call --query <canister-name> <method_name> --network=ic`: Make a query call to a canister deployed on the mainnet. Query calls are free.

:::caution
The downside of query calls is that the response is not trusted since it's coming from a single node. An update call or a [certified query](#certified-queries) should be used for security-critical calls.
Expand All @@ -134,54 +104,28 @@ The downside of query calls is that the response is not trusted since it's comin
<AdornedTabs groupId="language">
<TabItem value="motoko" label="Motoko" default>

```motoko
actor {

public func greet(name : Text) : async Text {
return "Hello, " # name # "!";
};

};
```motoko no-repl file=../../../references/samples/motoko/counter/src/Main.mo#L5-L9
```


</TabItem>

<TabItem value="rust" label="Rust">

```rust
#[ic_cdk::query]
fn greet(name: String) -> String {
format!("Hello, {}!", name)
}
```rust file=../../../references/samples/rust/counter/src/lib.rs#L8-L12
```

</TabItem>

<AdornedTab value={"typescript"} label="TypeScript" endAdornment={<BetaChip />}>

```typescript
Azle code coming soon.

[Learn more about Azle.](https://demergent-labs.github.io/azle/)
```

</AdornedTab>

<AdornedTab value={"python"} label="Python" endAdornment={<BetaChip />}>

```python
Kybra code coming soon.

[Learn more about Kybra.](https://demergent-labs.github.io/kybra/)
```
:::caution
Kybra canisters must be deployed from a Python virtual environment. [Learn more in the Kybra docs](/docs/current/developer-docs/backend/python/).
:::

</AdornedTab>
</AdornedTabs>
Expand All @@ -198,11 +142,11 @@ Typically, a call is processed within a single message execution unless there ar

### Composite queries

Composite queries are query calls that can call other queries on the same <GlossaryTooltip>subnet</GlossaryTooltip>. They can only be invoked by end users and not by other canisters.
[Composite queries](/docs/current/developer-docs/smart-contracts/advanced-features/composite-query) are query calls that can call other queries on the same <GlossaryTooltip>subnet</GlossaryTooltip>. They can only be invoked by end users and not by other canisters.

### Certified queries

Certified queries use certified variables to prove the authenticity of a piece of data that comes along with the query's response. Certified variables can be set via an update call, then read via a query call.
Certified queries use [certified variables](/docs/current/references/samples/motoko/cert-var/) to prove the authenticity of a piece of data that comes along with the query's response. Certified variables can be set via an update call, then read via a query call.

### Replicated queries

Expand Down
6 changes: 3 additions & 3 deletions docs/developer-docs/smart-contracts/compile.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ To compile your canister's Wasm module, you can use the [`dfx build`](/docs/curr

Compile your canisters from within the project's directory:

- `dfx build <canister_name>`: Compile a canister locally. The local replica must be running to compile a canister locally. Start it with `dfx start --background`.
- `dfx build <canister-name>`: Compile a canister locally. The local replica must be running to compile a canister locally. Start it with `dfx start --background`.

- `dfx build <canister_name> --network=playground`: Compile a canister on the playground. Compiling a canister on the playground is free, but canisters are temporary and will be removed after 20 minutes.
- `dfx build <canister-name> --network=playground`: Compile a canister on the playground. Compiling a canister on the playground is free, but canisters are temporary and will be removed after 20 minutes.

- `dfx build <canister_name> --network=ic`: Compile a canister on the mainnet. Compiling a canister on the mainnet will cost [cycles](/docs/current/developer-docs/gas-cost).
- `dfx build <canister-name> --network=ic`: Compile a canister on the mainnet. Compiling a canister on the mainnet will cost [cycles](/docs/current/developer-docs/gas-cost).

- `dfx build --network=ic`: Compile all canisters in the project's `dfx.json` file on the mainnet.

Expand Down
6 changes: 3 additions & 3 deletions docs/developer-docs/smart-contracts/create.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ Canisters are created with [`dfx canister create`](/docs/current/developer-docs/

Create your canisters from within the project's directory:

- `dfx canister create <canister_name>`: Create a canister locally. The local replica must be running to create a canister locally. Start it with `dfx start --background`.
- `dfx canister create <canister-name>`: Create a canister locally. The local replica must be running to create a canister locally. Start it with `dfx start --background`.

- `dfx canister create <canister_name> --network=playground`: Create a canister on the playground. Creating a canister on the playground is free, but canisters are temporary and will be removed after 20 minutes.
- `dfx canister create <canister-name> --network=playground`: Create a canister on the [playground](/docs/current/developer-docs/smart-contracts/deploy/overview#testnets). Creating a canister on the playground is free, but canisters are temporary and will be removed after 20 minutes.

- `dfx canister create <canister_name> --network=ic`: Create a canister on the mainnet. Creating a canister on the mainnet will cost [cycles](/docs/current/developer-docs/gas-cost).
- `dfx canister create <canister-name> --network=ic`: Create a canister on the mainnet. Creating a canister on the mainnet will cost [cycles](/docs/current/developer-docs/gas-cost).

- `dfx canister create --all --network=ic`: Create all canisters in the project's `dfx.json` file on the mainnet.

Expand Down
16 changes: 8 additions & 8 deletions docs/developer-docs/smart-contracts/deploy/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,23 @@ For most developers, the playground option can be used. For more advanced develo
<input type="checkbox"/> <a href="/docs/current/developer-docs/smart-contracts/write/overview">Write a smart contract.</a>
<div>
</div>
<input type="checkbox"/> <a href="/docs/current/developer-docs/smart-contracts/create">Create your canister.</a>
<input type="checkbox"/> <a href="/docs/current/developer-docs/smart-contracts/create">Create your canister.</a> Optional; <code>dfx deploy</code> will execute this step if not already complete.
<div>
</div>
<input type="checkbox"/> <a href="/docs/current/developer-docs/smart-contracts/compile">Compile your canister code into Wasm.</a>
<input type="checkbox"/> <a href="/docs/current/developer-docs/smart-contracts/compile">Compile your canister code into Wasm.</a> Optional; <code>dfx deploy</code> will execute this step if not already complete.
<div>
</div>
<input type="checkbox"/> <a href="/docs/current/developer-docs/smart-contracts/install">Install the Wasm module into your canister.</a>
<input type="checkbox"/> <a href="/docs/current/developer-docs/smart-contracts/install">Install the Wasm module into your canister.</a> Optional; <code>dfx deploy</code> will execute this step if not already complete.
</TabItem>
</Tabs>

Verify you are in your project's directory and the canisters you'd like to deploy are configured in the project's `dfx.json` file.

- `dfx deploy hello_world`: Deploy a canister locally. The local replica must be running to deploy a canister locally. Start it with `dfx start --background`.
- `dfx deploy <canister-name>`: Deploy a canister locally. The local replica must be running to deploy a canister locally. Start it with `dfx start --background`.

- `dfx deploy hello_world --network=playground`: Deploy a canister on the playground. Deploying a canister on the playground is free, but canisters are temporary and will be removed after 20 minutes.
- `dfx deploy <canister-name> --network=playground`: Deploy a canister on the playground. Deploying a canister on the playground is free, but canisters are temporary and will be removed after 20 minutes.

- `dfx deploy hello_world --network=ic`: Deploy a canister on the mainnet. Deploying a canister on the mainnet will cost [cycles](/docs/current/developer-docs/gas-cost).
- `dfx deploy <canister-name> --network=ic`: Deploy a canister on the mainnet. Deploying a canister on the mainnet will cost [cycles](/docs/current/developer-docs/gas-cost).

- `dfx deploy --network=ic`: Deploy all canisters in the project's `dfx.json` file on the mainnet.

Expand Down Expand Up @@ -112,14 +112,14 @@ You can set a canister's init arguments when the canister is deployed by passing
the `--argument` flag:

```bash
dfx deploy <CANISTER_NAME> --argument "(arg in candid)"
dfx deploy <canister-name> --argument "(arg in candid)"
```

If several arguments should be used, an argument file can be defined with the
`--argument-file` flag instead:

```bash
dfx deploy <CANISTER_NAME> --argument-file file.txt
dfx deploy <canister-name> --argument-file file.txt
```

Alternatively, init arguments can be set in `dfx.json` in `dfx` versions
Expand Down
Loading

0 comments on commit 55595f2

Please sign in to comment.