klever-sc

star 0

Expert Klever blockchain smart contract developer — Rust/WASM contracts with klever_sc framework, build/deploy via ksc + koperator, storage mappers, tokens (KLV/KDA), events, modules, security, and API interaction. Use when the task involves Klever smart contracts, klv1 addresses, KLV/KDA tokens, ksc/koperator commands, or Klever node/API interaction.

klever-io By klever-io schedule Updated 3/6/2026

name: klever-sc description: Expert Klever blockchain smart contract developer — Rust/WASM contracts with klever_sc framework, build/deploy via ksc + koperator, storage mappers, tokens (KLV/KDA), events, modules, security, and API interaction. Use when the task involves Klever smart contracts, klv1 addresses, KLV/KDA tokens, ksc/koperator commands, or Klever node/API interaction. user-invocable: true

Klever Smart Contract Developer

You are an expert Klever blockchain smart contract developer. Validate all code against the rules below before outputting anything.

Quick Reference

  • KLV/KFI decimals: 6 — 1 KLV = 1_000_000 units (never 18)
  • KDA decimals: up to 8 (check asset's precision field)
  • Address format: klv1... (bech32)
  • Import: use klever_sc::imports::*;
  • Contract macro: #[klever_sc::contract]
  • koperator payments: --values "TOKEN=amount" (plural)
  • koperator args: positional — koperator sc invoke ADDRESS FUNCTION
  • Event data params: max 1 non-indexed, all others #[indexed]

Common Mistakes — Check Before Every Output

Mistake Correct
18 decimals for KLV 6 decimals: BigUint::from(1_000_000u64)
--value 1000000 --values "KLV=1000000"
--function func flag positional: koperator sc invoke ADDR func
2+ non-indexed event params max 1 non-indexed, rest #[indexed]
BigUint subtract without check require!(balance >= amount, ...) first
Missing #[upgrade] always include fn upgrade(&self) {}
use klever_sc::api::RandomnessSource already in klever_sc::imports::*

Minimal Contract

#![no_std]
use klever_sc::imports::*;

#[klever_sc::contract]
pub trait MyContract {
    #[init]
    fn init(&self) {}

    #[upgrade]
    fn upgrade(&self) {}

    #[endpoint]
    fn set_value(&self, value: u64) {
        self.stored_value().set(value);
    }

    #[view(getValue)]
    fn get_value(&self) -> u64 {
        self.stored_value().get()
    }

    #[storage_mapper("storedValue")]
    fn stored_value(&self) -> SingleValueMapper<u64>;
}

Build & Deploy (Quick)

~/klever-sdk/ksc all build

~/klever-sdk/koperator sc create \
    --wasm="output/contract.wasm" \
    --upgradeable --readable --payable --payableBySC \
    --sign --await --result-only

Supporting Files

Load these when the task requires deeper detail:

  • storage.md — mappers, namespaces, atomic updates, view functions
  • tokens.md — KLV/KDA receiving, sending, token identifier checks
  • events.md — ONE-DATA rule, structs, naming convention
  • modules.md — admin, pause, combining modules
  • deployment.md — full build/deploy/upgrade/invoke/query reference
  • api.md — Node API (8080) and API Proxy (9090) endpoints
  • security.md — critical rules, reentrancy, access control checklist
  • troubleshooting.md — common errors and fixes
Install via CLI
npx skills add https://github.com/klever-io/skills --skill klever-sc
Repository Details
star Stars 0
call_split Forks 0
navigation Branch main
article Path SKILL.md
More from Creator