Tag: blockchain for beginners

  • Day 10 — Why Does Ethereum Charge Gas for Every Tiny Step?

    A measured gas meter limiting the computational work of Ethereum

    We now know that Ethereum nodes repeat the instructions inside a smart contract so that the network can agree on one result. That shared execution creates a new problem. Computation is not free. If anybody could ask every node to perform unlimited work, a careless program or an attacker could keep the network busy forever.

    Ethereum solves this with gas. Gas is a unit used to measure the amount of computational work a transaction requires. Adding two numbers costs a small amount. Reading or changing stored data costs more. Deploying a large smart contract may require much more. Gas is not a separate coin; it is the meter that counts the work, while the fee is paid in ether.

    Think of it like taking a taxi. Distance is not money, but it helps calculate the fare. In the same way, gas measures the journey through a program. A user sets a limit on how much gas the transaction may consume. If the contract finishes within that limit, unused capacity is not charged. If it runs out, execution stops so that the program cannot consume resources endlessly.

    The final fee also depends on what the network is charging for each unit of gas. When many people want their transactions included, block space becomes more competitive and fees can rise. A user can also offer an additional priority fee to encourage faster inclusion. This is why two identical actions performed at different times may cost different amounts.

    Gas protects the network, but it can surprise beginners. A transaction that fails may still consume a fee because nodes already performed work before discovering the failure. Paying for computation does not guarantee that the intended result will succeed; it pays the network for checking and executing the attempt.

    This system turns computation into a scarce resource and discourages spam. It also explains why developers try to write efficient contracts and why scaling Ethereum matters so much. Before we reach scaling, however, we need to understand who is authorising these paid instructions.

    When a website sees a password, it asks a company’s server whether the password is correct. Ethereum has no such account desk. So how can a wallet prove that a transaction truly came from you without sending a password to the network? The answer lies in digital signatures.

  • Day 9 — If Ethereum Is a Computer, Who Actually Runs It?

    Independent computers executing the same Ethereum Virtual Machine instructions

    Yesterday we described Ethereum as a blockchain that can hold both value and logic. That description sounds impressive, but it also hides a practical problem. A program cannot execute itself. On a normal website, code runs on a server owned by a company. If Ethereum has no central server, which computer actually runs a smart contract?

    The answer is not one special machine. Ethereum defines a small, standardised computing environment called the Ethereum Virtual Machine, usually shortened to the EVM. Developers write smart contracts and compile them into instructions that the EVM understands. Those instructions are stored on the blockchain along with the contract’s address and data.

    A useful way to imagine the EVM is as a calculator whose design has been copied onto thousands of computers. Give every copy the same starting numbers and the same operation, and each should produce the same answer. When someone sends a transaction to a smart contract, Ethereum nodes execute the relevant instructions and calculate the resulting changes. One node may be in Mumbai and another in London, but the rules of the virtual machine are the same.

    The result is a shared state. This state includes account balances, contract storage and other information that Ethereum currently recognises as true. A transaction proposes a change to that state. The network checks the signature, executes the contract, and agrees on the new result before it becomes part of a block. A person cannot simply change the answer on their own computer because their version would disagree with everyone following the protocol.

    For this agreement to work, the EVM has to be deterministic. The same input must always lead to the same output. A smart contract therefore cannot casually ask one computer for its local time, read a private file, or browse a website while it is running. Different machines might receive different answers. Contracts operate inside a controlled sandbox and can use only information supplied in a form the network can verify.

    This repetition sounds wasteful because many computers perform the same work. In one sense it is. Ethereum deliberately trades ordinary server efficiency for independent verification. The benefit is that no single server owner can secretly change the program’s result, switch off the database or rewrite a balance. The cost is that shared computation is scarce.

    That leads to the next question. If thousands of machines may need to check a computation, what prevents someone from submitting an enormous program or an infinite loop and making everybody work for free? Ethereum’s answer is a meter attached to every instruction: gas.

  • Day 8 — What If Money Could Follow Instructions?

    A smart contract running on a blockchain as a shared programmable agreement

    Yesterday, we reached a boundary in Bitcoin’s design. Bitcoin is exceptionally good at recording ownership and moving value without a bank, but its rules are deliberately narrow. It can answer questions such as “Does this person own these coins?” and “Has this money already been spent?” What if a blockchain could answer a more interesting question: “Should this money move only when a particular condition becomes true?”

    Imagine that you and your friend Rahul make a small bet on a cricket match. Ordinarily, one of you would hold the money, or both of you would trust a third person to pay the winner. That third person could disappear, take a fee, choose a side, or simply make a mistake. Now imagine placing the money inside a transparent digital box. The box contains a rule: after the match ends, release the entire amount to whoever won. Nobody can quietly change the rule, and the box does not need to like or trust either person.

    This is the basic idea behind a smart contract. A smart contract is a small program stored on a blockchain. It receives information, checks the rules written into its code, and changes the blockchain’s state when those rules are satisfied. It can hold digital assets, send them, exchange them, or record a result. Once deployed, the same program is visible to the network and every participant can verify what it is supposed to do.

    The name can be slightly misleading. A smart contract is not necessarily smart, and it is not automatically a legal contract. It does not understand intention, fairness, or the spirit of an agreement. It follows instructions. If the code says that money should move after a certain digital signature appears, then that is the condition it checks. It behaves less like a lawyer and more like a vending machine: provide the required input, and a predictable output follows.

    Bitcoin already has a limited scripting system, but it was intentionally designed to remain simple and cautious. In 2015, Ethereum took a broader approach. Instead of building a blockchain mainly around one kind of digital asset, Ethereum was designed as a shared platform on which developers could publish many different programs. Its native currency, ether, is used to pay for activity on this network, but the larger idea is that the blockchain can store both value and logic.

    That small change opens a surprisingly large door. A lending program can release funds when enough collateral has been deposited. A marketplace can exchange a token and a payment in one operation so that neither side has to move first. A group can keep funds in a shared treasury that only moves after several members approve. A game can record ownership of an item outside the company that created it. Each of these systems can be built from smart contracts that interact with one another.

    Applications built in this manner are usually called decentralized applications, or dApps. They may still look like ordinary websites on the surface. There can be buttons, forms, profiles and colourful dashboards. The difference lies underneath. Instead of sending every important instruction to one company’s private server, the application sends transactions to smart contracts on a public network. The rules and resulting changes can be independently checked.

    This does not remove trust completely. It changes where trust is placed. Users no longer need to trust a company to follow hidden database rules, but they must trust that the public code was written correctly. A mistake in an ordinary website can often be repaired quietly by an administrator. A mistake in a smart contract can be much harder to undo, particularly if the program controls valuable assets. Transparency helps people inspect the rules, but visible code is not the same as flawless code.

    There is another puzzle. If a smart contract is a program, some computer must run it. A normal application usually has a server owned by one company. Ethereum claims to run programs without giving one server or one company control. Does every computer execute every instruction? Who decides the result, and what prevents someone from changing it on their own machine?

    To answer that, we need to look inside Ethereum’s shared computer: the Ethereum Virtual Machine.