Expand description
TruthLinked Smart Contract SDK
This SDK provides a complete toolkit for building smart contracts on the TruthLinked blockchain.
§Features
- Storage: Type-safe collections (maps, vectors, blobs) with dual API pattern
- Codec: Efficient encoding/decoding for 32-byte and variable-length data
- Events: Structured logging with indexed topics
- Manifests: Declare storage access patterns for parallel execution
- Oracle: HTTP requests for external data
- Testing: In-memory storage harness for unit tests
§Quick Start
ⓘ
use truthlinked_sdk::prelude::*;
#[derive(Manifest)]
struct Counter {
#[manifest(read, write)]
value: Slot,
}
fn increment() -> Result<()> {
let counter = Counter {
value: Slot::from_label("count"),
};
let current = counter.value.read_u64()?;
counter.value.write_u64(current + 1)?;
Ok(())
}
contract_entry!(increment);§Module Overview
abi- Function selectors and calldata parsingbackend- Storage backend abstractioncall- Cross-contract callscodec- Encoding/decoding traits and builderscollections- StorageMap, StorageVec, StorageBlobcontext- Execution context (caller, height, timestamp, etc.)- [
env] - Low-level WASM host bindings error- Error types and Result aliashashing- Cryptographic utilitieslog- Event systemmanifest- Storage access declarationsoracle- HTTP oracle interfacestorage- Direct storage slot access- [
testing] - Unit test utilities
Re-exports§
Modules§
- abi
- ABI (Application Binary Interface) helpers for function dispatch and calldata parsing.
- backend
- Storage backend abstraction for contract state persistence.
- call
- Cross-contract call utilities for contract composability.
- codec
- Serialization and deserialization traits and utilities.
- collections
- High-level storage collections built on 32-byte slots.
- context
- Execution context accessors for contract runtime information.
- env
- Low-level WASM host environment bindings.
- error
- Error handling types and utilities for contract execution.
- hashing
- Cryptographic hashing utilities.
- log
- Event logging system for smart contracts.
- manifest
- Contract manifest generation for parallel execution optimization.
- oracle
- HTTP oracle interface for external data access.
- prelude
- Prelude module with commonly used imports.
- storage
- Storage slot abstraction for direct storage access.
Macros§
- contract_
entry - Defines the contract entry point.
- slot
- Macro for creating a
Slotfrom a 32-byte array.
Attribute Macros§
- error_
code - Attribute macro for defining error code enums.
- require
- Attribute macro for adding precondition checks to functions.
Derive Macros§
- Bytes
Codec - Derives the
BytesCodectrait for variable-length encoding. - Codec32
- Derives the
Codec32trait for 32-byte fixed-size encoding. - Event
- Derives the
Eventtrait for structured logging. - Manifest
- Derives the
Manifesttrait for storage access declarations.