Stylus Cache SDK
A Rust SDK for Stylus contract caching utilities with AutoCacheOptIn event support.
Features
- 🚀 Easy Integration: Simple functions for contract caching
- 📝 Event Support: Built-in
AutoCacheOptInevent - 🛠️ Trait-based: Optional
Cacheabletrait for standardized implementation - 📚 Well Documented: Comprehensive documentation and examples
Installation
Add this to your Cargo.toml:
[]
= "0.1.0"
Quick Start
Basic Usage
use ;
use *;
use Address;
Using the Cacheable Trait
use Cacheable;
use *;
use Address;
// Now you can use:
// contract.is_cacheable() -> bool
// contract.opt_into_cache(address) -> emits AutoCacheOptIn event
Updated Counter Contract Example
extern crate alloc;
use ;
use ;
sol_storage!
API Reference
Functions
is_contract_cacheable() -> bool: Returns whether the contract is cacheableemit_cache_opt_in(contract_addr: Address): Emits the AutoCacheOptIn event
Events
AutoCacheOptIn(address indexed contract_addr): Event for cache opt-in
Traits
Cacheable: Trait providing default caching functionality
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.