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)
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
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)
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)
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)
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)
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
def getcarlist(): carrent = Car_Contract(contract_address) car_msg = carrent.get_car_list() return jsonify(car_msg), 200
def getcar(chainnumber): carrent = Car_Contract(contract_address) car_msg = carrent.get_car_by_chainnumber(chainnumber) return jsonify(car_msg), 200
def is_carowner(address): carrent = Car_Contract(contract_address) iscarowner = carrent.is_carowner(address) return jsonify(iscarowner), 200
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