#events #casper #standard #level #contracts #schema #emit

casper-event-standard

The smart contract level events for Casper

6 releases (3 breaking)

0.4.1 Nov 10, 2023
0.4.0 Jun 14, 2023
0.3.0 May 11, 2023
0.2.0 Feb 20, 2023
0.1.0 Jan 31, 2023

#1990 in Magic Beans

Download history 63/week @ 2023-12-04 237/week @ 2023-12-11 75/week @ 2023-12-18 45/week @ 2023-12-25 50/week @ 2024-01-01 54/week @ 2024-01-08 35/week @ 2024-01-15 54/week @ 2024-01-22 138/week @ 2024-01-29 151/week @ 2024-02-05 181/week @ 2024-02-12 70/week @ 2024-02-19 324/week @ 2024-02-26 272/week @ 2024-03-04 379/week @ 2024-03-11 135/week @ 2024-03-18

1,114 downloads per month
Used in 14 crates (4 directly)

Apache-2.0

18KB
330 lines

Casper Event Standard

The Casper Event Standard is a Rust library that provides a simple and standardized way for smart contracts on the Casper Network to emit events. Events are an important tool for decentralized applications, as they allow contracts to communicate with external services in a transparent and decentralized way.

With the Casper Event Standard, developers can easily define custom event types and register them in the contract. The library provides a convenient API for emitting events. This makes it easy to build complex applications that rely on event-driven architecture.

Whether you're building a decentralized exchange, a prediction market, or any other type of blockchain application, the Casper Event Standard is an essential tool for creating reliable and scalable smart contracts. So why wait? Start using the Casper Event Standard today and take your decentralized application to the next level!

Usage

use casper_event_standard::Event;

// Turn a struct into an event.
#[derive(Event)]
struct Transfer {
    amount: U256,
    from: Key,
    to: Key
}

// Register event schemas.
fn init_events() {
    let schemas = Schemas::new()
        .with::<Transfer>();
    casper_event_standard::init(schemas);
}

// Emit event.
fn emit_transfer(transfer: Transfer) {
    casper_event_standard::emit(transfer);
}

Tests

To test the code run:

$ just test

Dependencies

~7MB
~146K SLoC