This README provides instructions for setting up and running this project. It includes prerequisites, installation steps, and how to start a local blockchain, run tests, and deploy contracts.
To run the frontend make sure to complete steps 1-5 first and then go to step 7. You can also checkout a live version of the site here: Live Site
Before you begin, ensure you have the following software installed:
- Node.js (v18.18.2 or later recommended)
- npm (comes with Node.js)
- Truffle (v5.11.5 or later)
- Ganache (v7.9.1 or later)
-
Install Node.js and npm:
Download and install Node.js from the official website. This will also install npm.
-
Install Truffle:
Install Truffle globally using npm:
npm install -g truffle
-
Install Ganache:
Download Ganache from the official website and install it.
Or install from terminal:
npm i -g ganache
-
Install Fuzzing Tooling:
pip3 install diligence-fuzzing npm i -g eth-scribble
Follow the rest of the steps here on the Diligence official website
Follow these steps to set up and run the project:
Clone the repository to your local machine:
git clone https://github.com/ZCalz/nft-collateralized-loan.git
cd nft-collateralized-loanInstall the project dependencies and generate types using npm:
npm install && npm run postinstallCopy the environment variables into an env file:
cp .env.example .envAdd your private key and Infura project id to the environment. You can obtain an Infura project id from the Infura website.
PROJECT_ID=<your-infura-project-id>
PK=<your-private-key>
You can use Ganache to start a local Ethereum blockchain. Open Ganache and create a new workspace, or use the Ganache CLI if preferred.
-
Ganache GUI:
- Launch Ganache and configure a new workspace.
-
Ganache CLI:
-
Install Ganache CLI globally:
npm install -g ganache-cli
-
Start Ganache CLI:
ganache-cli
-
Compile the smart contracts using Truffle:
truffle compileYou can deploy the contract to any network specified in the truffle.config.js file. To deploy the contracts use:
truffle migrate --network <network-name>Deploy the smart contracts to the local blockchain:
truffle migrate --network developmentAfter the project fully deploys, the deployed contract's addresses will appear in the deployed_addresses directory according to the network name.
-
Deploy Specific Migration File:
If you need to deploy a specific migration file, use:
truffle migrate --f <migration_number> --to <migration_number> --network development
Run the tests to ensure everything is working correctly:
truffle test --network developmentArming:
fuzz arm contracts/NFTCollateralLoanIssuer.sol contracts/NFT.solDisarming:
fuzz disarm contracts/NFTCollateralLoanIssuer.sol contracts/NFT.solRun:
fuzz runMake sure to complete step 1-5 before running the frontend. The frontend depends on the generate contract artifacts, deployment addresses and typeschain types.
Change into the frontend directory:
cd frontendThen run:
npm i && npm run startThe frontend will be running on localhost:5173/
-
Run Truffle Console:
Launch a Truffle console connected to the local blockchain:
truffle console --network development
-
Interact with Deployed Contracts:
Use the Truffle console to interact with the deployed contracts and perform transactions.
If you encounter issues, consider the following:
- Ensure that the
truffle-config.jsis properly configured for the correct network. - Verify that Ganache or Ganache CLI is running before deploying contracts.
- Check for any errors or issues in the Truffle output and logs.
For more detailed Truffle documentation, visit the Truffle Documentation.