本文整理汇总了Python中boa.interop.Neo.Storage.GetContext方法的典型用法代码示例。如果您正苦于以下问题:Python Storage.GetContext方法的具体用法?Python Storage.GetContext怎么用?Python Storage.GetContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boa.interop.Neo.Storage
的用法示例。
在下文中一共展示了Storage.GetContext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_append_1
# 需要导入模块: from boa.interop.Neo import Storage [as 别名]
# 或者: from boa.interop.Neo.Storage import GetContext [as 别名]
def do_append_1():
"""
Add 1 item into the list in storage.
:return: indication success execution of the command
:rtype: bool
"""
context = GetContext()
list_bytes = Get(context, KEY)
item_list = deserialize_bytearray(list_bytes)
item_list.append('single item')
list_length = len(item_list)
Log('new list length:')
Log(list_length)
list_bytes = serialize_array(item_list)
Put(context, KEY, list_bytes)
return True
示例2: TotalSupply
# 需要导入模块: from boa.interop.Neo import Storage [as 别名]
# 或者: from boa.interop.Neo.Storage import GetContext [as 别名]
def TotalSupply():
"""
Method to return the total amount of NEP5 tokens in current circluation
:return: the total number of tokens in circulation
:rtype: int
"""
print("total supply!")
context = GetContext()
res = Get(context, "totalSupply")
print("got total supply")
Notify(res)
return res
示例3: BalanceOf
# 需要导入模块: from boa.interop.Neo import Storage [as 别名]
# 或者: from boa.interop.Neo.Storage import GetContext [as 别名]
def BalanceOf(account):
"""
Method to return the current balance of an address
:param account: the account address to retrieve the balance for
:type account: bytearray
:return: the current balance of an address
:rtype: int
"""
print("getting balance of...")
context = GetContext()
print("getting context...")
balance = Get(context, account)
print("got balance...")
return balance
示例4: RegisterDomain
# 需要导入模块: from boa.interop.Neo import Storage [as 别名]
# 或者: from boa.interop.Neo.Storage import GetContext [as 别名]
def RegisterDomain(domain_name, owner):
msg = concat("RegisterDomain: ", domain_name)
Notify(msg)
if not CheckWitness(owner):
Notify("Owner argument is not the same as the sender")
return False
context = GetContext()
exists = Get(context, domain_name)
if exists:
Notify("Domain is already registered")
return False
Put(context, domain_name, owner)
return True
示例5: TransferDomain
# 需要导入模块: from boa.interop.Neo import Storage [as 别名]
# 或者: from boa.interop.Neo.Storage import GetContext [as 别名]
def TransferDomain(domain_name, to_address):
msg = concat("TransferDomain: ", domain_name)
Notify(msg)
context = GetContext()
owner = Get(context, domain_name)
if not owner:
Notify("Domain is not yet registered")
return False
if not CheckWitness(owner):
Notify("Sender is not the owner, cannot transfer")
return False
if not len(to_address) != 34:
Notify("Invalid new owner address. Must be exactly 34 characters")
return False
Put(context, domain_name, to_address)
return True
示例6: DeleteDomain
# 需要导入模块: from boa.interop.Neo import Storage [as 别名]
# 或者: from boa.interop.Neo.Storage import GetContext [as 别名]
def DeleteDomain(domain_name):
msg = concat("DeleteDomain: ", domain_name)
Notify(msg)
context = GetContext()
owner = Get(context, domain_name)
if not owner:
Notify("Domain is not yet registered")
return False
if not CheckWitness(owner):
Notify("Sender is not the owner, cannot transfer")
return False
Delete(context, domain_name)
return True
示例7: Main
# 需要导入模块: from boa.interop.Neo import Storage [as 别名]
# 或者: from boa.interop.Neo.Storage import GetContext [as 别名]
def Main():
context = GetContext()
# This is the storage key we use in this example
item_key = 'test-storage-key'
# Try to get a value for this key from storage
item_value = Get(context, item_key)
msg = ["Value read from storage:", item_value]
Notify(msg)
if len(item_value) == 0:
Notify("Storage key not yet set. Setting to 1")
item_value = 1
else:
Notify("Storage key already set. Incrementing by 1")
item_value += 1
# Store the new value
Put(context, item_key, item_value)
msg = ["New value written into storage:", item_value]
Notify(msg)
return item_value
示例8: RegisterFarmer
# 需要导入模块: from boa.interop.Neo import Storage [as 别名]
# 或者: from boa.interop.Neo.Storage import GetContext [as 别名]
def RegisterFarmer(Farmer_name, owner):
msg = concat("RegisterFarmer: ", Farmer_name)
Notify(msg)
if not CheckWitness(owner):
Notify("Owner argument is not the same as the person who registered the farmer")
return False
context = GetContext()
exists = Get(context, Farmer_name)
if exists:
Notify("Farmer is already registered")
return False
Put(context, Farmer_name, owner)
return True
示例9: DeleteFarmer
# 需要导入模块: from boa.interop.Neo import Storage [as 别名]
# 或者: from boa.interop.Neo.Storage import GetContext [as 别名]
def DeleteFarmer(Farmer_name):
msg = concat("DeleteFarmer: ", Farmer_name)
Notify(msg)
context = GetContext()
owner = Get(context, Farmer_name)
if not owner:
Notify("Farmer is not yet registered")
return False
if not CheckWitness(owner):
Notify("This person is not the owner of the farmer registry, the farmer cannot be deleted")
return False
Delete(context, Farmer_name)
return True
## STAGE TWO : FARM REGISTRATION : PYTHON CODE COMPLETE
## THIS CODE IS TO REGISTER FARM OWNERSHIP ON THE BLOCKCHAIN WITH ABILITY TO ADD/DELETE/QUERY/TRANSFER OWNERSHIP
示例10: RegisterFarm
# 需要导入模块: from boa.interop.Neo import Storage [as 别名]
# 或者: from boa.interop.Neo.Storage import GetContext [as 别名]
def RegisterFarm(Farm_name, owner):
msg = concat("RegisterFarm: ", Farm_name)
Notify(msg)
if not CheckWitness(owner):
Notify("Owner argument is not the same as the person who registered")
return False
context = GetContext()
exists = Get(context, Farm_name)
if exists:
Notify("Farm is already registered")
return False
Put(context, Farm_name, owner)
return True
示例11: DeleteFarm
# 需要导入模块: from boa.interop.Neo import Storage [as 别名]
# 或者: from boa.interop.Neo.Storage import GetContext [as 别名]
def DeleteFarm(Farm_name):
msg = concat("DeleteFarm: ", Farm_name)
Notify(msg)
context = GetContext()
owner = Get(context, Farm_name)
if not owner:
Notify("Farm is not yet registered")
return False
if not CheckWitness(owner):
Notify("This person is not the owner of the farm, the farm cannot be deleted")
return False
Delete(context, Farm_name)
return True
## STAGE THREE : FARM PROJECT REGISTRATION : PYTHON CODE COMPLETE
## THIS CODE IS TO REGISTER FARM PROJECT GIVEN THE FARMER IS ALSO ON THE BLOCKCHAIN AND THEIR FARM IS ALSO REGISTERED
## ON THE BLOCKCHAIN WITH ABILITY TO ADD/DELETE/QUERY/TRANSFER OF PROJECT OWNERSHIP
示例12: RegisterFarmProject
# 需要导入模块: from boa.interop.Neo import Storage [as 别名]
# 或者: from boa.interop.Neo.Storage import GetContext [as 别名]
def RegisterFarmProject(FarmProject_name, owner):
msg = concat("RegisterFarmProject: ", FarmProject_name)
Notify(msg)
if not CheckWitness(owner):
Notify("Owner argument is not the same as the person who registered")
return False
context = GetContext()
exists = Get(context, FarmProject_name)
if exists:
Notify("Farm Project is already registered")
return False
Put(context, FarmProject_name, owner)
return True
示例13: TransferFarmProject
# 需要导入模块: from boa.interop.Neo import Storage [as 别名]
# 或者: from boa.interop.Neo.Storage import GetContext [as 别名]
def TransferFarmProject(FarmProject_name, to_address):
msg = concat("TransferFarmProject: ", FarmProject_name)
Notify(msg)
context = GetContext()
owner = Get(context, FarmProject_name)
if not owner:
Notify("Farm Project is not yet registered")
return False
if not CheckWitness(owner):
Notify("This person is not the owner, farm project ownership cannot transfer")
return False
if not len(to_address) != 34:
Notify("Invalid new owner neo address. Must be exactly 34 characters")
return False
Put(context, FarmProject_name, to_address)
return True
示例14: DeleteFarmProject
# 需要导入模块: from boa.interop.Neo import Storage [as 别名]
# 或者: from boa.interop.Neo.Storage import GetContext [as 别名]
def DeleteFarmProject(FarmProject_name):
msg = concat("DeleteFarmProject: ", FarmProject_name)
Notify(msg)
context = GetContext()
owner = Get(context, FarmProject_name)
if not owner:
Notify("Farm Project is not yet registered")
return False
if not CheckWitness(owner):
Notify("This person is not the owner of the farm project, the farm project cannot be deleted")
return False
Delete(context, FarmProject_name)
return True
## STAGE FOUR : Buyer REGISTRATION : PYTHON CODE COMPLETE
## THIS CODE IS TO REGISTER A DIRECT Buyer ON THE BLOCKCHAIN WITH ABILITY TO ADD/DELETE/QUERY
示例15: RegisterBuyer
# 需要导入模块: from boa.interop.Neo import Storage [as 别名]
# 或者: from boa.interop.Neo.Storage import GetContext [as 别名]
def RegisterBuyer(Buyer_name, owner):
msg = concat("RegisterBuyer: ", Buyer_name)
Notify(msg)
if not CheckWitness(owner):
Notify("Owner argument is not the same as the person who registered")
return False
context = GetContext()
exists = Get(context, Buyer_name)
if exists:
Notify("Buyer is already registered")
return False
Put(context, Buyer_name, owner)
return True