I've been curious about something for a while. If you wanted to create a state object to track a bunch of the same object, is it more efficient(cheaper) to create a contract for each object or one contract for all the objects?
For instance, say you wanted to keep track of the state of a piece of fruit. Is it more efficient to create a contract for each piece of fruit:
(in pseudocode)
init(id) {
self.id = id
self.is_peeled = false
}
peel() {
self.is_peeled = true
}
isPeeled() {
return self.is_peeled;
}
Or a contract that uses a lot of storage to track all of the fruit:
init() {
self.fruit = []
}
addFruit(id) {
self.fruit[id] = {
is_peeled: false
isPeeled: function() { return self.is_peeled }
}
}
getFruit(id) {
return self.fruit[id]
}
And what if it ends up being thousands of objects; does that change the efficiency?
I guess the cost of storage versus the cost of deploying a new contract isn't something I fully grasp yet.