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).
- 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.
Before you begin, ensure you have the following installed:
- Node.js and npm: Download Node.js
- Truffle: Install globally using npm:
npm install -g truffle
- Ganache: Download Ganache
- MetaMask: Install MetaMask (browser extension)
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
Clone this repository to your local machine:
git clone https://github.com/your-username/simple-blockchain.git
cd simple-blockchain
Install the required dependencies for both the Truffle project and the React frontend:
npm install
cd frontend
npm install
cd ..
- Open Ganache and create a new workspace.
- Add the
truffle-config.js
file to the workspace. - Start the Ganache blockchain.
Deploy the SimpleToken
contract to the Ganache network:
truffle migrate --reset
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
.
- Open MetaMask and connect to the Ganache network:
- Network Name: Ganache
- RPC URL:
http://127.0.0.1:7545
(orhttp://127.0.0.1:8545
for Ganache CLI) - Chain ID:
1337
- Import an account from Ganache using its private key.
- 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.
- 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
).
- Ensure MetaMask is connected to the Ganache network.
- Check that the RPC URL and Chain ID are correct.
- Ensure the React app is running (
npm start
in thefrontend
directory). - Check the browser console for errors.
Contributions are welcome! If you'd like to contribute to this project, please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bugfix.
- Commit your changes and push to the branch.
- Submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
- Truffle Suite for the development framework.
- MetaMask for wallet integration.
- React for the frontend.
If you have any questions or feedback, feel free to reach out:
- Email: [email protected]
- GitHub: github.com/ansifi
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! 😊