Crate overview

CrateVersionUse
rialo-cdk0.9.xPrimary on-chain library. Targets native (tokio) and wasm32
rialo-venus-dsl0.9.xAsync DSL macro — AFTER / EVERY / ON / SEND / START
rialo-sol-lang0.9.xAnchor-compatible eDSL for SVM-layer programs
rialo-s-sdk0.9.xClient-side Rust SDK (off-chain)
rialo-s-program0.9.xLow-level SVM program crate

prelude

Import everything you need in one line:

rust
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.

fntoken::transfer(from, to, amount)

Transfer native tokens between accounts.

rust
token::transfer(from: Pubkey, to: Pubkey, amount: u64) -> Result<()>
fntoken::transfer_stable(to, amount)

Transfer protocol stablecoin (USDC-equivalent).

rust
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.

GEThttps::get(url)
rust
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
⚠️
Determinism

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.

rust
// 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.

rust
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.

rust
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.

rust
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.

rust
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.

rust
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).

rust
// 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

MacroDescription
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

TypeDescription
ContextTransaction context — .signer, .accounts, .auth_token
Pubkey32-byte on-chain address
Result<T>Rialo result, maps to ProgramResult
DurationDuration::seconds(n), ::minutes(n), ::hours(n), ::days(n)
ClockClock::get().unix_timestamp — on-chain time
EventConditionComposable trigger condition for ON keyword