มาสร้าง 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
- Building a Scalable EV Charging Backend — For Operators, Developers, and Innovators
- How to Handle Complex Pricing for Made-to-Order Products in Odoo
- How to Build a Made-to-Order Product System That Boosts Sales & Customer Satisfaction
- Transform Your Operations with Autonomous Agentic AI
- Streamline Fiber Tester Management with a Lightweight EXFO Admin Panel
- Enhancing Naval Mission Readiness with EMI Simulation: Cost-Effective Risk Reduction Using MEEP and Python
- Strengthen Your Cybersecurity Posture with Wazuh: A Scalable, Cost-Effective SIEM Solution
- OCPP Central System + Mobile App — Customer Proposal
- How TAK Systems Are Transforming Border Security
- ChatGPT-4o vs GPT-4.1 vs GPT-4.5: Which Model Is Best for You?
- Can Clients Decrypt Server Data Without the Private Key? (Spoiler: No—and Here’s Why)
- Managing JWT Authentication Across Multiple Frameworks
- Building a Lightweight EXFO Tester Admin Panel with FastAPI and Alpine.js
- Monitoring Cisco Network Devices with Wazuh: A Complete Guide
- Using FastAPI to Bridge Mobile Apps with OCPP EV Charging Systems
- Simulating EMC/EMI Coupling on a Naval Top Deck Using MEEP and Python
- 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?