I want to store vehicle history in the blockchain. Each historical "event" would contain the vehicle VIN
, mileage
and date
. There are a lot of vehicles and the history per vehicle is fairly small. So deploying a new contract for each vehicle seems wasteful, but storing all vehicles in one contract isn't scalable.
So I was thinking of storing the history simply in the events themselves that the "registrar" contract generates.
Something like this:
pragma solidity ^0.4.21;
contract VehRegistry {
address public owner;
event Event(string vin, string mileage, string date);
function VehRegistry() public {
owner = msg.sender;
}
function registerEvent(string vin, string mileage, string date) public {
require(msg.sender == owner);
emit Event(vin, mileage, date);
}
}
Is this a secure solution (in terms of data integrity)?
And would I be able to look up all events for a given registry address?