A decentralized application built on Ethereum blockchain using Hardhat, Solidity, Next.js, IPFS, and Fleek. MileChain aims to provide a tamper-proof and decentralized solution for recording the history of mileage and ownership of vehicles to prevent fraud in the used-car market. Our solution utilizes the immutability of blockchain, the decentralized storage of IPFS, and the secure hosting of Fleek to ensure data integrity and reliability.
Before running any command, make sure to install dependencies:
npm install
You'll have to set some environment variables. You can add them to a .env
file, similar to what you see in .env.example
.
PRIVATE_KEY
: The private key of your account (like from metamask). NOTE: FOR DEVELOPMENT, PLEASE USE A KEY THAT DOESN'T HAVE ANY REAL FUNDS ASSOCIATED WITH IT.SEPOLIA_RPC_URL
: This is url of the node you're working with. You can get setup with one for free from AlchemyETHERSCAN_API_KEY
: You'll need this if you want to automatically verify deployed contractsCOINMARKETCAP_API_KEY
: You'll need this if you want to have USD convertions of gas used to call the contract functionsREPORT_GAS
: You have to set this totrue
if you want detailed gas usage reports of the contractsDB_CONN_STRING
: The MongoDB connection string. You'll need this if you want to deploy the contract on a live network.
Compile the smart contracts with Hardhat:
npx hardhat compile
Run the unit tests:
npx hardhat test
Run the staging tests:
npx hardhat test --network sepolia
To get a report of gas costs, set env REPORT_GAS
to true. A file named gas-report.txt
will be generated when running new tests.
To get a USD estimation of gas cost, you'll need a COINMARKETCAP_API_KEY
environment variable. You can get one for free from CoinMarketCap.
npx hardhat deploy --network sepolia | mainnet | localhost
After you created a local node (with npx hardhat node
) and deployed the contract to it (with npx hardhat deploy --network localhost
), you can interact with it using the existent tasks:
addVehicle [licensePlate] [mileage]
getVehicle [licensePlate]
The syntax for executing tasks is the following:
npx hardhat [taskName] [options] --network localhost
For example, the commading for getting the vehicle with licence plate "AA000AA" is:
npx hardhat getVehicle AA000AA --network localhost
If you deploy to a testnet or mainnet, you can verify it if you get an API Key from Etherscan and set it as an environemnt variable named ETHERSCAN_API_KEY
. You can pop it into your .env file as seen in the .env.example.
In it's current state, if you have your api key set, it will auto verify your contracts!
However, you can manual verify with:
npx hardhat verify --constructor-args arguments.js DEPLOYED_CONTRACT_ADDRESS
Nicolas Guarini - @nicolasguarini - nicolasguarini.it
Lorenzo Ficazzola - @Zeref-zt