div#pop_ad { opacity: 0; }


from ontology.interop.System.Runtime import GetTime, CheckWitness, Notify, Serialize, Deserialize
from ontology.interop.Ontology.Runtime import Base58ToAddress, AddressToBase58, GetCurrentBlockHas
from ontology.interop.System.Runtime import Notify
def demo:
Notify("hello world")

from ontology.interop.System.Runtime import GetTime
def demo:
time=GetTime
return time # 返回时间戳, 单位是秒
from ontology.interop.Ontology.Runtime import GetCurrentBlockHash
def demo:
block_hash = GetCurrentBlockHash
return block_hash
from ontology.interop.System.Runtime import Notify, Serialize, Deserializefrom ontology.interop.System.Storage import Put, Get, GetContextdef Main(operation, args): if operation == serialize_to_bytearray : data = args[0] return serialize_to_bytearray(data) if operation == deserialize_from_bytearray : key = args[0] return deserialize_from_bytearray(key) return Falsedef serialize_to_bytearray(data): sc = GetContext key = "1" byte_data = Serialize(data) # 序列化传入的参数 Put(sc, key, byte_data) # 将序列化后的数据存入区块链
def deserialize_from_bytearray(key): sc = GetContext byte_data = Get(sc, key) # 按key从区块链中取出数据 data = Deserialize(byte_data) # 将bytearray数据反序列化成原先类型数据 return data
from ontology.interop.Ontology.Runtime import Base58ToAddress, AddressToBase58
def demo:
base58_addr="AV1GLfVzw28vtK3d1kVGxv5xuWU59P6Sgn"
addr=Base58ToAddress(base58_addr) # 将 base58 地址转成 bytearray形式地址
Notify(addr)
base58_addr=AddressToBase58(addr) #将bytearray地址转为base58地址
Notify(base58_addr)
from ontology.interop.System.Runtime import CheckWitness
from ontology.interop.Ontology.Runtime import Base58ToAddress
def demo:
addr=Base58ToAddress("AW8hN1KhHE3fLDoPAwrhtjD1P7vfad3v8z")
res=CheckWitness(addr) # 验证调用者地址是否为AW8hN1KhHE3fLDoPAwrhtjD1P7vfad3v8z
return res
添加新手交流群:币种分析、每日早晚盘分析
添加助理微信,一对一亲自指导:YoYo8abc