This project implements a decentralized system for managing student identification cards using Ethereum smart contracts. The smart contract allows the owner (institution) to issue, invalidate, and extend student cards. It uses a mapping to associate each student’s public key with their identification card details, providing a secure, transparent, and immutable way to handle sensitive student data.
The student's card details are encrypted using the student's public key. This ensures that only the holder of the corresponding private key can decrypt and access the details, safeguarding the confidentiality of the information.
NextJS, @primer/react, ganache, prisma, Web3.js, Solidity.
click to see smart-contract
source code.
Issue Student Card:
- The
issueCard
function allows the contract owner to issue a student card by providing a card hash, expiration date, and the student's public key. An event CardIssued is emitted once the card is successfully issued.
Get Student Card:
- The
getCard
function allows anyone to retrieve the details of a student card using the student's public key. If no card is found, an error is thrown.
Invalidate Student Card:
- The
invalidateCard
function marks a student card as invalid, preventing further use. This can only be done by the contract owner, and an event CardInvalidated is emitted.
Extend Card Expiration:
- The
extendCardExpiration
function extends the expiration date of an existing student card, ensuring that the new expiration date is greater than the current one. An event CardExpirationExtended is emitted.
Flowchart showing how the project is structured
User Registering
01-register-flow.webm
Admin rejecting user's request
02-admin-reject-user-flow.webm
Admin approving user's request
03-admin-approve-user-flow.webm
Admin extending user's card expiration time
04-admin-extend-expiration-time.webm
Admin invalidatin user's card
05-admin-invalidate-user-card.webm
User decrypting card
06-user-decrypting-card.webm
User forgot private key
07-user-forgot-private-key.webm
ATTENTION: To run this project locally, you must have docker installed on your machine.
cp .env.example .env
⚠️ To run the project with all the features, you would need a lambda function using the presigned urls strategy. And then add thefunction_url
toLAMBDA_FUNCTION_URL
env. If you really want to run the project, contact me.
The lambda function structure can be followed here.
pnpm project:setup
- This command will:
- install project dependencies;
- compose up docker conteiner;
- wait for the conteiner up;
- run migrations.
pnpm dev:all
- This command will:
- start ganache local server (concurrently in terminal)
- deploy the smart contract on ganache local server (it will save the contract address in a file)
- compose up docker conteiner;
- wait for conteiner;
- run the development server.