Skip to main content

Crate kal_sc

Crate kal_sc 

Source
Expand description

Smart contract SDK for the Kalvora Network.

Write contracts in Rust, compile to wasm32-unknown-unknown, and deploy to Kalvora validators. kal-sc wraps the native host ABI exposed by validators in a safe, idiomatic Rust API, handling serialization, memory management, and the different execution contexts (direct calls, delegatecall, derived wallets, etc.).

§Quick start

ⓘ
use kal_sc::{emit, wasmedge_bindgen};

#[wasmedge_bindgen]
pub fn hello(name: String) {
    emit(&format!("hello, {}", name));
}

§Modules

  • transfer — move tokens: send, send_multi, send_all, deposit, burn, mint
  • state — persist data: save, load, clear, exists
  • query — read network state: balances, token metadata, contract existence
  • call — invoke other contracts: execute or delegate
  • txn — submit raw network transactions
  • wallet — derive wallets owned by this contract
  • context — read the current frame: sender, block time, contract identity
  • crypto — hashing primitives: sha256, sha512, blake3, shake

§Non-WASM targets

On targets other than wasm32, every host function is stubbed to panic, so the crate compiles (and docs build) everywhere, but contract logic can only be exercised inside a validator.

Modules§

call
context
crypto
query
state
transfer
txn
wallet

Structs§

CoinDenomination
CoinTXN
Full coin-transfer transaction, mirroring the network’s CoinTXN proto (minus base, which the network fills in from the transaction context).
Compliance
ContractFees
ContractUpdateTXN
ExpenseRatio
Governance
InputTransfers
Describes which signer (by index into TransferAuthentication.public_key) is sending, how much, and how fees are split. Mirrors InputTransfers.
InstrumentContractTXN
KeyValuePair
MaxSupplyRelease
MintTXN
Full mint transaction, mirroring the network’s MintTXN proto (minus base, which the network fills in).
MultiKey
MultiPatterns
OutputTransfers
A single coin-transfer output. Mirrors OutputTransfers.
PreMintWallet
ProtoTimestamp
PublicKey
RestrictedKey
Stage
TokenCompliance
TransferAuthentication
Sender authentication for a CoinTXN. Mirrors the network’s TransferAuthentication proto. Each position in public_key, signature, and nonce refers to the same signer.
U256
Little-endian large integer type

Enums§

ContractFeeType
ContractType
GovernanceType
ProposalPeriod
TransactionType
TxnSender

Constants§

BRIDGE_GUARDIANS_CONTRACT_ID
The BridgeGuardians contract identifier.
BRIDGE_TOKENS_CONTRACT_ID
The BridgeTokens contract identifier.
KALVORA_NETWORK_CONTRACT_ID
The canonical Kalvora Network contract identifier.
KIP_CONTRACT_ID
The Kip contract identifier.
LEGAL_CONTRACT_ID
The Legal contract identifier.
MARKETING_CONTRACT_ID
The Marketing contract identifier.
MINT_CONTRACT_ID
The Mint contract identifier.
PREGOV_CONTRACT_ID
The PreGov contract identifier.
SMART_CONTRACT_MAINTENANCE_CONTRACT_ID
The Smart Contract Maintenance contract identifier.
TECH_CONTRACT_ID
The Tech contract identifier.
TREASURY_CONTRACT_ID
The Treasury contract identifier.
TREASURY_WALLET
The Treasury wallet address.

Functions§

decode
Decode a postcard-serialized, base64-encoded string back into T.
emit
Emit a log message from the contract. Visible in transaction results.
emit_block
Emit a block-level log message from the contract.
encode
Encode value as a postcard-serialized, base64-encoded string.
is_valid_u256
string_to_u256
u256_to_string

Attribute Macros§

wasmedge_bindgen