Integration Flow Examples

Integrating Localcredit into your application is straightforward and flexible. Below are common real-world flows with step-by-step explanations and code snippets to help you get started quickly.Flow 1: Basic Score Check During Loan Application (Most Common)Your lending app wants to fetch a user's Localcredit score when they apply for a loan and adjust terms accordingly.

  1. User taps "Apply for Loan" in your app.

  2. Prompt user to connect their Localcredit identity (wallet signature to share ZK proof).

  3. Query the Localcredit API with the proof.

  4. Receive score, risk tier, and estimated limit.

  5. Adjust loan terms (rate, amount, collateral requirement) based on the result.

JavaScript/TypeScript Example (Web or Telegram Mini App)typescript

import { Localcredit } from '@localcredit/sdk-js';

const lc = new Localcredit({ apiKey: 'your_api_key' });

// After user signs proof with wallet
const userProof = await wallet.signMessage('Share Localcredit proof');

try {
  const result = await lc.getScore(userProof);
  console.log('Score:', result.score);           // e.g., 82
  console.log('Risk Tier:', result.riskTier);    // 'Low'
  console.log('Est. Limit:', result.creditLimitUsd); // 5200

  // Adjust your loan logic
  if (result.score >= 80) {
    offerUnsecuredLoan();
  } else if (result.score >= 60) {
    offerReducedCollateral();
  } else {
    requireFullCollateral();
  }
} catch (error) {
  handleNoScoreOrError();
}

Flow 2: Handling New Users (Seamless Redirect & Return)

A user has no Localcredit score yet. Redirect them to complete onboarding and return automatically.

  1. Query score → returns null or low default.

  2. Show prompt: "Boost your approval odds – create your Localcredit score (takes 2 mins)".

  3. Deep-link to Localcredit Mini App with return parameters.

  4. User completes onboarding in Localcredit.

  5. Localcredit closes and returns control with fresh proof.

  6. Your app auto-queries the new score.

Deep Link Example

On return, listen for the proof and re-query immediately.

Flow 3: On-Chain Score Query (Gas-Efficient DeFi Protocols)For smart contract-based lending on TON or EVM.

  1. User submits proof (bytes) to your contract.

  2. Contract calls LocalcreditOracle.

  3. Oracle fulfills with verified score.

  4. Contract logic uses score for borrowing power.

Solidity Example (EVM version)solidity

Flow 4: Reporting Loan Outcomes (Contribute to Model)After a loan completes, report the result to improve the shared scoring model.typescript

Reporting is optional but helps strengthen the entire ecosystem (and may qualify for future incentives).

Flow 5: Displaying a Consolidated DashboardShow Localcredit data alongside your app's information.

  • Fetch score and breakdown.

  • Display side-by-side with user’s loans, balances, or activity in your UI.

  • Refresh periodically or on user action.

These flows cover 90% of integrations. Choose the one that matches your product type (web app, Mini App, smart contract) and combine as needed.Full code samples and interactive playground available at docs.localcredit.org/integration-examples. Start small with a basic score check and expand as your product grows. Localcredit is built to scale with you.

Last updated