Introduction
This guide is a hands-on Silex tour inspired by the “by example” style. Each page introduces one idea, gives you a complete contract snippet, and links directly to Playground with the code preloaded.
Examples that only use pure language features can be compiled and run directly in Playground. Examples that use constructors, deposits, transfers, asset creation, scheduled executions, contract events, inter-contract calls, or RPC events need wallet/daemon RPC and an on-chain deployment on devnet.
Entries without an explicit return type use the default u64 exit code: 0 for success, or > 0 for a contract-defined error code. Examples with explicit return types demonstrate typed exit values; on-chain, those values are stored in contract logs and are limited to 256 encoded bytes.
Tour
- Hello entry
- Structs and methods
- Constructor and storage
- Iterators and closures
- Memory storage and scheduled block-end flush
- BTreeStore leaderboard
- Deposits, balances, and transfers
- Asset creation and minting
- Signature verification
- Homomorphic ciphertexts
- Contract events: publisher
- Contract events: listener
- Inter-contract calls and permissions
- Watching contract activity over RPC
Useful references
- Create your first contract
- Silex language reference
- Standard Library
- Homomorphic Encryption
- Wallet
build_transaction - Daemon events
What to try next
- Add pagination to the BTree leaderboard by passing
start_keyandpage_size. - Extend the vault to support any deposited asset with
get_deposits(). - Combine the publisher/listener examples with scheduled executions to batch oracle updates.
- Add signature checks to owner-only admin entries.
- Return the
commitment()andhandle()points from the ciphertext example to inspect its curve data. - Create an asset, mint it to the contract balance, transfer it to users, then accept it as a deposit in another contract.