Creating a Blockchain Transaction
Because blockchain is a trustless database solution, it does not have any middlemen when it comes to creating or processing transactions. All transactions are meant to be directly peer-to-peer and without any middlemen. For simple networks such as Bitcoin, the transaction model is straightforward: a user enters the wallet address of another user and sends them Bitcoin directly. There are no intermediaries, solely two wallets exchanging a given amount of currency.
For a basic networks, this is the only way to execute transactions. However, more advanced networks such as Ethereum can execute far more complex transactions on top of peer-to-peer money transfers. This includes actions such as:
- Storing data on-chain
- Communication and messaging
- Borrowing and lending
…and much more. They can do this through special programs known as smart contracts.
Smart contracts are self-executing programs saved directly on the blockchain network that allow a user to create custom transactions. They have the terms of an agreement written directly into the code, which lets these contracts execute as soon as the terms are met and without any third party. These terms can range from a service to data storage to communication.
The opportunity for smart contracts is only limited by their complexity, as more compute-heavy contracts will cost more to execute.
Source: ChatGPT
Anyone can create and deploy their own smart contract onto a blockchain network. All a developer would have to do is write up a smart contract using a language such as Solidity, and they would be able to directly deploy it onto the network for a small deployment fee. It is then stored directly on the blockchain and can be viewed by anyone. Many popular blockchain networks also contain testnets, or mock networks that operate exactly the same way as the real network does, but without real money. Developers can utilize these testnets to test out their contracts to ensure they are working correctly before deployment onto the real network.
💡 Differences in smart contract complexity
Contract #1 is a simple escrow contract, where all that it does is take in money from a payer, store it until the the listed conditions of the contract are met, and then releases the money to the payee.
Contract #2 is designed in a way where the payer deposits money into it, but then multiple parties get to vote on a proposal of who gets the money, and then whichever party wins will be the payee.
The second contract will require much more computing power to process than the first one because it has an additional layer of complexity built into it. Because of the increased computing power required to execute it, the contract will have a higher deployment cost onto the network.
Once a smart contract is deployed, users can interact with it either directly by referencing the hash that identifies the contract, or through a user interface such as a website. Most developers prefer the latter, where they are able to build out good looking and functional websites and applications that directly integrate the smart contract.
Smart contracts allow blockchain networks to operate like no other centralized network can because of the built in automation:
- With no middlemen to take a percentage of each transaction processed, using blockchain to settle payments becomes much cheaper than using other monetary transfer systems, making it an ideal system
- With no controlling authority owning smart contracts, all data is secured and encrypted in a way that only those with explicit permission given in the terms of the contract can access it
- With no workers required to process transactions, settlement time goes down from days to seconds and occurs 24/7
As smart contract development continues to progress and become cheaper, new use cases are arising every day. A huge use case that arose from this system is Decentralized Finance. Decentralized finance, or DeFi, is a completely open financial market that can be accessed by anyone, anywhere. Learn more about DeFi later on in the course.
📋 Practice Question