An educational blockchain implementation in TypeScript, designed to demonstrate fundamental blockchain concepts.
- ⛓️ Blockchain creation and management
- ⚒️ Block mining with proof of work
- ✏️ Block editing (for educational purposes)
- 🔄 Block re-mining
- ✅ Chain validation
- 🌐 REST API for interaction
- 🔍 Web interface for visualization
- TypeScript
- Node.js
- Express.js
- Jest (testing)
- HTML/CSS/JavaScript (frontend)
- Backend: Hosted on Render
- Frontend: Deployed on Vercel
- Live Demo: ScottChain Live
- Node.js (version 14 or higher)
- npm or yarn
- Clone the repository:
git clone https://github.com/chrisgadelha/Scottchain1.git
cd Scottchain1
- Install dependencies:
npm install
- Compile TypeScript:
npm run build
- Start the server:
npm start
The server will run at http://localhost:3000
All requests must include the X-Session-ID
header to identify the session.
POST /reset
- Reset the blockchainGET /chain
- Get current blockchainPOST /mine
- Mine a new blockGET /validate
- Validate blockchainPOST /block/update
- Update block dataPOST /block/remine
- Re-mine a block
# Create a new block
curl -X POST http://localhost:3000/mine \
-H "X-Session-ID: session123" \
-H "Content-Type: application/json" \
-d '{"data": "My first block"}'
Run unit and integration tests:
npm test
To view test coverage:
npm run test:coverage
src/
├── lib/ # Core classes
│ ├── block.ts
│ └── blockchain.ts
├── server/ # Express server
│ └── server.ts
├── __tests__/ # Tests
│ ├── block.test.ts
│ └── blockchain.test.ts
└── frontend/ # Web interface
-
Add New Blocks
- Enter data in the input field
- Click "Mine Block" to add a new block to the chain
- Each block contains unique data and a calculated hash
-
Block Manipulation
- Edit any block's data using the input field
- Click "Update" to modify block content
- Note: Updating breaks the blockchain's integrity
-
Block Recovery
- Use "Remine" button to recalculate a block's hash
- Restores blockchain consistency after modifications
-
Chain Validation
- Click "Validate Chain" to check blockchain integrity
- Identifies corrupted or tampered blocks
- Ensures data immutability
-
Reset Blockchain
- Use "Reset Chain" to start a fresh blockchain
- Removes all existing blocks
- Creates a new genesis block
- Educational blockchain exploration
- Understanding proof-of-work concepts
- Demonstrating blockchain immutability
- Experimenting with block manipulation
-
Code Contributions
- Fix bugs
- Implement new features
- Improve performance
- Enhance documentation
-
Reporting Issues
- Use GitHub Issues
- Provide detailed description
- Include steps to reproduce
- Attach relevant screenshots/logs
-
Feature Requests
- Open a new issue
- Describe proposed feature
- Explain its potential value
- Discuss implementation approach
- Fork the repository
- Create a feature branch
git checkout -b feature/your-feature-name
- Commit your changes
git commit -m 'Add detailed commit message'
- Push to your branch
git push origin feature/your-feature-name
- Open a Pull Request
- Describe changes
- Link related issues
- Request code review
- Use Node.js 14+
- Follow existing code style
- Write unit tests for new features
- Ensure all tests pass before submitting
- Be respectful
- Collaborate constructively
- Welcome diverse perspectives
- Focus on learning and improvement
Happy Coding! 💻🔗
This project is under the MIT License. See LICENSE for details.
Christian Gadelha - [[email protected]]
- Luiz Tools for the course and inspiration
- Blockchain community for educational resources