A decentralized application (dApp) or web3 application that uses blockchain technology to record the security checks that a company must carry out in order to prove the security of its buildings.
This app is intended to be used for educational and informational purposes.
You can access to a demo:
All employers must ensure the occupational safety and health of their employees (Art. L4121-1 of the French labor code).
The employer must guarantee that the building welcoming workers (ERT) and the public (ERP) complies with safety standards.
The employer must carry out periodic general checks (VGP) on any equipment that could present a danger in the event of a malfunction (heating, electricity, etc.) and on fire-fighting means (fire extinguisher, fire alarm, smoke extraction, etc.) .
Periodic general checks (VGP) are noted in a register which must be available in any ERT or ERP building.
It is called Security (or Safety) Register and is binding in the event of an incident (fire, accident, occupational illness, etc.)
The Security Register is most often a paper document.
There are digital versions whose information is centralized. This application takes advantage of the decentralization of. blockchain technology.
- A company
- subscribe by registering its company
- add sites
- add a verifier
- manage user accounts
- create verification tasks
- manage verification tasks status
- show verification tasks
- A Verifier
- subscribe by registering its company
- manage user accounts
- manage verification tasks status
- show verification tasks
- A guest
- show verification tasks
flowchart LR
subgraph "Company"
CA[A company]
CA --> CB(Subscribe)
CA --> CC(Add verifier)
CA --> CD(Add members)
CA --> CE(Create task)-->CF(task waiting for validation)
CA --> CL(Show verification tasks)
CF-->|task validated| CG{Manage status}
CG-->CH(Approve task)
CG-->CJ(Reject)
CG-->CI(Conditionally approve)
CH-->CK(Create NFT)
CJ-->CK
end
subgraph "Verifier"
VA[A verifier]
VA --> VB(Subscribe)
VA --> VC(Add members)
VA --> VD[Validate task]--> CF
VA --> CL
end
subgraph "Guest"
GA[A Guest]
GA --> CL
end
This app uses Ethereum blockchain on the testnet network Sepolia.
- NEXT.js
- Typescript
- TailwindCSS
- Hardhat 2.16.1
- RainbowKit
- Wagmi
- Solidity 0.8.18
- TheGraph & graph-client 3.0.0
-----------------------|----------|----------|----------|----------|----------------|
File | % Stmts | % Branch | % Funcs | % Lines |Uncovered Lines |
-----------------------|----------|----------|----------|----------|----------------|
contracts/ | 100 | 96.08 | 100 | 100 | |
SecurityRegister.sol | 100 | 96.08 | 100 | 100 | |
-----------------------|----------|----------|----------|----------|----------------|
All files | 100 | 96.08 | 100 | 100 | |
-----------------------|----------|----------|----------|----------|----------------|
In folder backend
, rename sample.env
to .env
This file contains the information necessary for authentication on the Sepolia test network.
INFURA_ID=<Infura API key>
SEPOLIA_PRIVATE_KEY=<your account private key >
In folder frontend
, Rename sample.env
to .env.developement
and .env.production
- Create a Wallet project ID - WalletConnect
- Create a subgraph - The Graph
- Create a Pinata account - Pinata
NEXT_PUBLIC_CONTRACT_ADDRESS=<YOUR_SMART_CONTRACT_ADDRESS>
NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID=<YOUR_WALLET_CONNECT_PROJECT_ADDRESS>
NEXT_PUBLIC_ENABLE_TESTNETS=<true or false>
NEXT_PUBLIC_NETWORK=<hardhat or sepolia>
NEXT_PUBLIC_GENESIS_BLOCK=<GENESIS_BLOCK>
THE_GRAPH_HTTP_TRANSPORT=<The Graph>
NEXT_PUBLIC_PINATA_API_KEY=<Pinata API Key>
NEXT_PUBLIC_PINATA_SECRET_API_KEY=<Pinata private Key>
Enter the values according to the environment:
- .env.development
NEXT_PUBLIC_ENABLE_TESTNETS=true
NEXT_PUBLIC_NETWORK=hardhat
NEXT_PUBLIC_GENESIS_BLOCK=1
- .env.production
NEXT_PUBLIC_ENABLE_TESTNETS=false
NEXT_PUBLIC_NETWORK=sepolia
From the root folder, go to the backend
folder and install the dependencies
cd backend
npm install
From the root folder, go to the frontend
folder and install the dependencies
cd frontend
npm install
From the root folder, position yourself in the backend
folder
cd backend
Open a console and run the following code to start the hardhat
testnet:
npx hardhat node
Important: leave this console open
Open a second console and run the following code to deploy the smart contract:
npx hardhat run --network localhost scripts/01-deploy.ts
npx hardhat run --network sepolia scripts/01-deploy.ts
From the root folder, navigate to the frontend
folder
cd frontend
npm run dev
npm run build && npm run start
From a web browser http://localhost:3000
From the root folder, position yourself in the backend
folder
cd backend
npx hardhat compile
npx hardhat test
With coverage
npx hardhat coverage
Gas report
REPORT_GAS=true npx hardhat test
Only the frontend is deployed on Vercel
The testnet used is Sepolia.