Skip to content

ansifi/block-chain-test

Repository files navigation

block-chain-test

This project demonstrates a simple blockchain application built with Truffle, React, and Ganache. It allows users to send and receive test funds using a custom ERC-20 token called SimpleToken (STK).

Watch the video

Features

  • Smart Contract: A basic ERC-20 token (SimpleToken) deployed on a local blockchain.
  • Frontend: A React-based user interface for sending and receiving test funds.
  • Wallet Integration: MetaMask integration for managing accounts and signing transactions.
  • Local Blockchain: Ganache for running a local Ethereum blockchain.

Prerequisites

Before you begin, ensure you have the following installed:

  1. Node.js and npm: Download Node.js
  2. Truffle: Install globally using npm:
    npm install -g truffle
  3. Ganache: Download Ganache
  4. MetaMask: Install MetaMask (browser extension)

Project Structure

simple-blockchain/
├── build/                  # Compiled smart contracts
├── contracts/              # Solidity smart contracts
│   └── SimpleToken.sol     # ERC-20 token contract
├── frontend/               # React frontend
│   ├── public/             # Static assets
│   ├── src/                # React components
│   └── package.json        # Frontend dependencies
├── migrations/             # Deployment scripts
│   └── 2_deploy_contracts.js
├── test/                   # Smart contract tests
├── truffle-config.js       # Truffle configuration
└── README.md               # Project documentation

Setup Instructions

1. Clone the Repository

Clone this repository to your local machine:

git clone https://github.com/your-username/simple-blockchain.git
cd simple-blockchain

2. Install Dependencies

Install the required dependencies for both the Truffle project and the React frontend:

npm install
cd frontend
npm install
cd ..

3. Run Ganache

  • Open Ganache and create a new workspace.
  • Add the truffle-config.js file to the workspace.
  • Start the Ganache blockchain.

4. Deploy the Smart Contract

Deploy the SimpleToken contract to the Ganache network:

truffle migrate --reset

5. Start the Frontend

Navigate to the frontend directory and start the React app:

cd frontend
npm start

The app will open in your browser at http://localhost:3000.


Usage

1. Connect MetaMask to Ganache

  • Open MetaMask and connect to the Ganache network:
    • Network Name: Ganache
    • RPC URL: http://127.0.0.1:7545 (or http://127.0.0.1:8545 for Ganache CLI)
    • Chain ID: 1337
  • Import an account from Ganache using its private key.

2. Interact with the Frontend

  • Check Balance: The frontend displays your account balance in STK (SimpleToken).
  • Send Funds: Enter the recipient's address and the amount of STK to send.
  • Confirm Transaction: MetaMask will prompt you to confirm the transaction.

Troubleshooting

1. Contract Address Not Specified

  • Ensure the contract is deployed successfully and the address is set in SimpleToken.json.
  • Verify the network ID in the frontend matches the Ganache network ID (1337).

2. MetaMask Not Connecting

  • Ensure MetaMask is connected to the Ganache network.
  • Check that the RPC URL and Chain ID are correct.

3. Frontend Not Loading

  • Ensure the React app is running (npm start in the frontend directory).
  • Check the browser console for errors.

Contributing

Contributions are welcome! If you'd like to contribute to this project, please follow these steps:

  1. Fork the repository.
  2. Create a new branch for your feature or bugfix.
  3. Commit your changes and push to the branch.
  4. Submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.


Acknowledgments


Contact

If you have any questions or feedback, feel free to reach out:


Enjoy building with blockchain! 🚀


You can customize this README further to include additional details, such as screenshots, advanced features, or deployment instructions for testnets/mainnets. Let me know if you need help with anything else! 😊

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published