# Quick Start (SDK)

The Somnia SDK lets you resolve `.som` names using just one function. It works anywhere you can use TypeScript or JavaScript.

***

### 📁 1. Copy the SDK file

Add this file to your project:

```typescript
lib/sds.ts
```

#### sds.ts content:

```typescript
import { ethers } from "ethers";

const RPC_URL = "https://dream-rpc.somnia.network";
const CONTRACT_ADDRESS = "0xDB4e0A5E7b0d03aA41cBB7940c5e9Bab06cc7157";
const CONTRACT_ABI = [
  {
    inputs: [{ internalType: "address", name: "owner", type: "address" }],
    name: "reverseLookup",
    outputs: [{ internalType: "string", name: "", type: "string" }],
    stateMutability: "view",
    type: "function"
  }
];

const provider = new ethers.JsonRpcProvider(RPC_URL);
const contract = new ethers.Contract(CONTRACT_ADDRESS, CONTRACT_ABI, provider);

export async function getPrimarySomName(walletAddress: string): Promise<string | null> {
  try {
    const name = await contract.reverseLookup(walletAddress);
    return name;
  } catch (err) {
    console.error("Somnia name lookup failed:", err);
    return null;
  }
}
```

### 💻 2. Usage

Anywhere in your app:

```typescript
import { getPrimarySomName } from "./lib/sds";

const somniaName = await getPrimarySomName("0x1234...abcd"); // Or the string wallet address variable of the wallet API you are using 
console.log(somniaName); // "test.som" or null
```

### 🔄 Use Case

Display `.som` names instead of addresses:

```typescript
const label = somniaName || walletAddress;
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://somnia-domain-services.gitbook.io/somnia-domain-services/for-developers/publish-your-docs.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
