Skip to content

Commit 426cc57

Browse files
authored
feat: [sc-26178] Create readme for NameAI SDK (#578)
* create readme for nameai-sdk; add license * extend response example
1 parent 8ff36d8 commit 426cc57

File tree

2 files changed

+148
-0
lines changed

2 files changed

+148
-0
lines changed

packages/nameai-sdk/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 NameHash
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

packages/nameai-sdk/README.md

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# NameAI SDK
2+
3+
![NPM Version](https://img.shields.io/npm/v/@namehash/nameai)
4+
5+
[NameAI](https://nameai.dev) extends [NameGuard](https://nameguard.io) with sophisticated natural language processing capabilities to help evaluate and understand Ethereum Name Service (ENS) names.
6+
7+
[NameGuard](https://nameguard.io) is designed to inspect and prevent malicious use of ENS names by providing comprehensive security checks. See the [NameGuard SDK documentation](../nameguard-sdk/README.md) for details about the base security features.
8+
9+
⚠️ **This SDK is BETA. Things will change based on the community feedback.**
10+
11+
## Features
12+
13+
Additional features provided by NameAI on top of NameGuard:
14+
- **Natural Language Processing**: Evaluate how well ENS names represent meaningful words or phrases
15+
- **Tokenization**: Break down names into meaningful word components with probability scoring
16+
- **Purity Scoring**: Assess the cleanliness and quality of ENS names
17+
- **Sort Scoring**: Get relative ranking scores for ENS names
18+
19+
The `@namehash/nameai` SDK provides full type-safety when working with the NameAI API.
20+
21+
## Install
22+
23+
Install NameAI via npm, yarn or pnpm:
24+
25+
```bash
26+
npm install @namehash/nameai
27+
```
28+
29+
## Usage
30+
31+
Import `nameai`:
32+
33+
```ts
34+
import { nameai } from "@namehash/nameai";
35+
```
36+
37+
### Basic Name Inspection
38+
39+
Inspect a name:
40+
41+
```ts
42+
const report = await nameai.inspectName("vitalik.eth");
43+
44+
// Example response:
45+
{
46+
nameai: {
47+
// Quality score (0.0 to 1.0) for the first label
48+
purity_score: 0.29,
49+
50+
// Ranking score (0.0 to 1.0) for the first label
51+
sort_score: 0.35,
52+
53+
analysis: { // undefined for uninspected names
54+
// The normalization status of the name (normalized, unnormalized, or unknown)
55+
status: "normalized",
56+
57+
// Details about the inspected name component
58+
inspection: {
59+
label: "vitalik",
60+
// ... other inspection details
61+
},
62+
63+
// Text meaningfulness (0.0 to 1.0)
64+
probability: 0.95,
65+
66+
// Natural log of probability (≤ 0.0)
67+
log_probability: -0.05,
68+
69+
// Minimum words in valid tokenizations
70+
word_count: 1,
71+
72+
// Recommended word breakdown (may be undefined)
73+
top_tokenization: ["vitalik"],
74+
75+
// All possible tokenizations (up to 1000)
76+
tokenizations: [
77+
{
78+
tokens: ["vitalik"],
79+
probability: 0.95,
80+
log_probability: -0.05
81+
}
82+
]
83+
}
84+
},
85+
nameguard: NameGuardReport // Standard NameGuard security inspection
86+
}
87+
```
88+
89+
### Tokenization Inspection
90+
91+
The SDK provides detailed tokenization inspection:
92+
93+
```ts
94+
const { nameai: { analysis } } = await nameai.inspectName("cryptowallet.eth");
95+
96+
console.log(analysis.top_tokenization); // ["crypto", "wallet"]
97+
console.log(analysis.tokenizations); // Array of possible tokenizations with probabilities
98+
```
99+
100+
### Custom Client
101+
102+
You can create a custom client with different settings:
103+
104+
```ts
105+
import { createClient } from "@namehash/nameai";
106+
107+
const nameai = createClient({
108+
nameaiEndpoint: "...",
109+
network: "sepolia"
110+
});
111+
```
112+
113+
## Limitations
114+
115+
- Maximum name length: 200 characters (including dots)
116+
- Maximum unknown labels: 5
117+
- Names exceeding these limits will have undefined analysis
118+
119+
## Contact Us
120+
121+
Visit our [website](https://namehashlabs.org/) to get in contact.
122+
123+
## License
124+
125+
Licensed under the MIT License, Copyright © 2023-present [NameHash Labs](https://namehashlabs.org).
126+
127+
See [LICENSE](./LICENSE) for more information.

0 commit comments

Comments
 (0)