Move语言社区

【Move进阶】HelloWorld

address 0x2 {
module HelloWorld {
    use 0x1::Signer;
    use 0x1::Event;

    struct AnyWordEvent has store, drop {
        words: vector<u8>,
    }

    struct EventHolder has key {
        any_word_events: Event::EventHandle<AnyWordEvent>,
    }

    public(script) fun hello_world(account: &signer) acquires EventHolder {
        let addr = Signer::address_of(account);
        let hello_world = x"68656c6c6f20776f726c64";//hello world
        let holder = borrow_global_mut<EventHolder>(addr);
        Event::emit_event<AnyWordEvent>(&mut holder.any_word_events, AnyWordEvent { words:hello_world });
    }
}
}