听说Python的广告刷爆了你的朋友圈?
温馨提示:这篇文章已超过910天没有更新,请注意相关的内容是否还可用!
01 导语
02 DynamicAppCall 使用方法
from ontology.interop.System.App import DynamicAppCall
2.1 DynamicAppCall API
def Main(operation, args):
if operation == "DynamicCallContract":
if len(args) != 3:
return False
revesedContractAddress = args[0]
opt = args[1]
params = args[2]
return DynamicCallContract(revesedContractAddress, opt, params) return False def DynamicCallContract(revesedContractAddress, operation, params):
res = DynamicAppCall(revesedContractAddress, operation, [params])
Notify(["the result of the DynamicCall is: ", res])
return res def Main(operation, args):
if operation == 'Hello':
msg = args[0]
return Hello(msg) return False def Hello(msg):
return msg 1. 不用每次调用方法时,传入 B 合约的哈希反序; 2. 对于函数调用者而言,合约 B 的哈希是隐形的,可以预先在合约 A 中方便地进行设置,进而保留了动态调用的灵活性,同时也包含了 RegisterAppCall 接口传参的简洁性。from ontology.interop.System.App import DynamicAppCall
from ontology.interop.System.Runtime import Notify
from ontology.interop.System.Runtime import Notify
03 SmartX 示例
5. 点击「运行预执行」,返回68656c6c6f20776f726c64 (Hello World 十六进制字符串), 调用成功。
04 总结