Project for CZ4153-Blockchain-Tech
Github Repository: https://github.com/Zenteh-NTU/CZ4153-Blockchain-Tech
To deploy your program, you need to have the following installed:
- NodeJS - https://nodejs.org/en/
- Ganache - https://trufflesuite.com/ganache/
- Metamask extension
Before proceeding with the next steps, it is very important that you have both Ganache running and all 3 of the program requirements installed on your machine.
To deploy the Smart Contracts, you will first need to run npm install
in the web3.0/smart_contract
folder.
cd web3.0/smart_contract
npm install
Next, you will have to configure the hardhat.config.js
file.
You will need to first create a hardhat.config.js
file in the web3.0/smart_contract
folder
A template file (hardhat.config-template.js
) has already been provided and you can copy the file and rename it as hardhat.config.js
To configure the file, you will need to paste the private key of one of the Ethereum accounts provided by the Ganache server. This will be the Ethereum account that will be used to deploy the Smart Contract.
Double check that the url
entry in the js file is the RPC server address that Ganache is running on.
Once all that is done, the Smart Contract can be deployed.
In the web3.0/smart_contract
folder on your terminal, run the following command:
npx hardhat run .\scripts\deploy.js --network ganache
The terminal should output a line that says something like
Transactions deployed to: [CONTRACT DEPLOYED ADDRESS]
This is the address that the Smart Contract is deployed at, copy this address to a notepad for now as it will be used later.
The generated ABIs will be in the following folders:
web3.0/artifacts/contracts/MarketTracker.sol/MarketTracker.json
web3.0/artifacts/contracts/MarketTracker.sol/Market.json
web3.0/artifacts/contracts/MarketTracker.sol/MarketTransactions.json
Like in the previous section, you will first need to run npm install
in the web3.0/client
folder.
cd web3.0/client`
npm install
After all the npm dependencies have been installed, you will need to copy the generated ABIs in the previous step into the web3.0/client/src/utils
folder.
The last step to do before running the program, is changing the deployment address that you have copied earlier into web3.0/client/src/utils/constants.js
file.
In the web3.0/client/src/utils/constants.js
file
line 8: export const contractAddress = '[CONTRACT DEPLOYED ADDRESS]';
From your terminal, cd into the web3.0/client/
directory and run
npm run dev
- ReactJS - https://reactjs.org/
- Vite - https://vitejs.dev/
- TailwindCSS - https://tailwindcss.com/
- Ganache - https://trufflesuite.com/ganache/
- Hardhat - https://hardhat.org/
- NodeJS - https://nodejs.org/en/