TechiRik
TechiRik

Reputation: 2143

How do smart contracts relate to blockchains

I am very new to blockchains. I am trying to figure out how I can use blockchain in my particular scenario, while trying to learn about it and have some very basic questions.

Business Scenario B purchases product P from A. A charges $x for each unit of P delivered under condition C1 and $y for each unit of P delivered under condition C2. B pays A at the end of a billing cycle.

Questions

  1. "The delivery of P by A to B" - can this be considered as a transaction?
  2. My smart contract will probably be defined as "If C1 then rate=$x". A or B can deliver the event ("delivery of P by A to B") to the smart contract to check the condition and determine the action. Will that "event" be equivalent of a block in this case? What will be stored in the blockchain?
  3. How will this "block" be validated? In this case, the event will have parameters to check the condition, but since the event is being submitted by either A or B (untrusted parties), how can a miner validate that the event parameters have not be tampered with?
  4. If A needs to generate an end of billing cycle invoice, should A be reading it from the blockchain? (To showcase the data has not been tampered with)

Thanks in advance.

Regards, Ritwik

Upvotes: 0

Views: 88

Answers (1)

arun_munagala
arun_munagala

Reputation: 65

There are a lot of things to be considered before designing a Smart contract. I will try to explain it with minimum technicality.

Your Smart contract scenario:
deliver product P from A to B under 2 conditions.
So your Smart contract will have 2 addresses i.e. of A and B. Upon delivery of P by A to B, there will be method(verify) that B and A can verify(using some protocol where 2 parties agree upon a decision and only when both say yes it is true or false) that a certain condition is met i.e. either C1 or C2.
When that condition is met that payment is done (either $x or $y)

  1. If upon delivery of P from A to B both will try to invoke the method verify and agree upon the condition. This invocation of methods will be transactions.

  2. Delivery of "event" will be the invocation of the method in this scenario. Like i said before these invocations are transactions which are stored on the blockchain. These transactions will have information about which method was invoked with what arguements and the timestamp. These transactions will be present with other transactions on that particular block which is mined.

  3. When defining your conditions in a method. You will have conditions on who can call those methods. The miner will only run the code irrespective if the code returns an error or not. So if verify method is invoked by someone who is not suppose to, your code should return an error(this is your responsibility on how you code your smart contract). The miner only runs the code and returns whatever your code will output.

  4. Yes blockchain history cannot be tampered with and hence can be used as proof.

Upvotes: 1

Related Questions