spreadzp / ethlisbon

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Trust Scale, the NFTfi Credit Score

Trust Scale is a protocol for determining a wallet's creditworthiness for acting as a borrower in NFT loans. This worthiness is expressed in a numerical value, the NFTfi credit score.

Overview

Problem

Currently, creditworthiness in the NFT loans market is opaque. Users and protocols alike have very little visibility over a borrower's credit history, which makes it difficult to ascertain their likelihood of default. This opaqueness make it difficult to negotiate terms in a transparent way, since lenders don't know much about the borrower's profile. We aim to change that, by giving borrowers to possibility to show lenders their onchain NFTfi credit score.

Solution

Trust Scale gives a wallet a numerical credit score, which enables its owner to leverage their credit history to better negotiate NFT loan terms. This score is given in the form of a Zero-Knowledge Proof (ZKP) that the wallet owner can create, for lenders to later verify. The use of ZKPs enable users to keep their scores private from the general public, so they may preserve their privacy.

Calculation method

We take into account a wallet's past history when interacting with NFTfi protocols to determine its creditworthiness. The calculation is done via a weighted average of two variables - the borrower's Historical Performance Score (HPS) and their Trustworthiness Score (TS). The HPS is a composite score, which expresses the wallet's past behaviour as a borrower. It takes into account the user's default-to-loan ratio, loan recency, loan size and credit utilization. As for TS, it expresses the wallet's past behaviour as a lender, which gives further depth and context about their borrower profile. It does so by considering past loan offers, effective loans and asset diversity in what is also a composite score.

How It Works

  • Borrower visits our website, where they connect their wallet and emit a ZKP of their credit score.
  • Borrower can submit their real-life credit score, to be taken into account in score computation. This information is kept private via IExec's Data Protector.
  • Lenders visit our website to verify the borrower's ZKP, thus confirming their claim to better loan terms.

Future Protocol Expansion

This protocol has a lot of potential for modularity and expansion, namely in terms of accessibility and functionality. In terms of accessibility, the borrower could mint an NFT with their score, as well as create a widget / API that enables protocols to easily display someone's credit score to other users, should they wish to. In terms of functionality, there's a lot of potential to expand the protocol to take into account the borrower's DeFi credit score. This will strengthen their case for negotiating better loan terms and make the transaction as transparent and data-backed as possible, while still preserving the borrower's privacy.

Notes on external component usage

iExec

iExec is a protocol for decentralized cloud computing.

Our project's original plan was to utilize iExec for securing a separate credit score for each user. This credit score could be uploaded by the user via the "Submit manual" functionality. This score would then be used securely through iExec encrypted data when calculating the final score used in this project. The user could request the final score by email, by utilizing iExec's privatized email sending.

Unfortunately, we never got the email component working properly and our email tasks never completed. Due to time constraints, we decided not to include this in the final product. The code used is stored in a separate branch.

Neon EVM

Neon EVM is a revolutionary project to combine the data of Solana with EVM compatibility.

Since Solana's NFT ecosystem is huge, the opportunity to incorporate Solana's NFT lending data couldn't be ignored. We got our project deployed on Neon EVM, but unfortunately did not have the time to incorporate the real NFT lending data.

Technical details

System architecture

Flow chart of the proving engine.

Flow chart of the proving engine

Privacy

The program uses Zero Knowledge technology to hide the credit score. NFT lenders can query our service for whether a certain address has a credit score above certain number or not - they can't find out the exact score.

The ZK language used is Noir from Aztec. The project includes a Noir circuit, an autogenerated Solidity verifier and interaction through the website.

Environments

This Noir verifier contract is accessible in the Polygon ZkEVM testnet, at address 0xe9D7E3FCa12fEcC54167Fb9DD2EE7c52ca404fB8 . For faster testing, local Hardhat deployment is recommended.

Installation

  • Install npm

  • Install noirup with

    curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | bash
  • Install Nargo v0.17.0 with

    noirup -v 0.17.0

If you had a lower version of nargo installed previously and are running into errors when compiling, you may need to uninstall it, instructions here.

  • Install dependencies with

    npm i

Test locally

  1. Copy next-hardhat/.env.example to a new file next-hardhat/.env.

  2. Start a local development EVM at http://localhost:8545 with

    npx hardhat node
  3. Run the unit tests with

    npx hardhat test

Deploy locally

  1. Copy next-hardhat/.env.example to a new file next-hardhat/.env.

  2. Start a local development EVM at http://localhost:8545 with

    npx hardhat node
  3. Build the project and deploy contracts to the local development chain with

    NETWORK=localhost npm run dev
  4. Once your contracts are deployed and the build is finished, start the web app with

    npm run start

Deploy on real networks

Neon EVM

To deploy on Neon EVM:

  1. Fill in the value NEON_DEPLOYER_PRIVATE_KEY in .env
  2. Get testnet tokens for deployment: https://neonfaucet.org/
  3. Run npm run deployNeon
  4. Check the deployed address ("verifier")
  5. To verify the contract: npx hardhat verify 0x12 --network neon where you replace 0x12 with the contract address

An instance of the contract has been deployed and verified at https://devnet.neonscan.org/address/0xBbC1E1B6595aaaa515f169959a165542Ad545A1a#contract

Polygon zkEVM

To deploy on Polygon Zk-EVM:

  1. Fill in the value POLYGONZK_DEPLOYER_PRIVATE_KEY in .env
  2. Get testnet Eth (Polygon zkEVM) https://faucet.polygon.technology/
  3. Run NETWORK=polygonzk npm run deploy

An instance of the contract has been deployed at https://testnet-zkevm.polygonscan.com/address/0xcCC57c20D29E777308FB61728432C675Bc3A09E1 . Unfortunately, contract verification is not supported for that network in Hardhat.

About


Languages

Language:Solidity 83.9%Language:JavaScript 15.2%Language:HTML 0.4%Language:TypeScript 0.3%Language:Roff 0.2%Language:CSS 0.1%