TON-Specific Integration
Localcredit is deeply integrated with the TON ecosystem, making it the fastest and most seamless environment for building Telegram Mini Apps and TON-native dApps. The JavaScript/TypeScript SDK automatically detects TON and uses TON Connect for wallet interactions, while on-chain queries use native TON smart contracts.1. Telegram Mini App Integration (Recommended Path)Use the same @localcredit/sdk-js package – it handles TON Connect automatically in Mini App environments.Installation (same as web)bash
npm install @localcredit/sdk-jsFull Example in a Telegram Mini Apptypescript
import { Localcredit } from '@localcredit/sdk-js';
import { TonConnectUIProvider, useTonConnectUI } from '@tonconnect/ui-react';
// Wrap your app with TonConnect provider (standard for TON Mini Apps)
function App() {
return (
<TonConnectUIProvider manifestUrl="https://yourapp.com/tonconnect-manifest.json">
<LocalcreditDashboard />
</TonConnectUIProvider>
);
}
function LocalcreditDashboard() {
const [tonConnectUI] = useTonConnectUI();
// Initialize Localcredit with optional pre-connected TON UI
const lc = new Localcredit({
apiKey: 'your_api_key',
tonConnectUI: tonConnectUI // passes existing connection
});
const handleCheckScore = async () => {
try {
const userProof = await lc.requestProof(); // uses connected TON wallet
const result = await lc.getScore(userProof);
alert(`Your Localcredit score: ${result.score}`);
// Update UI with result.riskTier, result.creditLimitUsd, etc.
} catch (error) {
if (error.code === 'NO_SCORE') {
// Redirect to official Localcredit Mini App for onboarding
await lc.redirectToOnboarding({
returnUrl: 'yourminiapp://return', // or use Telegram deep link
appId: 'your_lending_app'
});
}
}
};
return (
<button onClick={handleCheckScore}>
Check Localcredit Score
</button>
);
}The SDK detects the Telegram environment and uses native TON Connect modals for the best user experience.2. On-Chain Queries with TON Smart ContractsFor fully decentralized TON dApps, query scores directly via the Localcredit Oracle contract (written in FunC/Tact).Contract Interaction Example (using@ton/core and ton-contracts)typescript
3. Handling Callbacks (Score Fulfillment)Your contract receives the score via an incoming message from the oracle.Tact Pseudocode (receiver)tact
TON-Specific Benefits
Lowest fees: Queries cost fractions of a TON.
Native wallet experience: No external extensions needed – users stay inside Telegram.
Instant redirects: Deep linking to@LocalcreditBotis seamless.
Future Jetton support: Stake and pay fees directly with $CREDIT Jetton.
Last updated