This decentralized blockchain application provides a comprehensive solution for managing fisheries, fish trading, and sustainability tracking. The system leverages smart contracts to ensure transparency, traceability, and efficient market operations in the fishing industry.
- Manages fish batch logging and tracking
- Allows government to update sustainability status
- Tracks fish batch details and transfers
- Enables listing and trading of fish batches
- Supports buying fish with weight-based pricing
- Ensures only sustainable fish can be listed
- Records transfer stages of fish batches
- Tracks logistical movements and timestamps
- Integrates with FisheriesManagement contract
- Manages authorization of fishing inspectors
- Controlled by government address
- Allows adding and revoking inspector permissions
- Dynamic pricing mechanism
- Adjusts fish prices based on sustainability and freshness factors
- Sustainability Tracking: Government can mark fish batches as sustainable
- Transparent Trading: Open marketplace for fish trading
- Transfer Logging: Comprehensive tracking of fish batch movements
- Price Flexibility: Dynamic price adjustment based on multiple factors
- Secure Authorization: Government-controlled inspector management
- Only government can update sustainability status
- Authorized inspectors manage fish batch tracking
- Price adjustments controlled by specific contract
- Built-in checks to prevent unauthorized actions
-
Node.js: v16 or higher
-
Solidity ^0.8.27
-
Ethereum-compatible blockchain environment
-
MetaMask or similar Web3 wallet
-
Environment Variables: Configure a
.envfile with the following:PRIVATE_KEY=<your-private-key>Replace
<your-private-key>with the private key of your Ethereum wallet. This key will be used for signing transactions during deployment.
-
Clone the repository:
git clone https://github.com/ayushkumar912/FishChain.git cd FishChain cd backend
-
Install dependencies:
npm install
-
Create a
.envfiletouch .env
-
Set up the
.envfile in the backend of the project as shown above.
Deployment is managed using hardhat-deploy. Scripts are stored in the deploy directory.
-
Start a local blockchain:
npx hardhat node
-
Deploy the contracts:
npx hardhat deploy --network localhost
-
Run the backend server
nodemon app.js
-
Url generated for interaction
http://localhost:8080/api/function
- Ensure the
.envfile is configured with a valid private key. - Add RPC URLs for networks in
hardhat.config.jsif necessary.
Test scripts are located in the test directory.
-
Run all tests:
npx hardhat test -
Run tests with a gas report:
REPORT_GAS=true npx hardhat test -
Run tests on a local blockchain:
npx hardhat test --network localhost
- backend
├── contracts/ # Solidity smart contracts
├── deploy/ # Deployment scripts
├── test/ # Tests for the contracts
├── hardhat.config.js # Hardhat configuration
├── .env # Environment variables file
├── routes/ # All the routes are defined
├── scripts/ # mining a block manually
├── app.js # Backend server
└── README.md # Documentation
-
List Available Tasks:
npx hardhat help -
Start a Local Node:
npx hardhat node
-
Run a Script:
npx hardhat run scripts/<script-name>.js
-
Deploy to the local network:
npx hardhat deploy --network localhost
-
Deploy to a testnet (e.g., Rinkeby):
npx hardhat deploy --network rinkeby
-
Run all tests:
npx hardhat test -
Run tests with gas usage reporting:
REPORT_GAS=true npx hardhat test
This project is licensed under the Apache License. See the LICENSE file for details.