Skip to main content

Command Palette

Search for a command to run...

Building CryptoScore: A Blockchain-Based Wallet Credit Scoring App Using Blockscout API

Published
4 min read
Building CryptoScore: A Blockchain-Based Wallet Credit Scoring App Using Blockscout API
V

I am a third-year Computer Science Engineering student studying in Chandigarh. I am a full-stack web developer exploring the field of DevOps and gaining hands-on experience in it, including AWS.

Hello everyone, and welcome to this detailed blog post about my latest Web3 project — CryptoScore.

In this project, we built an innovative application that calculates a credit-like score for Ethereum wallets based on their on-chain activity. Using the powerful Blockscout API, CryptoScore analyzes various blockchain data points such as wallet balance, transaction history, and NFT activity to generate insights and a risk-based credit score.


What is CryptoScore?

CryptoScore is designed to provide users with a credit score equivalent based on their Ethereum wallet behavior. Much like traditional credit scoring, but powered by transparent, immutable blockchain data, this tool can help assess wallet trustworthiness and activity patterns.

Currently, CryptoScore supports the Ethereum network but plans are in place to extend support to other popular chains available on Blockscout like Polygon, BNB Chain, Arbitrum, Optimism, and more.


How Does CryptoScore Work?

At the heart of CryptoScore lies the Blockscout API — a comprehensive blockchain explorer API that provides detailed data about wallet addresses and transactions.

Here’s the step-by-step data retrieval process:

  • Fetch Wallet Balance: Using the fgetbalance endpoint, the app retrieves the current balance of the user’s Ethereum address.

  • Retrieve Transaction History: The app calls the account module with the txlist action to gather the complete list of transactions for the wallet. This helps in calculating total transaction count and identifying activity patterns.

  • Analyze NFT Activity: To include token holdings and NFT activity, CryptoScore uses the ERC721 Token Transfer Events endpoint. This fetches all NFT transactions associated with the address, giving insight into token engagement.

All these endpoints are well documented on the official Blockscout API page. For those interested, I’ll share the links to the API documentation and source code at the end of this post.


Live Demo and User Experience

On the front end, CryptoScore features a clean dashboard where users simply paste their Ethereum wallet address.

The app connects to the blockchain through the Blockscout API, fetches relevant data, analyzes the transaction and token patterns, and then generates a credit score with an associated risk level.

For example, in one demo case, the app analyzed a recently created wallet with the first transaction dated May 29th and the latest on May 31st. Based on this data, the wallet was assigned a medium risk score with a recommendation for consistent activity to improve trustworthiness.

The dashboard also displays detailed information such as:

  • Wallet balance

  • Total number of transactions

  • First and last activity dates

  • Risk level assessment

  • History of NFT transactions including token names, transfer dates, and counterparties

All data points can be cross-verified directly on Blockscout Explorer, ensuring transparency and accuracy.


The Coding Part: How the APIs Work

The backend of CryptoScore uses several Blockscout APIs to fetch data related to the user's wallet:

  • Balance API: Retrieves the wallet’s current balance by passing the user’s address to the endpoint.
const API_BASE_URL = 'https://eth.blockscout.com/api';

try {
    // Get balance
    let balanceResponse;
    try {
      balanceResponse = await fetchWithRetry(API_BASE_URL, {
        module: 'account',
        action: 'balance',
        address: address
      });
    } catch (error: any) {
      console.error('Balance fetch error:', error);
      return NextResponse.json({ 
        status: '0',
        message: 'Failed to fetch balance',
        result: null
      }, { status: 500 });
    }
  • Transaction API: Fetches the full transaction list associated with the address using the user account module and the transaction list action.
const API_BASE_URL = 'https://eth.blockscout.com/api';

try {
    // Get normal transactions
    let txResponse;
    try {
      txResponse = await fetchWithRetry(API_BASE_URL, {
        module: 'account',
        action: 'txlist',
        address: address,
        startblock: 0,
        endblock: 99999999,
        sort: 'desc'
      });
    } catch (error: any) {
      console.error('Transaction fetch error:', error);
      return NextResponse.json({ 
        status: '0',
        message: 'Failed to fetch transactions',
        result: null
      }, { status: 500 });
    }
  • Token Holder API: Provides NFT transaction details linked to the address using the user account module with the token NFT transaction action.
const API_BASE_URL = 'https://eth.blockscout.com/api';

try {
    // Get NFT transactions with retry
    let nftResponse;
    try {
      nftResponse = await fetchWithRetry(API_BASE_URL, {
        module: 'account',
        action: 'tokennfttx',
        address: address
      });
    } catch (error: any) {
      console.error('NFT transactions fetch error:', error);
      return NextResponse.json({ 
        error: 'Failed to fetch NFT transactions',
        details: error.message
      }, { status: 500 });
    }

The base URL of these APIs changes depending on the blockchain network. For example, to query the Arbitrum network, the identifier ARB is used in the URL.


Resources

Feel free to explore, contribute, or build upon this foundation to create even more innovative blockchain applications!


Thanks for reading! If you enjoyed this project or want to see more Web3 tutorials, don’t forget to subscribe and stay tuned.

More from this blog

Erg

31 posts