当前位置: 首页>>代码示例>>Python>>正文


Python builtins.concat方法代码示例

本文整理汇总了Python中boa.builtins.concat方法的典型用法代码示例。如果您正苦于以下问题:Python builtins.concat方法的具体用法?Python builtins.concat怎么用?Python builtins.concat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在boa.builtins的用法示例。


在下文中一共展示了builtins.concat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: serialize_array

# 需要导入模块: from boa import builtins [as 别名]
# 或者: from boa.builtins import concat [as 别名]
def serialize_array(items):

    # serialize the length of the list
    itemlength = serialize_var_length_item(items)

    output = itemlength

    # now go through and append all your stuff
    for item in items:

        # get the variable length of the item
        # to be serialized
        itemlen = serialize_var_length_item(item)

        # add that indicator
        output = concat(output, itemlen)

        # now add the item
        output = concat(output, item)

    # return the stuff
    return output 
开发者ID:CityOfZion,项目名称:neo-boa,代码行数:24,代码来源:LargeArrayStorageTest.py

示例2: serialize_var_length_item

# 需要导入模块: from boa import builtins [as 别名]
# 或者: from boa.builtins import concat [as 别名]
def serialize_var_length_item(item):

    # get the length of your stuff
    stuff_len = len(item)

    # now we need to know how many bytes the length of the array
    # will take to store

    # this is one byte
    if stuff_len <= 255:
        byte_len = b'\x01'
    # two byte
    elif stuff_len <= 65535:
        byte_len = b'\x02'
    # hopefully 4 byte
    else:
        byte_len = b'\x04'

    out = concat(byte_len, stuff_len)

    return out 
开发者ID:CityOfZion,项目名称:neo-boa,代码行数:23,代码来源:LargeArrayStorageTest.py

示例3: kyc_register

# 需要导入模块: from boa import builtins [as 别名]
# 或者: from boa.builtins import concat [as 别名]
def kyc_register(ctx, args):
    """

    :param args:list a list of addresses to register
    :param token:Token A token object with your ICO settings
    :return:
        int: The number of addresses to register for KYC
    """
    ok_count = 0

    if CheckWitness(TOKEN_OWNER):

        for address in args:

            if len(address) == 20:

                kyc_storage_key = concat(KYC_KEY, address)
                Put(ctx, kyc_storage_key, True)

                OnKYCRegister(address)
                ok_count += 1

    return ok_count 
开发者ID:CityOfZion,项目名称:neo-boa,代码行数:25,代码来源:crowdsale.py

示例4: kyc_status

# 需要导入模块: from boa import builtins [as 别名]
# 或者: from boa.builtins import concat [as 别名]
def kyc_status(ctx, args):
    """
    Gets the KYC Status of an address

    :param args:list a list of arguments
    :return:
        bool: Returns the kyc status of an address
    """

    if len(args) > 0:
        addr = args[0]

        kyc_storage_key = concat(KYC_KEY, addr)

        return Get(ctx, kyc_storage_key)

    return False 
开发者ID:CityOfZion,项目名称:neo-boa,代码行数:19,代码来源:crowdsale.py

示例5: Main

# 需要导入模块: from boa import builtins [as 别名]
# 或者: from boa.builtins import concat [as 别名]
def Main(ba1, ba2):

    m = ba2[1:2]  # but you can do this instead

    # strings and byte arrays work the same
    mystr = 'staoheustnau'

    # this will not work
    # m = mystr[3]

    # but this will
    m = mystr[3:5]

    #
    m = ba1[1:len(ba1)]

    return concat(m, concat(mystr, ba2)) 
开发者ID:CityOfZion,项目名称:neo-boa,代码行数:19,代码来源:ByteArrayTest2.py

示例6: Main

# 需要导入模块: from boa import builtins [as 别名]
# 或者: from boa.builtins import concat [as 别名]
def Main():

    items = [0, 1, 2]

    items2 = ['a', 'b', 'c', 'd']
    count = 0

    blah = b''

    for i in items:

        for j in items2:

            blah = concat(blah, j)

            count += 1

    blah = concat(blah, count)

    return blah 
开发者ID:CityOfZion,项目名称:neo-boa,代码行数:22,代码来源:IterTest4.py

示例7: RegisterDomain

# 需要导入模块: from boa import builtins [as 别名]
# 或者: from boa.builtins import concat [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 
开发者ID:CityOfZion,项目名称:python-smart-contract-workshop,代码行数:18,代码来源:4-domain.py

示例8: TransferDomain

# 需要导入模块: from boa import builtins [as 别名]
# 或者: from boa.builtins import concat [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 
开发者ID:CityOfZion,项目名称:python-smart-contract-workshop,代码行数:22,代码来源:4-domain.py

示例9: DeleteDomain

# 需要导入模块: from boa import builtins [as 别名]
# 或者: from boa.builtins import concat [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 
开发者ID:CityOfZion,项目名称:python-smart-contract-workshop,代码行数:18,代码来源:4-domain.py

示例10: init

# 需要导入模块: from boa import builtins [as 别名]
# 或者: from boa.builtins import concat [as 别名]
def init():
    """
    initialize the contract, put some important info into the storage in the blockchain
    :return:
    """
    if len(OWNER) != 20:
        Notify(["Owner illegal!"])
        return False
    if Get(ctx,SUPPLY_KEY):
        Notify("Already initialized!")
        return False
    else:
        total = TOTAL_AMOUNT * FACTOR
        Put(ctx,SUPPLY_KEY,total)
        Put(ctx,concat(BALANCE_PREFIX,OWNER),total)

        # Notify(["transfer", "", Base58ToAddress(OWNER), total])
        # ownerBase58 = AddressToBase58(OWNER)
        TransferEvent("", OWNER, total)

        return True 
开发者ID:ONT-Avocados,项目名称:python-template,代码行数:23,代码来源:OEP4Sample.py

示例11: RegisterFarmer

# 需要导入模块: from boa import builtins [as 别名]
# 或者: from boa.builtins import concat [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 
开发者ID:BitMari,项目名称:varimi,代码行数:18,代码来源:smartFarmContracts.py

示例12: DeleteFarmer

# 需要导入模块: from boa import builtins [as 别名]
# 或者: from boa.builtins import concat [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 
开发者ID:BitMari,项目名称:varimi,代码行数:22,代码来源:smartFarmContracts.py

示例13: RegisterFarm

# 需要导入模块: from boa import builtins [as 别名]
# 或者: from boa.builtins import concat [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 
开发者ID:BitMari,项目名称:varimi,代码行数:18,代码来源:smartFarmContracts.py

示例14: DeleteFarm

# 需要导入模块: from boa import builtins [as 别名]
# 或者: from boa.builtins import concat [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 
开发者ID:BitMari,项目名称:varimi,代码行数:22,代码来源:smartFarmContracts.py

示例15: RegisterFarmProject

# 需要导入模块: from boa import builtins [as 别名]
# 或者: from boa.builtins import concat [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 
开发者ID:BitMari,项目名称:varimi,代码行数:18,代码来源:smartFarmContracts.py


注:本文中的boa.builtins.concat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。