Learn everything about Aptos
Smart contracts are executed on blockchain, which means that the terms are stored in a distributed database and cannot be changed.
Just like we can add any data into a block, we can add software programs into a block.
šµļøāāļø Definition: These software programs that go into the blocks are called āsmart contracts.ā
Users can trigger the existing code pieces (āsmart contractsā) on a blockchain to execute them with the inputs they want.
Every smart contract is associated with an account. Users also have accounts. When a user wants to trigger (ācallā) a smart contract, that user creates a transaction to the smart contract account.
š§ Reminder: New transactions are broadcasted to the node network to be added to the blocks after mining.
Similarly, triggering a smart contract is essentially the same as creating a new transaction to the account of that smart contract. These transactions are broadcasted to the nodes to be included in the next block.
Miners use computational resources, mostly time and memory, to execute smart contracts. To execute this contract, the user pays a "transaction fee" to the miner in exchange for computational resources.
The amount of the transaction fee can vary depending on the complexity of the transaction. A complex smart contract with a large number of transactions consumes more computational resources and therefore requires a higher transaction fee.
Transaction fees help ensure that a blockchain remains decentralized by incentivizing miners to get paid and join the network. Preventing spam and abuse. Charging a fee to run the code prevents spam accounts from sending too many transactions to the network.
š Fun fact: Transaction fees are called different things for different blockchains. Aptos, Ethereum and Cosmos use the label "gas fee", while Solana calls it "rent".
As we know from our daily lives, software programs can do many things. But codes in a blockchain have some limitations, as weāll explain later.
Still, letās see the two main things that the smart contracts can do when executed:
1ļøā£ Generating new transactions to be added to new blocks. A smart contract can create new transactions. These transactions should then be added to the blockchain by miners.
2ļøā£ Updating the state of the blockchain. A smart contract can update the state of the blockchain by modifying the data stored on the blockchain. That might mean updating a balance or changing the ownership of an asset.
Decentralized computing systems are complex.
But they come with some advantages that existing computing systems donāt have:
- No single point of failure. Decentralized systems are more secure because many nodes have a copy of the entire blockchain. There is no single, uniquely vulnerable point. Even if a few nodes are out of game, the remaining nodes can run the entire system.
- Transparency. This one is obvious, right? The system is transparent because literally everything is recorded on a blockchain!
- Immutability. The system is immutable because previous blocks cannot be changed.
Comments
You need to enroll in the course to be able to comment!