มาสร้าง Blockchain ของเราเองกันเถอะ ( 1 )
Blockchain คือ การบันทึกข้อมูล ที่ยากในการแก้ไข ( แทบจะเป็นไปไม่ได้ ) ที่จะเปลี่ยนแปลงข้อมูล, hack ระบบ, หรือโกงได้

องค์ประกอบของ blockchain จะประกอบด้วย Block ซึ่งเป็นที่เก็บข้อมูลที่เราต้องการบันทึก เมื่อมี block ใหม่เข้ามา ก็จะทำการไปต่อท้ายเหมือนเป็นสายโซ่ ( chain ) เราเลยเรียกว่า Blockchain แต่การที่จะเพิ่ม block เข้าไปใหม่ใน blockchain network จะมีขั้นตอนที่เรียกว่า proof of work ( การสร้าง hash key ที่ตรงตามเงื่อนไขที่เรากำหนดไว้ เราอาจจะรู้จักขั้นตอนนี้ว่า "ขุด" mine )
เราสามารถนำ blockchain มาเป็น บัญชี digital ( digital ledger ) โดยทำการสำเนา transaction และแจกจ่าย ( distributed ) ไปในระบบเครือข่าย ( network system ) ของ blockchain ด้วยการทำงานแบบ decentralize network ทำให้ระบบมีความปลอดภัยสูง และยากในการที่จะทำการปลอมแปลงข้อมูลได้ทุก node ใน network. ในเวลาเดียวกันได้
เรามาดูว่า data structure ของ blockchain จะมีหน้าตาอย่างไร
function Blockchain() {
this.chain = [];
this.pendingTransactions = [];
this.currentNodeUrl = currentNodeUrl;
this.networkNodes = [];
this.createNewBlock(100, '0', '0');
};
มาทำความเข้าใจแต่ละ attribute ใน Blockchain class
- chains array: เป็นที่เก็บ block ใน blockchain
- pendingTransactions: ที่พัก transaction เพื่อจะถูกเก็บไว้ใน block ที่จะถูกสร้างขึ้นใหม่
- currentNodeUrl: URL ของ node นี้ ( เราจะสร้าง blockchain server ในภายหลัง )
- networkNodes: node อื่นๆ ใน blockchain network
- this.createNewBlock(100, '0', '0') คือ block แรกของ blockchain ( genesis block )
ในบทความต่อไป จะอธิบายเกี่ยวกับการจัดเก็บข้อมูลของ transaction ไปใน block อย่างไร
Related Posts
- How AI Supercharges Accounting and Inventory in Odoo (with Dev Insights)
- Building a Fullstack E-commerce System with JavaScript
- Building Agentic AI with Python, Langchain, and Ollama for eCommerce & Factory Automation
- Diagnosing the Root Cause of P0420 with Python, OBD-II, and Live Sensor Data
- How to Apply The Mom Test to Validate Your Startup Idea the Right Way
- When to Choose Rasa vs Langchain for Building Chatbots
- Introducing OCR Document Manager: Extract Text from Documents with Ease
- Testing an AI Tool That Finds Winning Products Before They Trend — Interested?
- Your Website Is Losing Leads After Hours — Here’s the Fix
- How Agentic AI is Revolutionizing Smart Farming — And Why Your Farm Needs It Now
- How to Apply RAG Chatbot with LangChain + Ollama
- Automating EXFO Instruments with SCPI: A Practical Guide
- Design Patterns That Help Tame Legacy Code (With Python Examples)
- How to Safely Add New Features to Legacy Code — A Developer’s Guide
- Modernizing Legacy Software — Without Breaking Everything
- How OpenSearch Works — Architecture, Internals & Real-Time Search Explained
- Choosing the Right Strategy for Basic vs Premium Features in Django
- Transform Your Custom Furniture Business with a Modern eCommerce Platform
- Introducing simpliPOS: The Smart POS Built on ERPNext
- 🌾 Smart Farming Made Simple: A Tool to Help Farmers Track and Plan Inputs Efficiently
Our Products
Related Posts
- How AI Supercharges Accounting and Inventory in Odoo (with Dev Insights)
- Building a Fullstack E-commerce System with JavaScript
- Building Agentic AI with Python, Langchain, and Ollama for eCommerce & Factory Automation
- Diagnosing the Root Cause of P0420 with Python, OBD-II, and Live Sensor Data
- How to Apply The Mom Test to Validate Your Startup Idea the Right Way
- When to Choose Rasa vs Langchain for Building Chatbots
- Introducing OCR Document Manager: Extract Text from Documents with Ease
- Testing an AI Tool That Finds Winning Products Before They Trend — Interested?
- Your Website Is Losing Leads After Hours — Here’s the Fix
- How Agentic AI is Revolutionizing Smart Farming — And Why Your Farm Needs It Now
- How to Apply RAG Chatbot with LangChain + Ollama
- Automating EXFO Instruments with SCPI: A Practical Guide
- Design Patterns That Help Tame Legacy Code (With Python Examples)
- How to Safely Add New Features to Legacy Code — A Developer’s Guide
- Modernizing Legacy Software — Without Breaking Everything
- How OpenSearch Works — Architecture, Internals & Real-Time Search Explained
- Choosing the Right Strategy for Basic vs Premium Features in Django
- Transform Your Custom Furniture Business with a Modern eCommerce Platform
- Introducing simpliPOS: The Smart POS Built on ERPNext
- 🌾 Smart Farming Made Simple: A Tool to Help Farmers Track and Plan Inputs Efficiently