Crates.io | casper_event |
lib.rs | casper_event |
version | 0.1.0 |
source | src |
created_at | 2021-10-15 15:41:25.602353 |
updated_at | 2021-10-15 15:41:25.602353 |
description | Library for developing Casper smart contracts with event. |
homepage | https://casper.network |
repository | https://github.com/Murasame233/casper-event |
max_upload_size | |
id | 465550 |
size | 9,732 |
this project is a lib that makes developer can easily use event on their smart contract.
#[no_mangle]
fn call(){
...
let mut entry = EntryPoints::new();
if let (entry_set: EntryPoint,entry_unset: EntryPoint) = get_set_event_entry(){
entry.add_entry_point(entry_set);
entry.add_entry_point(entry_unset);
}
let mut named_keys = NamedKeys::new();
named_keys.append(&mut get_set_event_named_keys())
new_contract(entry, named_keys, _, _);
...
}
// when you have a event to evoke
...
send_event("event_name".into(),Some(target),Some(target_entry),runtime_args!{})
...
// You need a entry to handle the event
#[no_mangle]
fn handler(){
...
}
// set event callback
...
set_event_callback("handler".into(),contract_hash,callback_entry,target_hash);
...