1

if the smart contract has terms to be met in a time order(assuming in one year time frame) and transactions corresponding to the terms, what will happen to the variables stored in the contract account when two different user accounts initiate the smart contract one after another and are being mined by the same miner? For example, the smart contract is about paying money at different stages of constructing an apartment building, and is used between a construction company and different apartment buyers.

closed as unclear what you're asking by smarx, Achala Dissanayake, Ismael, shane, Paul S Mar 13 at 17:57

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

1

Transactions are executed sequentially. Let's suppose we have two transaction T1 and T2 that call to contract C.

During T1 execution it can modify the state of C. When T2 start it will see the modified state.

If you only want the first transaction to succeed, the contract have to provide that logic for that. For example C set a variable to at creation to false, when a transaction is executed it check the variable if false continue, and if is true it will fail, on success it will set the variable to true.

  • How the Contract will handle a situation like this that if after some time, the sender of T1 (assuming paying a first construction stage fee) sends a T3(paying a second stage fee) which needs to start execution of the code with the state recorded after T1 and before T2. I hope i specify my question clear. My concern is about how the contract can pick up the last contract state that the sender of T1 left without picking up the state that other senders left. – Tuhc Tu Mar 9 at 6:11
  • The contract has to provide the logic to realize that. Like having an authorization system that only allows T1 sender to send new transactions. Any other invalid transaction will revert(), keeping the state unmodified. – Ismael Mar 9 at 17:24

Not the answer you're looking for? Browse other questions tagged or ask your own question.