Beyond Cryptocurrency
Blockchain technology provides distributed, immutable ledgers and smart contracts that solve real problems in supply chain, finance, healthcare and more.
How Blocks Work
import hashlib
import json
from datetime import datetime
class Block:
def __init__(self, data, previous_hash="0"):
self.timestamp = datetime.now().isoformat()
self.data = data
self.previous_hash = previous_hash
self.hash = self.calculate_hash()
def calculate_hash(self):
content = json.dumps({
"timestamp": self.timestamp,
"data": self.data,
"previous_hash": self.previous_hash
})
return hashlib.sha256(content.encode()).hexdigest()
chain = [Block("Genesis Block")]
chain.append(Block("Alice sends Bob 10 ETH", chain[-1].hash))
Smart Contracts with Solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract SimpleVoting {
mapping(string => uint) public votes;
mapping(address => bool) public hasVoted;
function vote(string memory candidate) public {
require(!hasVoted[msg.sender], "Already voted!");
votes[candidate]++;
hasVoted[msg.sender] = true;
}
}
Development Tools
- Hardhat: Development environment for Ethereum
- Remix IDE: Browser-based Solidity IDE
- MetaMask: Browser wallet for testing
- Ethers.js: JavaScript library for blockchain
Getting Started Path
- Learn JavaScript and Node.js basics
- Understand Ethereum concepts (ethereumbook.info)
- Learn Solidity at CryptoZombies.io
- Deploy to testnet with Hardhat
- Build a simple DApp (token, voting, or NFT)
