當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。