Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
72 changes: 63 additions & 9 deletions public/llms-full.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2559,6 +2559,14 @@ persistent actor {

```toml
# Cargo.toml
[package]
name = "https_outcalls_backend"
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["cdylib"]

[dependencies]
ic-cdk = "0.18"
candid = "0.10"
Expand Down Expand Up @@ -3055,6 +3063,14 @@ persistent actor {
#### Cargo.toml Dependencies

```toml
[package]
name = "icrc_ledger_backend"
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["cdylib"]

[dependencies]
ic-cdk = "0.18"
candid = "0.10"
Expand Down Expand Up @@ -3387,6 +3403,8 @@ Internet Identity (II) is the Internet Computer's native authentication system.

7. **Not calling `agent.fetchRootKey()` in local development.** Without this, certificate verification fails on localhost. Never call it in production -- it's a security risk on mainnet.

8. **Storing auth state in `thread_local!` without stable storage (Rust)** -- `thread_local! { RefCell<T> }` is heap memory, wiped on every canister upgrade. Use `StableCell` from `ic-stable-structures` for any state that must persist across upgrades, especially ownership/auth data.

## Implementation

### icp.json Configuration
Expand Down Expand Up @@ -3566,19 +3584,31 @@ persistent actor {

```toml
# Cargo.toml
[package]
name = "ii_backend"
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["cdylib"]

[dependencies]
ic-cdk = "0.18"
candid = "0.10"
serde = { version = "1", features = ["derive"] }
ic-stable-structures = "0.7"
```

```rust
use candid::Principal;
use ic_cdk::{caller, query, update};
use ic_stable_structures::{DefaultMemoryImpl, StableCell};
use std::cell::RefCell;

thread_local! {
static OWNER: RefCell<Option<Principal>> = RefCell::new(None);
static OWNER: RefCell<StableCell<Option<Principal>, DefaultMemoryImpl>> = RefCell::new(
StableCell::init(DefaultMemoryImpl::default(), None).unwrap()
);
}

/// Reject anonymous principal. Call this at the top of every protected endpoint.
Expand All @@ -3597,10 +3627,10 @@ fn init_owner() -> String {
let caller = require_auth();

OWNER.with(|owner| {
let mut owner = owner.borrow_mut();
match *owner {
let mut cell = owner.borrow_mut();
match cell.get() {
None => {
*owner = Some(caller);
cell.set(Some(caller)).unwrap();
format!("Owner set to {}", caller)
}
Some(_) => "Owner already initialized".to_string(),
Expand All @@ -3613,8 +3643,8 @@ fn admin_action() -> String {
let caller = require_auth();

OWNER.with(|owner| {
let owner = owner.borrow();
match *owner {
let cell = owner.borrow();
match cell.get() {
Some(o) if o == caller => "Admin action performed".to_string(),
Some(_) => ic_cdk::trap("Only the owner can call this function."),
None => ic_cdk::trap("Owner not set. Call init_owner first."),
Expand Down Expand Up @@ -4089,7 +4119,7 @@ crate-type = ["cdylib"]
ic-cdk = "0.18"
candid = "0.10"
serde = { version = "1", features = ["derive"] }
ic-stable-structures = "0.6"
ic-stable-structures = "0.7"
```

#### src/user_service/src/lib.rs
Expand Down Expand Up @@ -4198,7 +4228,7 @@ crate-type = ["cdylib"]
ic-cdk = "0.18"
candid = "0.10"
serde = { version = "1", features = ["derive"] }
ic-stable-structures = "0.6"
ic-stable-structures = "0.7"
```

#### src/content_service/src/lib.rs
Expand Down Expand Up @@ -4830,7 +4860,7 @@ Distribution:
vesting_period: 31_557_600 # seconds (12 months)

InitialBalances:
governance: 520_000_000_000_000 # e8s (5_200_000 tokens) — Treasury (controlled by DAO)
governance: 500_000_000_000_000 # e8s (5_000_000 tokens) — Treasury (controlled by DAO)
swap: 250_000_000_000_000 # e8s (2_500_000 tokens) — Sold during decentralization swap

total: 1_000_000_000_000_000 # e8s (10_000_000 tokens) — Must equal sum of all allocations
Expand Down Expand Up @@ -5213,6 +5243,14 @@ Rust canisters use `ic-stable-structures` for persistent storage. The `MemoryMan
#### Cargo.toml

```toml
[package]
name = "stable_memory_backend"
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["cdylib"]

[dependencies]
ic-cdk = "0.18"
ic-stable-structures = "0.7"
Expand Down Expand Up @@ -5570,6 +5608,14 @@ vetkd_derive_key : (record {
**Cargo.toml:**

```toml
[package]
name = "vetkd_backend"
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["cdylib"]

[dependencies]
candid = "0.10"
ic-cdk = "0.18"
Expand Down Expand Up @@ -6052,6 +6098,14 @@ persistent actor {
#### Cargo.toml Dependencies

```toml
[package]
name = "wallet_backend"
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["cdylib"]

[dependencies]
ic-cdk = "0.18"
candid = "0.10"
Expand Down
6 changes: 3 additions & 3 deletions public/sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://dfinity.github.io/icskills/</loc>
<lastmod>2026-02-25</lastmod>
<lastmod>2026-02-26</lastmod>
<changefreq>weekly</changefreq>
<priority>1.0</priority>
</url>
Expand Down Expand Up @@ -80,13 +80,13 @@
</url>
<url>
<loc>https://dfinity.github.io/icskills/llms.txt</loc>
<lastmod>2026-02-25</lastmod>
<lastmod>2026-02-26</lastmod>
<changefreq>weekly</changefreq>
<priority>0.8</priority>
</url>
<url>
<loc>https://dfinity.github.io/icskills/llms-full.txt</loc>
<lastmod>2026-02-25</lastmod>
<lastmod>2026-02-26</lastmod>
<changefreq>weekly</changefreq>
<priority>0.8</priority>
</url>
Expand Down
8 changes: 8 additions & 0 deletions skills/https-outcalls/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,14 @@ persistent actor {

```toml
# Cargo.toml
[package]
name = "https_outcalls_backend"
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["cdylib"]

[dependencies]
ic-cdk = "0.18"
candid = "0.10"
Expand Down
8 changes: 8 additions & 0 deletions skills/icrc-ledger/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,14 @@ persistent actor {
#### Cargo.toml Dependencies

```toml
[package]
name = "icrc_ledger_backend"
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["cdylib"]

[dependencies]
ic-cdk = "0.18"
candid = "0.10"
Expand Down
26 changes: 20 additions & 6 deletions skills/internet-identity/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ Internet Identity (II) is the Internet Computer's native authentication system.

7. **Not calling `agent.fetchRootKey()` in local development.** Without this, certificate verification fails on localhost. Never call it in production -- it's a security risk on mainnet.

8. **Storing auth state in `thread_local!` without stable storage (Rust)** -- `thread_local! { RefCell<T> }` is heap memory, wiped on every canister upgrade. Use `StableCell` from `ic-stable-structures` for any state that must persist across upgrades, especially ownership/auth data.

## Implementation

### icp.json Configuration
Expand Down Expand Up @@ -227,19 +229,31 @@ persistent actor {

```toml
# Cargo.toml
[package]
name = "ii_backend"
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["cdylib"]

[dependencies]
ic-cdk = "0.18"
candid = "0.10"
serde = { version = "1", features = ["derive"] }
ic-stable-structures = "0.7"
```

```rust
use candid::Principal;
use ic_cdk::{caller, query, update};
use ic_stable_structures::{DefaultMemoryImpl, StableCell};
use std::cell::RefCell;

thread_local! {
static OWNER: RefCell<Option<Principal>> = RefCell::new(None);
static OWNER: RefCell<StableCell<Option<Principal>, DefaultMemoryImpl>> = RefCell::new(
StableCell::init(DefaultMemoryImpl::default(), None).unwrap()
);
}

/// Reject anonymous principal. Call this at the top of every protected endpoint.
Expand All @@ -258,10 +272,10 @@ fn init_owner() -> String {
let caller = require_auth();

OWNER.with(|owner| {
let mut owner = owner.borrow_mut();
match *owner {
let mut cell = owner.borrow_mut();
match cell.get() {
None => {
*owner = Some(caller);
cell.set(Some(caller)).unwrap();
format!("Owner set to {}", caller)
}
Some(_) => "Owner already initialized".to_string(),
Expand All @@ -274,8 +288,8 @@ fn admin_action() -> String {
let caller = require_auth();

OWNER.with(|owner| {
let owner = owner.borrow();
match *owner {
let cell = owner.borrow();
match cell.get() {
Some(o) if o == caller => "Admin action performed".to_string(),
Some(_) => ic_cdk::trap("Only the owner can call this function."),
None => ic_cdk::trap("Owner not set. Call init_owner first."),
Expand Down
4 changes: 2 additions & 2 deletions skills/multi-canister/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ crate-type = ["cdylib"]
ic-cdk = "0.18"
candid = "0.10"
serde = { version = "1", features = ["derive"] }
ic-stable-structures = "0.6"
ic-stable-structures = "0.7"
```

#### src/user_service/src/lib.rs
Expand Down Expand Up @@ -491,7 +491,7 @@ crate-type = ["cdylib"]
ic-cdk = "0.18"
candid = "0.10"
serde = { version = "1", features = ["derive"] }
ic-stable-structures = "0.6"
ic-stable-structures = "0.7"
```

#### src/content_service/src/lib.rs
Expand Down
2 changes: 1 addition & 1 deletion skills/sns-launch/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ Distribution:
vesting_period: 31_557_600 # seconds (12 months)

InitialBalances:
governance: 520_000_000_000_000 # e8s (5_200_000 tokens) — Treasury (controlled by DAO)
governance: 500_000_000_000_000 # e8s (5_000_000 tokens) — Treasury (controlled by DAO)
swap: 250_000_000_000_000 # e8s (2_500_000 tokens) — Sold during decentralization swap

total: 1_000_000_000_000_000 # e8s (10_000_000 tokens) — Must equal sum of all allocations
Expand Down
8 changes: 8 additions & 0 deletions skills/stable-memory/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@ Rust canisters use `ic-stable-structures` for persistent storage. The `MemoryMan
#### Cargo.toml

```toml
[package]
name = "stable_memory_backend"
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["cdylib"]

[dependencies]
ic-cdk = "0.18"
ic-stable-structures = "0.7"
Expand Down
8 changes: 8 additions & 0 deletions skills/vetkd/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ vetkd_derive_key : (record {
**Cargo.toml:**

```toml
[package]
name = "vetkd_backend"
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["cdylib"]

[dependencies]
candid = "0.10"
ic-cdk = "0.18"
Expand Down
8 changes: 8 additions & 0 deletions skills/wallet/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,14 @@ persistent actor {
#### Cargo.toml Dependencies

```toml
[package]
name = "wallet_backend"
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["cdylib"]

[dependencies]
ic-cdk = "0.18"
candid = "0.10"
Expand Down