33 releases (13 stable)

new 1.1.0 Jun 1, 2026
1.0.11 Mar 23, 2026
1.0.9 Dec 9, 2025
1.0.8 Nov 12, 2025
0.1.2 Dec 27, 2023

#403 in Magic Beans

Download history 18/week @ 2026-02-11 2/week @ 2026-02-18 7/week @ 2026-02-25 119/week @ 2026-03-04 59/week @ 2026-03-11 25/week @ 2026-03-18 17/week @ 2026-03-25 2/week @ 2026-04-01 10/week @ 2026-04-08 7/week @ 2026-04-15 31/week @ 2026-04-22 18/week @ 2026-04-29 35/week @ 2026-05-06 6/week @ 2026-05-13 12/week @ 2026-05-20 10/week @ 2026-05-27

64 downloads per month
Used in 5 crates (3 directly)

MIT license

74KB
1.5K SLoC

kormir

Crate Documentation

A DLC oracle implementation for creating announcements and signing attestations.

Kormir supports both enumeration and numeric events, with optional Nostr protocol integration for publishing oracle data.

Usage

use kormir::{Oracle, OracleAnnouncement, Storage};

// Create oracle from extended private key
let oracle = Oracle::from_xpriv(storage, xpriv)?;

// Create an enumeration event
let announcement = oracle.create_enum_event(
    "game-result",
    vec!["team_a".to_string(), "team_b".to_string(), "draw".to_string()],
    maturity_epoch,
).await?;

// Sign the outcome
let attestation = oracle.sign_enum_event("game-result", "team_a").await?;

Numeric Events

// Create a numeric event (base 2)
let announcement = oracle.create_numeric_event(
    "btc-price",
    Some(20),        // num_digits
    Some(false),     // is_signed
    Some(0),         // precision
    "USD".to_string(),
    maturity_epoch,
).await?;

// Sign with numeric outcome
let attestation = oracle.sign_numeric_event("btc-price", 50000).await?;

Storage Trait

Implement the Storage trait for your backend:

#[async_trait]
pub trait Storage {
    async fn get_next_nonce_indexes(&self, num: usize) -> Result<Vec<u32>, Error>;
    async fn save_announcement(&self, announcement: OracleAnnouncement, indexes: Vec<u32>) -> Result<String, Error>;
    async fn save_signatures(&self, event_id: String, sigs: Vec<(String, Signature)>) -> Result<OracleEventData, Error>;
    async fn get_event(&self, event_id: String) -> Result<Option<OracleEventData>, Error>;
}

A MemoryStorage implementation is provided for testing.

Nostr Integration

With the nostr feature, publish announcements and attestations to Nostr:

use kormir::nostr_events::{create_announcement_event, create_attestation_event};

// Get Nostr keys from oracle
let keys = oracle.nostr_keys();

// Create Nostr event for announcement (Kind 88)
let event = create_announcement_event(&keys, &announcement)?;

// Create Nostr event for attestation (Kind 89)
let event = create_attestation_event(&keys, &attestation, &announcement_event_id)?;

Features

Feature Description
nostr Nostr protocol integration for publishing oracle data

Running a Kormir Server

See the kormir repository for the HTTP server implementation.

License

This project is licensed under the MIT License.

Dependencies

~32MB
~467K SLoC