API Reference
Complete reference for the Rialo CDK — every module, function signature, and type available to on-chain programs.
Crate overview
| Crate | Version | Use |
|---|---|---|
rialo-cdk | 0.9.x | Primary on-chain library. Targets native (tokio) and wasm32 |
rialo-venus-dsl | 0.9.x | Async DSL macro — AFTER / EVERY / ON / SEND / START |
rialo-sol-lang | 0.9.x | Anchor-compatible eDSL for SVM-layer programs |
rialo-s-sdk | 0.9.x | Client-side Rust SDK (off-chain) |
rialo-s-program | 0.9.x | Low-level SVM program crate |
prelude
Import everything you need in one line:
use rialo_cdk::prelude::*;
// Exports: Context, Pubkey, Result, Clock, Duration,
// token, https, price_feed, messaging, random,
// schedule, cross_chain, require!, emit!, msg!
token
Native token operations — transfer, mint, burn, and balance queries.
Transfer native tokens between accounts.
token::transfer(from: Pubkey, to: Pubkey, amount: u64) -> Result<()>Transfer protocol stablecoin (USDC-equivalent).
token::transfer_stable(to: Pubkey, amount: u64) -> Result<()>
token::balance(account: Pubkey) -> Result
token::mint(to: Pubkey, amount: u64) -> Result<()>
token::burn(from: Pubkey, amount: u64) -> Result<()> https
Make secure HTTP requests directly from on-chain programs, verified via TEEs. No oracle needed.
https::get(url: impl Into) -> Result
https::post(url: impl Into, body: &T) -> Result
https::get_with_headers(url, headers) -> Result
// HttpResponse
response.status() -> u16
response.text() -> String
response.json::() -> Result // auto-deserializes HTTPS calls within the same block window are cached — the same URL returns the same response for all validators. Design your data sources accordingly.
price_feed
Native on-chain price data. No oracle subscription. Stable costs.
// Latest price (u64 scaled by 10^6)
price_feed::get(pair: &str) -> Result
// Price with confidence interval
price_feed::get_with_confidence(pair: &str) -> Result
// PriceWithConfidence { price: u64, confidence: u64, expo: i32 }
// Time-weighted average (e.g. 1-hour TWAP)
price_feed::twap(pair: &str, window: Duration) -> Result
// Event trigger conditions — use with ON keyword
price_feed::below(pair: &str, threshold: u64) -> EventCondition
price_feed::above(pair: &str, threshold: u64) -> EventCondition
price_feed::change(pair: &str, pct_bps: i64) -> EventCondition
Supported pairs include: BTC/USD, ETH/USD, SOL/USD, USDC/USD, and dozens more. Full list available in the testnet explorer.
messaging
Send encrypted notifications to users via wallet, email, SMS, or push — using identity-based encryption. No key exchange setup needed.
messaging::send(recipient: Pubkey, msg: &str) -> Result<()>
messaging::send_email(email: &str, msg: &str) -> Result<()>
messaging::send_sms(phone: &str, msg: &str) -> Result<()>
messaging::send_push(device_id: &str, msg: &str) -> Result<()>
random
True on-chain randomness — generated in a TEE enclave at execution time. Verifiably unpredictable and unbiasable.
random::range(min: u64, max: u64) -> u64 // [min, max)
random::bytes(len: usize) -> Vec
random::bool_with_prob(p: u8) -> bool // p in 0..=100
schedule
Create scheduled (future) transactions that execute at a specified time without the user being online.
schedule::create(
instruction: impl Instruction,
trigger: Trigger,
) -> Result
// Trigger variants
Trigger::Timestamp(unix_ts: i64)
Trigger::BlockHeight(height: u64)
Trigger::Event(condition: EventCondition)
schedule::cancel(id: ScheduledTxId) -> Result<()>
cross_chain
Read state from other chains without bridges or wrappers.
cross_chain::read(
chain: Chain,
address: impl Into<[u8; 32]>,
method: &str,
) -> Result>
// Chain variants
Chain::Ethereum
Chain::Solana
Chain::Bitcoin // read-only
cross_chain::send(
chain: Chain,
instruction: CrossChainInstruction,
) -> Result
scale
The SCALE framework for AI agent identity, payments, and task coordination.
use rialo_cdk::scale::*;
// Scoped wallet for agents
ScopedWallet::new()
.owner(pubkey)
.spend_limit(amount)
.spend_period(Duration::days(1))
.allowed_programs(vec![program_id])
.build() -> Result
// Pay with spend-limit enforcement
scale::pay(&wallet, to, amount, memo) -> Result<()>
scale::escrow(amount) -> Result
scale::release_escrow(to, amount) -> Result<()>
scale::refund_escrow() -> Result<()>
scale::new_task_id() -> u64
scale::discover_service(capability: &str)-> Result
tee
Confidential execution inside Trusted Execution Environments (Intel TDX / AMD SEV-SNP).
// Mark a function to run inside a TEE enclave
#[confidential]
fn sensitive_logic(input: SensitiveData) -> Output {
// Intermediate state is not visible to node operators
// Inputs and output are committed on-chain with TEE attestation
}
use rialo_cdk::crypto::ibe;
ibe::encrypt(Identity::Email("user@example.com"), data) -> Result>
ibe::encrypt(Identity::Pubkey(pk), data) -> Result>
Macros
| Macro | Description |
|---|---|
require!(cond, err) | Assert condition or return Err(err) |
emit!(Event { .. }) | Emit a typed on-chain event |
msg!("fmt", ..) | Log to transaction log (debug) |
rialo! { .. } | Main Venus DSL entry point (from rialo-venus-dsl) |
Core types
| Type | Description |
|---|---|
Context | Transaction context — .signer, .accounts, .auth_token |
Pubkey | 32-byte on-chain address |
Result<T> | Rialo result, maps to ProgramResult |
Duration | Duration::seconds(n), ::minutes(n), ::hours(n), ::days(n) |
Clock | Clock::get().unix_timestamp — on-chain time |
EventCondition | Composable trigger condition for ON keyword |