Skip to content

ZCalz/nft-collateralized-loan

Repository files navigation

NFT Collaterlized Loan

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

Prerequisites

Before you begin, ensure you have the following software installed:

Installing Prerequisites

  1. Install Node.js and npm:

    Download and install Node.js from the official website. This will also install npm.

  2. Install Truffle:

    Install Truffle globally using npm:

    npm install -g truffle
  3. Install Ganache:

    Download Ganache from the official website and install it.

    Or install from terminal:

    npm i -g ganache
  4. Install Fuzzing Tooling:

    pip3 install diligence-fuzzing
    npm i -g eth-scribble

    Follow the rest of the steps here on the Diligence official website

Project Setup

Follow these steps to set up and run the project:

1. Clone the Repository

Clone the repository to your local machine:

git clone https://github.com/ZCalz/nft-collateralized-loan.git
cd nft-collateralized-loan

2. Install Project Dependencies

Install the project dependencies and generate types using npm:

npm install && npm run postinstall

Copy the environment variables into an env file:

cp .env.example .env

Add 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>

3. Start a Local Blockchain

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

4. Compile Contracts

Compile the smart contracts using Truffle:

truffle compile

5. Migrate Contracts

You 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 development

After 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

6. Run Tests

Run the tests to ensure everything is working correctly:

truffle test --network development

7. Using Fuzzer

Arming:

fuzz arm contracts/NFTCollateralLoanIssuer.sol contracts/NFT.sol

Disarming:

fuzz disarm contracts/NFTCollateralLoanIssuer.sol contracts/NFT.sol

Run:

fuzz run

8. Running The Frontend

Make 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 frontend

Then run:

npm i && npm run start

The frontend will be running on localhost:5173/

Additional Commands

  • 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.

Troubleshooting

If you encounter issues, consider the following:

  • Ensure that the truffle-config.js is 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.

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors