This repo ships with a public Sepolia test account so anyone can try the full system end‑to‑end. Do not send any real assets to it.
- Network: Sepolia
- Test account private key (for demo only):
50a1978d6fca900d0ea122307860b26b33f8eb8fb57d68fb66975d75e1834a05 - Notes:
- This account is pre‑granted about 1000 carbon credits (allowance) in
CarbonTraderso you can create and settle auctions. - The key is intentionally public and must never be reused outside of testnets.
- Import it into MetaMask / Rabby as an additional account and switch the network to Sepolia before using the dApp.
- This account is pre‑granted about 1000 carbon credits (allowance) in
-
Import the demo account
- In your wallet (MetaMask / Rabby), choose “Import account” and paste the test private key.
- Switch network to Sepolia and make sure you have a small amount of test ETH for gas.
-
Run or open the frontend
- Local:
Then visit
cd carbontrader-prime npm install npm run devhttp://localhost:5173(or the URL Vite prints). - Or open the Vercel deployment URL for this repo.
- Local:
-
Connect your wallet
- Click
Connect Walleton the landing page and connect the imported Sepolia account.
- Click
-
Get USDT (bid token)
- Go to
Dashboard→ in theUSDT Balancecard clickTop Up. - In the
Acquire USDTmodal:- Either send a small
Amount of ETH to SpendviaSwap ETH for USDT(TokenSale.buyTokens()), or - Click
Claim Daily Faucetto callTokenFaucet.claim()and receive 1000 test USDT once every 24h.
- Either send a small
- Go to
-
Create an auction (seller)
- Switch to
Market→New Listing. - A
Trade IDlikeCT-100001is auto‑generated. - Fill:
Amount (Credits)– amount of carbon credits to list (e.g.100).Starting Total Price (USDT)– total starting ask (e.g.1000).- Optional:
Reserve Price (Total USDT)andBuy Now Price (Total USDT).
- Click
Create Listingand wait for confirmation. The auction card will appear inMarket.
- Switch to
-
Bid and settle
- With a second Sepolia account as buyer:
- Connect that account, go to
Market, choose the auction, clickPlace Bidand enter your total bid (USDT). - If a buy‑now price is set, you can click
Buy Nowto settle immediately.
- Connect that account, go to
- As seller:
- If the auction is still running with at least one bid, click
End Auction Now(or useDashboard → My Auctions → End Early) to callsellerFinalizeEarly. - After end time with a highest bid, click
Settle Auctionto callfinalizeAuctionAndTransferCarbon.
- If the auction is still running with at least one bid, click
- With a second Sepolia account as buyer:
-
Refunds & withdrawals
- Buyers:
- Use
Dashboard → My Bidsand clickRefund Depositon lost / finalized / reserve‑not‑met auctions to get back your deposit.
- Use
- Sellers:
- In
Dashboard, thePending Revenuecard shows withdrawable USDT. ClickClaimto callwithdrawAuctionAmount().
- In
- Buyers:
-
Admin features (optional)
- Connect with the contract owner account (
owner()ofCarbonTrader) to see theAdmintab. - There you can:
- Issue/destroy carbon credits.
- Manage whitelist / blacklist & toggle whitelist mode.
- Configure platform fee basis points.
- Batch finalize ended trades.
- Use the Accounts Console to inspect ETH/USDT/carbon/frozen/withdrawable balances for any set of addresses.
- Connect with the contract owner account (
Foundry-CarbonTrade/– Foundry contracts and Foundry‑style README:src/CarbonTraderStorage.sol– storage layout, events, errors, access control, whitelist/blacklist.src/CarbonTrader.sol– main business logic: carbon credit balances, auction, reserve/buy‑now, fees, whitelist/blacklist, early finalize, cancel trade.src/TokenSale.sol– ETH → USDTMock sale contract.src/TokenFaucet.sol– simple faucet; each address can claim a fixed amount of test tokens every 24 hours.script/deploy.s.sol– deployment script; deploysERC20Mock,CarbonTrader,TokenSale,TokenFaucetand writes their addresses todeployments/latest.json.deployments/latest.json– latest deployment addresses; used by the frontend as default config.test/CarbonTraderTest.sol– core unit tests for on‑chain logic.
carbontrader-prime/– React + Vite frontend:- Reads contract addresses from
../Foundry-CarbonTrade/deployments/latest.json. - Connects via
ethersv6 and implements the full UX described above.
- Reads contract addresses from
frontend/– original single‑page prototype (kept for reference; the React app is the main UI now).
For a detailed contract‑level explanation (errors, invariants, security model), see Foundry-CarbonTrade/README.md.
Build and test contracts:
cd Foundry-CarbonTrade
forge build
forge testRun a local chain:
anvilDeploy to a network (example: Sepolia via env vars):
cd Foundry-CarbonTrade
source .env # export INFURA_RPC_URL, PRIVATE_KEY
forge script script/deploy.s.sol:DeployScript \
--rpc-url $INFURA_RPC_URL \
--private-key $PRIVATE_KEY \
--chain-id 11155111 \
--broadcast -vvvvStart the React frontend:
cd carbontrader-prime
npm install
npm run dev