Example #1
0
def tokenURI():
    data = request.get_json()
    tokenid = data["tokenid"]
    carrent = Car_Contract(contract_address)
    iscarowner = carrent.tokenURI(int(tokenid))
    send_data = json.dumps({'tokenURI':iscarowner[0]})
    return make_response(send_data, 200)
Example #2
0
def add_user_by_amount():
    data = request.get_json()
    if data is None:
        return jsonify({"error": "Pleace input [address] by string."}), 400
    address = data["address"]
    carrent = Car_Contract(contract_address)
    carrent.client.set_account_by_privkey(admin_privkey)
    new_user = carrent.add_user_by_amount(address)
    return jsonify(new_user), 200
Example #3
0
def tokenOfOwnerByIndex():
    data = request.get_json()
    addr = fix_addr(data["addr"])
    index = data["index"]
    addr = Web3.toChecksumAddress(addr)
    con = Car_Contract(contract_address)
    data = con.tokenOfOwnerByIndex(addr,index)
    send_data = json.dumps({'result':data})
    return make_response(send_data, 200)
Example #4
0
def transferTo():
    data = request.get_json()
    addr = fix_addr(data["addr"])
    tokenid = data["tokenid"]
    addr = Web3.toChecksumAddress(addr)
    con = Car_Contract(contract_address)
    data = con.transferTo(addr,tokenid)
    send_data = json.dumps({'result':data})
    return make_response(send_data, 200)
Example #5
0
def balanceOf():
    data = request.get_json()
    # print(data)
    addr = fix_addr(data["addr"])
    # print(addr)
    addr = Web3.toChecksumAddress(addr)
    con = Car_Contract(contract_address)
    data = con.balanceOf(addr)
    send_data = json.dumps({'balance':data})
    return make_response(send_data, 200)
Example #6
0
def ownerOf():
    data = request.get_json()
    tokenid = data["tokenid"]
    # index = data["index"]
    # addr = Web3.toChecksumAddress(addr)
    con = Car_Contract(contract_address)
    data = con.ownerOf(tokenid)

    # did:weid:3:0xbf29d133d0b45b2db1f89394813e5a384088ce40
    send_data = json.dumps({'who':"did:weid:3:"+data[0]})
    return make_response(send_data, 200)
Example #7
0
def new_vehicle(carowner_privkey):
    data = request.get_json()
    if data is None:
        return jsonify({"error": "Pleace input [chainNumber, number, brand, color, quality, price, day]s."}), 400
    chainNumber = int(data["chainNumber"])
    number = data["number"]
    brand = data["brand"]
    color = data["color"]
    quality = data["quality"]
    price = int(data["price"])
    day = int(data["day"])

    carrent = Car_Contract(contract_address)
    carrent.client.set_account_by_privkey(carowner_privkey)
    newvehicle = carrent.new_vehicle(chainNumber, number, brand, color, quality, price, day)
    return jsonify(newvehicle), 200
Example #8
0
def getcarlist():
    carrent = Car_Contract(contract_address)
    car_msg = carrent.get_car_list()
    return jsonify(car_msg), 200
Example #9
0
def getcar(chainnumber):
    carrent = Car_Contract(contract_address)
    car_msg = carrent.get_car_by_chainnumber(chainnumber)
    return jsonify(car_msg), 200
Example #10
0
def is_carowner(address):
    carrent = Car_Contract(contract_address)
    iscarowner = carrent.is_carowner(address)
    return jsonify(iscarowner), 200
Example #11
0
def reback_vehicle(user_privkey, chainNumber):
    carrent = Car_Contract(contract_address)
    carrent.client.set_account_by_privkey(user_privkey)
    reback_msg = carrent.reback_vehicle(chainNumber)
    return jsonify(reback_msg), 200