コード例 #1
0
def get_ont_balance():
    preExec = True
    params = dict()

    abiFunction = Invoke.get_function(params, 'get_sin_balance', abi_info)
    responce = SdkUtils.SendTransaction(contract_address, payer, payer, gas_limit, gas_price, abiFunction, preExec)
    return parse_neo_vm_contract_return_type_integer(responce)
コード例 #2
0
 def test_random_num(self):
     func = abi_info.get_function('random_int_from_zero')
     func.set_params_value((10, seed))
     # for i in range(100):
     res = sdk.neo_vm().send_transaction(contract_addr, acc1, acc1,
                                         200000000, 500, func, True)
     print(util.parse_neo_vm_contract_return_type_integer(res))
コード例 #3
0
def get_integer_from_hex(res):
    """
    hex to integer
    :param res:
    :return:
    """
    return util.parse_neo_vm_contract_return_type_integer(res)
コード例 #4
0
def Balance(address):
    params = dict()
    params["address"] = address
    abiFunction = Invoke.get_function(params, 'balanceOf', abiInfo)
    return parse_neo_vm_contract_return_type_integer(
        SdkUtils.SendTransaction(ContractAddress(), owner, ownerAccount,
                                 abiFunction))
コード例 #5
0
def get_refund_timelock(hashlock):
    preExec = True
    params = dict()
    params["order_id"] = "Hex:" + hashlock.hex()

    abiFunction = Invoke.get_function(params, 'get_refund_timelock', abi_info)
    responce = SdkUtils.SendTransaction(contract_address, payer, payer, gas_limit, gas_price, abiFunction, preExec)
    return parse_neo_vm_contract_return_type_integer(responce)
コード例 #6
0
 def test_balance_of(self):
     func = abi_info.get_function('balance_of')
     func.set_params_value(acc1.get_address().to_byte_array())
     res = sdk.neo_vm().send_transaction(contract_addr, acc1, acc1, 200000,
                                         500, func, True)
     if res == '':
         print('nothing')
     else:
         print(util.parse_neo_vm_contract_return_type_integer(res))
コード例 #7
0
def Syncwd():
    sdk.set_rpc(rpc_address)
    blockheight = sdk.rpc.get_block_count()
    lastheight = blockheight

    while 1:
        while (lastheight > blockheight):
            blockheight = sdk.rpc.get_block_count()
            #time.sleep(5)

        while (lastheight <= blockheight):
            print(lastheight)
            #lastheight = 562237
            event = sdk.rpc.get_smart_contract_event_by_height(lastheight - 1)
            lastheight += 1
            print(event)
            if event == None:
                continue
            for item in event:
                for state in item['Notify']:
                    if state[
                            'ContractAddress'] == '55c494d57ac7cbaad565b5e19ea757dcfe315e29':
                        print(state)
                        if (state['States'][0] != '6775657373'):
                            continue
                        tokentype = state['States'][1]
                        address = state['States'][2]
                        amount = state['States'][3]
                        gameid = state['States'][4]
                        usernumber = state['States'][5]
                        sysnumber = state['States'][6]

                        tokentype = int(tokentype, 16)
                        address = Address((binascii.a2b_hex(
                            '64f75b59554a2008bcc1a87a7ae09249abc74a91')
                                           )).b58encode()
                        amount = util.parse_neo_vm_contract_return_type_integer(
                            amount)
                        usernumber = int(usernumber, 16)
                        sysnumber = int(sysnumber, 16)
                        gameid = int(gameid, 16)
                        print(state['States'])
                        SaveResult(address, tokentype, amount, gameid,
                                   usernumber, sysnumber)
コード例 #8
0
 def print_info(self, res):
     """
     print notify info
     :param res: json
     :return:
     """
     now = time.time()
     json_res = sdk.get_rpc().get_smart_contract_event_by_tx_hash(res)
     while json_res is None:
         json_res = sdk.get_rpc().get_smart_contract_event_by_tx_hash(res)
         time.sleep(0.1)
     print('checking tx cost %.2fs' % (time.time() - now))
     print(json_res)
     print('txid: %s' % res)
     try:
         print('action:%s\nfrom_account:%s\nto_account:%s\namount:%s' %
               (self.get_from_hex(json_res['Notify'][0]['States'][0]),
                json_res['Notify'][0]['States'][1],
                json_res['Notify'][0]['States'][2],
                util.parse_neo_vm_contract_return_type_integer(
                    json_res['Notify'][0]['States'][3])))
     except Exception:
         print('wrong notify')
コード例 #9
0
 def test_total_supply(self):
     func = abi_info.get_function('total_supply')
     func.set_params_value('a')
     res = sdk.neo_vm().send_transaction(contract_addr, acc1, acc1, 200000,
                                         500, func, True)
     print(util.parse_neo_vm_contract_return_type_integer(res))