Expand description
The smart contract level events for Casper.
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);
}
Structs§
- CLType2
- A wrapper on top of
CLType
. - Schema
- The information about a single event.
- Schemas
- The information about multiple events.
Constants§
- CES_
VERSION - The version of CES implemented in this library.
- CES_
VERSION_ KEY - The key under which the ces version is stored.
- EVENTS_
DICT - The key under which the events are stored.
- EVENTS_
LENGTH - The key under which the events length is stored.
- EVENTS_
SCHEMA - The key under which the event schemas are stored.
Traits§
- Event
Instance - Helper trait, used for the schema generation.
Functions§
- emit
- Emits an event.
- emit_
bytes - Emits an event. Don’t convert to bytes.
- init
- Initializes events-releated named keys and stores
Schemas
. - try_
full_ name_ from_ bytes - Extracts full name of the event including
event_
prefix. - validate_
type - Make sure the type of a value is not
CLType::Any
.
Derive Macros§
- Event
- Macro that derives
CLTyped
,FromBytes
,ToBytes
andEventInstance
.