Skip to content

Commit cec9177

Browse files
add sns support
1 parent d03177a commit cec9177

File tree

3 files changed

+91
-2
lines changed

3 files changed

+91
-2
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Solana Agent Kit provides a growing library of plugins that enhance your Solana
1616
* Solana Swap - Swap Solana tokens on Jupiter in the agent's wallet
1717
* Solana Balance - Get the token balances of a wallet
1818
* Solana Price - Get the price of a token
19+
* Solana SNS Lookup - Get the Solana address for a SNS domain
1920
* Rugcheck - Check if a token is a rug
2021
* Internet Search - Search the internet in real-time using Perplexity, Grok, or OpenAI
2122
* MCP - Interface with any MCP web server - Zapier is supported
@@ -93,6 +94,21 @@ config = {
9394
}
9495
```
9596

97+
### Solana SNS Lookup
98+
99+
This plugin enables Solana Agent to get the Solana address of an SNS domain.
100+
101+
```python
102+
config = {
103+
"tools": {
104+
"sns_lookup": {
105+
"quicknode_url": "my-quicknode-rpc-url", # Required - your QuickNode RPC URL with the SNS addon enabled
106+
},
107+
},
108+
}
109+
```
110+
111+
96112
### Rugcheck
97113

98114
This plugin enables Solana Agent to check if a token is a rug.

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "sakit"
3-
version = "12.2.0"
3+
version = "12.3.0"
44
description = "Solana Agent Kit"
55
authors = ["Bevan Hunt <bevan@bevanhunt.com>"]
66
license = "MIT"
@@ -20,7 +20,7 @@ solana-agent = ">=30.0.0"
2020
boto3 = "^1.38.32"
2121
botocore = "^1.38.32"
2222
nemo-agent = "5.0.3"
23-
fastmcp = "^2.7.0"
23+
fastmcp = "^2.7.1"
2424
solana = "^0.36.7"
2525
solders = "^0.26.0"
2626
pynacl = "^1.5.0"
@@ -45,3 +45,4 @@ privy_swap = "sakit.privy_swap:get_plugin"
4545
privy_transfer = "sakit.privy_transfer:get_plugin"
4646
privy_balance = "sakit.privy_balance:get_plugin"
4747
privy_wallet_address = "sakit.privy_wallet_address:get_plugin"
48+
sns_lookup = "sakit.sns_lookup:get_plugin"

sakit/sns_lookup.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
from typing import Dict, Any, List, Optional
2+
from solana_agent import AutoTool, ToolRegistry
3+
import httpx
4+
5+
class SnsLookupTool(AutoTool):
6+
def __init__(self, registry: Optional[ToolRegistry] = None):
7+
super().__init__(
8+
name="sns_lookup",
9+
description="Lookup SNS domain with a QuickNode RPC.",
10+
registry=registry,
11+
)
12+
self.quicknode_url = None
13+
14+
def get_schema(self) -> Dict[str, Any]:
15+
return {
16+
"type": "object",
17+
"properties": {
18+
"domain": {
19+
"type": "string",
20+
"description": "SNS domain to resolve, e.g. domain.sol",
21+
}
22+
},
23+
"required": ["domain"],
24+
"additionalProperties": False,
25+
}
26+
27+
def configure(self, config: Dict[str, Any]) -> None:
28+
super().configure(config)
29+
tool_cfg = config.get("tools", {}).get("sns_lookup", {})
30+
self.quicknode_url = tool_cfg.get("quicknode_url")
31+
32+
async def execute(self, domain: str) -> Dict[str, Any]:
33+
if not self.quicknode_url:
34+
return {"status": "error", "message": "No quicknode_url configured for SNS lookup."}
35+
payload = {
36+
"method": "sns_resolveDomain",
37+
"params": [domain],
38+
"id": 1,
39+
"jsonrpc": "2.0",
40+
}
41+
headers = {"Content-Type": "application/json"}
42+
async with httpx.AsyncClient() as client:
43+
resp = await client.post(self.quicknode_url, json=payload, headers=headers)
44+
resp.raise_for_status()
45+
data = resp.json()
46+
return {"status": "success", "result": data}
47+
48+
class SnsLookupPlugin:
49+
def __init__(self):
50+
self.name = "sns_lookup"
51+
self.config = None
52+
self.tool_registry = None
53+
self._tool = None
54+
55+
@property
56+
def description(self):
57+
return "Plugin for resolving SNS domains using a QuickNode endpoint."
58+
59+
def initialize(self, tool_registry: ToolRegistry) -> None:
60+
self.tool_registry = tool_registry
61+
self._tool = SnsLookupTool(registry=tool_registry)
62+
63+
def configure(self, config: Dict[str, Any]) -> None:
64+
self.config = config
65+
if self._tool:
66+
self._tool.configure(self.config)
67+
68+
def get_tools(self) -> List[AutoTool]:
69+
return [self._tool] if self._tool else []
70+
71+
def get_plugin():
72+
return SnsLookupPlugin()

0 commit comments

Comments
 (0)