0
0
Blockchain / Solidityprogramming~5 mins

Why handling value is core to blockchain

Choose your learning style9 modes available
Introduction

Blockchains are special because they let people send and receive value safely without needing a middleman. Handling value means moving money or assets in a way everyone trusts.

When you want to send money directly to a friend without a bank.
When you want to track ownership of digital art or collectibles.
When you want to make sure payments are secure and can't be changed.
When you want to build apps that use tokens or cryptocurrencies.
When you want to create a system where people can trade assets fairly.
Syntax
Blockchain / Solidity
transaction {
  sender: address,
  receiver: address,
  amount: number,
  signature: string
}

A transaction is a record of value moving from one place to another.

Each transaction must be signed to prove it is valid and authorized.

Examples
Alice sends 10 tokens to Bob with her signature to confirm.
Blockchain / Solidity
transaction {
  sender: 'Alice',
  receiver: 'Bob',
  amount: 10,
  signature: 'AliceSignature'
}
Carol sends 50 tokens to Dave securely.
Blockchain / Solidity
transaction {
  sender: 'Carol',
  receiver: 'Dave',
  amount: 50,
  signature: 'CarolSignature'
}
Sample Program

This simple blockchain tracks balances and transactions. Alice starts with 100 tokens, Bob with 50. Alice sends 30 to Bob successfully. Bob tries to send 90 to Alice but fails because he only has 80 after receiving 30.

Blockchain / Solidity
class Blockchain:
    def __init__(self):
        self.chain = []
        self.balances = {}

    def add_transaction(self, sender, receiver, amount):
        if self.balances.get(sender, 0) >= amount:
            self.balances[sender] -= amount
            self.balances[receiver] = self.balances.get(receiver, 0) + amount
            self.chain.append({'sender': sender, 'receiver': receiver, 'amount': amount})
            print(f"Transaction: {sender} sent {amount} tokens to {receiver}")
        else:
            print(f"Transaction failed: {sender} has insufficient balance")

blockchain = Blockchain()
blockchain.balances['Alice'] = 100
blockchain.balances['Bob'] = 50

blockchain.add_transaction('Alice', 'Bob', 30)
blockchain.add_transaction('Bob', 'Alice', 90)
OutputSuccess
Important Notes

Handling value means keeping track of who owns what and making sure transfers are real and safe.

Without value handling, blockchain would just be a list of data with no real use.

Security and trust come from making sure only the owner can send their value.

Summary

Blockchains handle value to let people send money or assets safely.

Transactions move value and must be authorized by the sender.

Tracking balances and transactions keeps the system fair and trusted.