Welcome to TrustGigs! This project is a decentralized application (dApp) designed to make freelancing safe. It uses "Smart Contracts" to ensure that freelancers get paid and clients get the work they asked for, without needing to trust each other or a middle-man.
If you are new to this, think of Web2 (the current internet like Facebook or Uber) as a system where a single big company owns the data and the "rules."
Web3 is different. It's the Decentralized Web. Instead of one company, the "rules" and "money" are managed by a network of computers (the Blockchain).
- No Boss: No single person can change the rules once the code is "deployed."
- Transparency: Everyone can see the transactions, but no one can fake them.
- Ownership: You own your money in your "Wallet" (like MetaMask), and only you can authorize spending it.
This project has three main parts that talk to each other:
- File:
contracts/TrustGig.sol - What it is: This is a piece of code that lives on the blockchain. It acts like a robotic judge.
- What it does: It holds the money (Escrow). It says: "I will hold this 1 ETH. I will only give it to the Freelancer if the Client clicks 'Approve'." It cannot be bribed or changed.
- Software:
Hardhat - What it is: Since we don't want to spend real money yet, we run a "Fake Ethereum" on your computer.
- What it does: It simulates a network of computers. It gives us test accounts with 10,000 "fake" ETH to play with.
- Software:
React + Vite - What it is: This is the website you see in your browser.
- What it does: It uses a library called
Ethers.js(The Bridge) to talk to the blockchain. When you click a button on the site, it asks your MetaMask Wallet to sign a digital permission slip to move money or create a job.
If you just downloaded the folder and have never run it:
- Install everything: Open a terminal in the folder and run:
npm install
Open 3 separate terminal windows and run these in order:
npx hardhat nodeThis starts your private "Ethereum" world. Leave it running.
npx hardhat run scripts/deploy_fixed.cjs --network localhostThis puts your Smart Contract onto that private world. Run this EVERY time you start Terminal 1.
npm run devThis starts the dashboard. Click the link (e.g., http://localhost:5173) to open it.
If you close your laptop or the website stops updating:
- Close all 3 terminals.
- Repeat Steps B1, B2, and B3 above.
- MetaMask Reset (Important):
- MetaMask remembers your old transactions. When you restart the blockchain (Step B1), MetaMask gets confused.
- Fix: Open MetaMask -> Settings -> Advanced -> Clear Activity Tab Data.
- This "resets" the wallet's memory so it matches the new blockchain.
- Connecting: Make sure MetaMask is set to
Localhost 8545. - Importing: Click the circle in MetaMask -> "Import Account" -> Paste a Private Key from Terminal 1. Do this for two accounts (one for Client, one for Freelancer).
- Resetting (Crucial): If you restart the blockchain (Step 1), MetaMask will get confused because the "World" has been reset but MetaMask remembers the old one.
- Fix: Go to MetaMask > Settings > Advanced > Clear Activity Tab Data. This will fix 99% of "Pending" or "Failed" errors.
- Post: Client posts a job description and a budget.
- Apply: Freelancer applies (proves they are interested).
- Hire: Client Picks the freelancer. This is when the money is locked in Escrow.
- Mark Done: Freelancer finishes and signals the contract.
- Pay: Client approves, and the contract automatically sends the money to the Freelancer.
TrustGig: Making the internet a safer place to work.