Rust SDK
l3rs1-sdk - crates.io - Rust 1.77+
cargo add l3rs1-sdk
Dependencies: sha2, hex, serde_json, thiserror.
Quick Example
use l3rs1::crypto::construct_asset_id;
use l3rs1::modules::apply_state_transition;
use l3rs1::types::AssetState;
let id = construct_asset_id(
"0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",
1740355200, "0000000000000001").unwrap();
let state = apply_state_transition(&AssetState::Issued, "ACTIVATION").unwrap();
// state == AssetState::Active
API Reference
| Function/Method | § | Description |
constructAssetId / ConstructAssetID | 2.2 | H(pk_issuer ∥ ts ∥ nonce) |
constructCID / ConstructCID | 8.3 | CID = H(I ∥ SH ∥ CH ∥ GH ∥ t) |
constructTxId / ConstructTxID | 9.6 | TxID = H(sender ∥ receiver ∥ amount ∥ nonce ∥ ts) |
canonicalize | 13.11 | Sorted-key JSON, no whitespace |
applyStateTransition | 2.5 | Deterministic state machine, Invariant I1 |
evaluateCompliance | 4.3 | C: E to {0,1}, O(n), Invariant I2 |
validateFeeModule | 6.12 | Allocations must sum to 10000 bp |
identityStatus | 3.6 | VALID / EXPIRED / REVOKED |
isReplay | 9.6 | Replay protection via TxID/nonce |
Error Type
pub enum L3rsError {
InvalidStateTransition(String),
Validation(String),
Crypto(String),
Serialization(String),
}
State Transition Matrix
| From | Trigger | To |
| ISSUED | ACTIVATION | ACTIVE |
| ACTIVE | BREACH | RESTRICTED |
| ACTIVE | FREEZE | FROZEN |
| RESTRICTED | CLEARED | ACTIVE |
| FROZEN | RELEASE | ACTIVE |
| ACTIVE | REDEMPTION | REDEEMED |
| REDEEMED | FINALIZATION | BURNED (terminal) |
| ACTIVE | SUSPENSION | SUSPENDED |
| SUSPENDED | REINSTATEMENT | ACTIVE |