eos智能合约与主进程交互
eos智能合约与主进程交互
1.启动wasm
2.智能合约调用主进程api
如何实现wasm代码与eos宿主交互还需要摸索!
大致:在wasm_interface.cpp文件中,通过如下宏来实现wasm与宿主程序的api桥接
REGISTER_INTRINSICS(action_api,
(read_action_data, int(int, int))(action_data_size, int())(current_receiver, int64_t()));
3.整体流程
- 注册接口
REGISTER_INTRINSICS(authorization_api,
(require_recipient, void(int64_t))(require_authorization, void(int64_t), "require_auth", void (authorization_api::*)(const account_name &))(require_authorization, void(int64_t, int64_t), "require_auth2", void (authorization_api::*)(const account_name &, const permission_name &permission))(has_authorization, int(int64_t), "has_auth", bool (authorization_api::*)(const account_name &) const)(is_account, int(int64_t)));
- 接口调用
推测 智能合约代码 apply_social_vote() -> require_recipient() // 通过如上代码注入 -> authorization_api::require_recipient() -> apply_context::require_recipient()