This README is the exact setup order for a new teammate to run the project locally with:
- Hardhat local blockchain
- Contract deployment
- Next.js web app
- Manual private-key sign in
Install these before starting:
- Node.js 20+ (recommended: 20 LTS)
- npm 10+
- Git
Optional:
- Docker Desktop (only if you want to run
docker composeflow)
git clone <REPO_URL>
cd supply-chain-trackingThere are 2 required env files:
- root
.env(used by Hardhat/deploy/scripts) services/web/.env.local(used by Next.js frontend)
Copy from example:
cp .env.example .envSet local values:
TENDERLY_RPC_URL=http://127.0.0.1:8545
TENDERLY_CHAIN_ID=1337
DEPLOYER_PRIVATE_KEY=0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d
CHAINPROOF_RPC_URL=http://127.0.0.1:8545
CHAINPROOF_CHAIN_ID=1337
CHAINPROOF_CONTRACT_KEY=chainproof
CHAINPROOF_CONTRACT_VERSION=2.0.0
CHAINPROOF_REGISTRY_PATH=/config/contracts.json
CHAINPROOF_SIGNER_PRIVATE_KEY=0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690dNotes:
CHAINPROOF_REGISTRY_PATH=/config/contracts.jsonis okay; deploy script auto-falls back to localservices/smart-contracts/config/contracts.jsonwhen/configis not present.- Use test keys only. Never use a real mainnet key.
Copy from example:
cp services/web/.env.example services/web/.env.localSet local values:
NEXT_PUBLIC_CHAINPROOF_RPC_URL=http://127.0.0.1:8545
NEXT_PUBLIC_CHAINPROOF_CHAIN_ID=1337
NEXT_PUBLIC_CHAINPROOF_CONTRACT_KEY=chainproofInstall per service:
cd services/smart-contracts && npm install
cd ../web && npm install
cd ../..You can deploy either to:
- local Hardhat node (fast local dev)
- Tenderly Virtual TestNet (shared persistent testnet)
cd services/smart-contracts
npx hardhat nodeKeep this terminal running.
The node starts at:
- RPC:
http://127.0.0.1:8545 - Chain ID:
1337
It will print funded accounts and private keys. Those are test-only keys for local use.
Set these in root .env:
TENDERLY_VIRTUAL_TESTNET_RPC_URL=https://virtual.mainnet.rpc.tenderly.co/<project>/<testnet>
TENDERLY_VIRTUAL_TESTNET_CHAIN_ID=<your_virtual_chain_id>
TENDERLY_DEPLOYER_PRIVATE_KEY=0x<test_private_key>
CHAINPROOF_RPC_URL=https://virtual.mainnet.rpc.tenderly.co/<project>/<testnet>
CHAINPROOF_CHAIN_ID=<your_virtual_chain_id>
CHAINPROOF_SIGNER_PRIVATE_KEY=0x<test_private_key>Then deploy:
cd services/smart-contracts
npm run deploy:tenderlyOpen a second terminal:
Local:
cd services/smart-contracts
npm run deploy:localTenderly Virtual TestNet:
cd services/smart-contracts
npm run deploy:tenderlyExpected result:
- Shows deployed
ChainProofaddress - Updates
services/smart-contracts/config/contracts.jsonunder:- key
chainproof - deployed chain id (for local usually
1337; for Tenderly use your virtual chain id)
- key
Open a third terminal:
cd services/web
npm run devOpen:
http://localhost:3000
- Go to login page.
- Paste one private key from Hardhat node output (for example Account #1).
- Click Sign In.
- If role is
none, assign role on-chain from the UI.
- Chain display in UI shows
1337 - No
Wrong RPC networkerror - No
No contract code found at ... on chain 1337error - Role assignment succeeds
- Producer dashboard actions (for producer role) submit transactions
Cause: Hardhat node restarted, but contract was not redeployed.
Fix:
- Ensure
npx hardhat nodeis running. - Re-run deploy:
cd services/smart-contracts npx hardhat run scripts/deploy.js --network localhost - Refresh web page (restart
npm run devif needed).
Cause: .env and .env.local chain/RPC do not match.
Fix: Both must point to same chain/RPC pair (127.0.0.1:8545 + 1337 for local).
Most common causes:
- You are pointed at wrong contract address for current chain.
- Contract for that chain is old or missing expected function.
- You restarted local node and forgot redeploy.
Every time you restart local blockchain:
- Start
npx hardhat node - Re-deploy contract (
scripts/deploy.js --network localhost) - Run web app (
npm run dev)
If preferred, run blockchain + dashboard with Docker:
docker compose up chain dashboard- Hardhat RPC is exposed on
localhost:8545 - Streamlit dashboard is exposed on
localhost:8501
You still run the web app from services/web with npm run dev.