How does Ethereum use smart contracts? Can smart contracts define rules, like a regular contract
If you are interested in learning how Ethereum works, this article will show you the basics of what Ethereum is, what a smart contract is, and give you an idea of how they work. Smart contracts can be used to run or program decentralized applications that exist on the blockchain and don’t require a third-party middleman. In other words, smart contracts can help make transactions immutable by computing mathematical formulas that are hard for hackers to manipulate.
For smart contracts to function smoothly and be fair for all users involved with them, there would need to be some rules put in place by the system so no one makes any accidental mistakes when entering data into their programs. Smart contracts can be written using the LLLL or LLLL+S syntax. The latter is intended to represent more complex formulas and conditions than the former. Here are examples of some common rules that would need to be programmed into a contract:
Contract A — Contract B — Start Date
Start Date: [Date] Ends Date: [Date]
The start date is a specific date that states it begins the contract’s existence.
The end date is when the contract will cease to exist. Allowed actions on or after that date only make sense if they involve this contract surviving past the end date.
Contract A — Contract B — Action
Action: [Actions] Can take: [List of Actions] Can’t take: [List of Actions]
The contract’s instructions are not limited to just the basic ones listed. The possible actions that can be performed are many, so long as they do not contradict the contract’s limitations. The list of actions and what they can be used for should probably not list killing people or stealing money, since the contract could be used to implement those intentions. This would pretty much fail on its own without being programmed by someone else with malicious intent.
Contract A — Action — Contract B — Action
Action 1: [Actions] Action 2: [Actions]
These are some additional actions that this contract cannot perform without dependent conditions. If a dependent condition is met, then the corresponding action can be performed. For example, one action might change the owner of this contract, and another could spend money from it.
We will discuss more advanced examples soon.
Contract A — Contract B — Condition — Action
Condition 1: [Conditions] Action 1: [Actions] Condition 2: [Conditions] Action 2: [Actions]
The contract has multiple conditions that must be met if the corresponding actions are to happen. For example, the owner of this contract could change under some conditions, and the contract could be spent under different conditions. The first condition must be met before the second condition can trigger. If both conditions are met, then an action can be performed.
The ideas above can all be used alone or in combination to create more flexible transactions on the Ethereum blockchain. We will go over each one individually to see how they would work with one another.
Now that you know what a smart contract is and how it works, you should have a basic understanding of Ethereum’s technology for its use cases in real-life situations. If you want to learn more about the technology behind Ethereum, feel free to do so by reading my other posts about it. Specifically, you should learn how Ethereum mining works before attempting to mine for yourself. I also would recommend checking out my blog post about how Smart Contracts work. I hope this article has helped help you understand how Ethereum uses smart contracts and can help you in your projects. Thanks for reading! Stay tuned for more writings about Ethereum.