eos智能合约与主进程交互

eos智能合约与主进程交互

1.启动wasm

参考eos智能合约执行流程.md

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()

posted @ 2018-12-11 22:28  Yarkin  阅读(444)  评论(0编辑  收藏  举报