> ## Documentation Index
> Fetch the complete documentation index at: https://blackswan-23965643.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# All BlackSwan JavaScript SDK Methods and Return Types

> Full reference for all BlackSwanClient methods: getCreditDashboard, getTrustRatio, getCurrentApr, getReputation, getCreditHistory, and more.

Once you have a configured `BlackSwanClient` instance, you can call any of the methods below to read on-chain credit data for a given wallet address. All methods are asynchronous and return promises, so you can use them with `await` or chain `.then()` callbacks.

***

## `hasSoulboundToken(wallet)`

```ts theme={null}
hasSoulboundToken(wallet: string): Promise<boolean>
```

Returns `true` if the wallet holds a BlackSwan Soulbound Token (SBT), which is minted when a borrower takes their first loan. Use this to gate UI flows or API responses that only make sense for active borrowers.

```ts theme={null}
const hasSBT = await client.hasSoulboundToken("0x...");

if (hasSBT) {
  // wallet has an on-chain credit history
}
```

***

## `getCreditDashboard(wallet)`

```ts theme={null}
getCreditDashboard(wallet: string): Promise<CreditDashboard>
```

Returns the complete on-chain credit profile for a wallet in a single call. This is the most comprehensive method — use it when you need to display a full credit summary.

| Property         | Type   | Description                        |
| ---------------- | ------ | ---------------------------------- |
| trustRatio       | number | Trust score from 0 to 10,000       |
| trustTierScore   | string | Tier letter from A (best) to E     |
| currentApr       | number | APR in basis points                |
| totalBorrowedUsd | string | Total USD value borrowed           |
| totalRepaidUsd   | string | Total USD value repaid             |
| successfulLoans  | number | Count of loans repaid successfully |
| defaults         | number | Count of defaulted loans           |

```ts theme={null}
import { BlackSwanClient } from "blackswan-sdk";

const client = new BlackSwanClient({
  network: "amoy",
  rpcUrl: process.env.NEXT_PUBLIC_RPC_URL
});

const dashboard = await client.getCreditDashboard("0x...");

console.log(`Trust Ratio: ${dashboard.trustRatio}`);
console.log(`Tier: ${dashboard.trustTierScore}`);
console.log(`APR: ${dashboard.currentApr / 1000}%`);
console.log(`Borrowed: $${dashboard.totalBorrowedUsd}`);
console.log(`Repaid: $${dashboard.totalRepaidUsd}`);
console.log(`Successful loans: ${dashboard.successfulLoans}`);
console.log(`Defaults: ${dashboard.defaults}`);
```

***

## `getReputation(wallet)`

```ts theme={null}
getReputation(wallet: string): Promise<{ repaidVolume: number; loans: number; trustRatio: number }>
```

Returns a concise reputation summary: total repaid volume, number of loans, and the current trust ratio.

```ts theme={null}
const reputation = await client.getReputation("0x...");

console.log(`Repaid volume: ${reputation.repaidVolume}`);
console.log(`Total loans: ${reputation.loans}`);
console.log(`Trust ratio: ${reputation.trustRatio}`);
```

***

## `getCurrentApr(wallet)`

```ts theme={null}
getCurrentApr(wallet: string): Promise<number>
```

Returns the wallet's current APR expressed in basis points. Divide by `1000` to convert to a human-readable percentage.

```ts theme={null}
const aprBasisPoints = await client.getCurrentApr("0x...");
const aprPercent = aprBasisPoints / 1000;

console.log(`Current APR: ${aprPercent}%`);
```

***

## `getTrustTier(wallet)`

```ts theme={null}
getTrustTier(wallet: string): Promise<string>
```

Returns the wallet's trust tier as a single letter from `A` (highest) to `E` (lowest). Use this to display a quick at-a-glance rating.

```ts theme={null}
const tier = await client.getTrustTier("0x...");

console.log(`Trust tier: ${tier}`); // e.g. "A"
```

***

## `getTrustRatio(wallet)`

```ts theme={null}
getTrustRatio(wallet: string): Promise<number>
```

Returns the raw trust score as an integer between `0` and `10,000`. Higher values indicate a stronger on-chain credit history.

```ts theme={null}
const trustRatio = await client.getTrustRatio("0x...");

console.log(`Trust ratio: ${trustRatio} / 10000`);
```

***

## `getCreditHistory(wallet)`

```ts theme={null}
getCreditHistory(wallet: string): Promise<{ totalLoans: number; successfulLoans: number; defaults: number }>
```

Returns a breakdown of the wallet's loan history: total loans taken, loans repaid on time, and defaults.

```ts theme={null}
const history = await client.getCreditHistory("0x...");

console.log(`Total loans: ${history.totalLoans}`);
console.log(`Successful: ${history.successfulLoans}`);
console.log(`Defaults: ${history.defaults}`);
```

***

## `getCurrentRisk(wallet)`

```ts theme={null}
getCurrentRisk(wallet: string): Promise<number>
```

Returns the wallet's current risk score. Higher values indicate greater credit risk.

```ts theme={null}
const risk = await client.getCurrentRisk("0x...");

console.log(`Risk score: ${risk}`);
```

***

## Error handling

All `BlackSwanClient` methods throw if the RPC call fails, the wallet address is invalid, or the on-chain data cannot be decoded. Wrap calls in a `try/catch` block to handle errors gracefully.

```ts theme={null}
import { BlackSwanClient } from "blackswan-sdk";

const client = new BlackSwanClient({
  network: "amoy",
  rpcUrl: process.env.NEXT_PUBLIC_RPC_URL
});

try {
  const dashboard = await client.getCreditDashboard("0x...");
  console.log(dashboard);
} catch (err: any) {
  console.error("Failed to fetch credit dashboard:", err.message);
}
```
