มาสร้าง 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 อย่างไร
Get in Touch with us
Related Posts
- How the TAK System Works: A Complete Guide for Real-Time Situational Awareness
- Building an E-commerce Website & Mobile App with Smart AI Integration — The Modern Way
- Personalized Recommendations Are Here — Powered by Smart Analytics
- Rasa vs LangChain vs Rasa + LangChain: Which One is Right for Your Business Chatbot?
- Understanding Wazuh by Exploring the Open Source Projects Behind It
- How to Integrate App Authentication with an OCPP Central System
- Beginner’s Guide: How EV Charging Apps Communicate, Track Charging, and Calculate Costs
- Building an OCPP 1.6 Central System with Flask async, WebSockets, and MongoDB
- 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