我正在查看索菲亚文档(https://aeternity-sophia.readthedocs.io/en/latest/contracts/#calling-other-contracts),但是我不知道如何执行从一个索菲亚合约到另一个索菲亚合约的跨合约调用(从一个索菲亚合约调用另一个合约函数)。我是否必须创建一个接口或类似的东西?
发布于 2021-05-01 04:02:31
要从另一个合同发出合同呼叫,您需要:
使用要调用的合约(即MyRemoteContract): )的您感兴趣的入口点,
合约MyRemoteContract =入口点my_remote_entrypoint:(int) => bool入口点another_remote_entrypoint:(address,int) => bool
合同MyCallerContract =记录状态={ some_field : address,remote_contract_instance : MyRemoteContract }
上实例化
状态有状态入口点初始化( remote_contract_instance_param : MyRemoteContract):
={ remote_contract_instance = remote_contract_instance_param }
实例的
从现在起,
有状态入口点try_remote_call(值: int) =state.token.my_remote_entrypoint(值)
另外请注意,当您的远程约定使用Call.caller时要小心,因为它不是实际的地址,而是作为调用者的约定地址。
发布于 2021-05-20 12:28:46
若要调用另一个约定,可以部署第一个约定,然后将相同的参数传递到调用的方法中
https://stackoverflow.com/questions/67317548
复制相似问题