Let's say we have a contract with functions for an online store built on top of the Ethereum blockchain. Whenever a transaction between buyer and seller happens, are new instances of that contract created for each transaction or are all transactions using the same contract?
2 Answers
You write the code, so you get to decide this. What you choose will depend on your requirements, but there's certainly no reason you have to use multiple contracts if you don't want to.
In your example, all transactions would use the same single instance of a contract. If you had multiple stores, you might consider having each store be a separate contract instance.
-
And what if the value sent by the buyer is not directly transferred to the seller, maybe separately stored on the contract until the buyer receives the product he bought and the event of the buyer receiving the product in turn triggers the value stored in the contract being transferred to the seller? Commented Mar 4, 2018 at 21:09
-
Sounds like your question is about different contract designs. The scenario you describe could be done with one or multiple contracts. From a gas cost perspective, it would typically use more gas to instantiate a new contract per transaction.– eth ♦Commented Mar 11, 2018 at 9:36