Skip to content

Commit dbfba4d

Browse files
authored
Merge pull request #14 from helloissariel/main
[Crypto] add neo and solana document
2 parents 1de182c + 2bcb5ba commit dbfba4d

File tree

3 files changed

+512
-0
lines changed

3 files changed

+512
-0
lines changed

Toolkit/crypto/neo.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
2+
3+
`spoon_toolkits.crypto.neo` bundles async Neo N3 helpers on top of the `neo-mamba` RPC client, covering addresses, assets, blocks, governance, and smart-contract introspection. Every tool subclasses `BaseTool` so agents get consistent parameter validation and `ToolResult` payloads.
4+
5+
## Environment & Network Selection
6+
7+
```bash
8+
export NEO_MAINNET_RPC=https://mainmagnet.ngd.network:443 # overrides default mainnet RPC
9+
export NEO_TESTNET_RPC=https://testmagnet.ngd.network:443 # overrides default testnet RPC
10+
export NEO_RPC_TIMEOUT=20 # seconds
11+
export NEO_RPC_ALLOW_INSECURE=false # set true to skip TLS verification
12+
```
13+
14+
- Each tool accepts `network` (`"mainnet"` / `"testnet"`) so you can switch clusters per call. If you omit it, `NeoProvider` defaults to testnet.
15+
- The provider reuses a single `aiohttp` session with optional insecure mode—handy when you test against private RPC nodes.
16+
- Address inputs may be Base58 (e.g., `Nf2C...`) or `0x` script hashes; `NeoProvider` normalizes them internally before hitting RPCs.
17+
18+
## Toolkit Map
19+
20+
| Module | Highlights |
21+
| --- | --- |
22+
| `address_tools.py` | Counts, info lookups, NEP-17 transfer history, ad-hoc tagging across multiple addresses. |
23+
| `asset_tools.py` | Asset metadata by hash/name, portfolio snapshots per address, NEP-17/NEP-11 balance queries. |
24+
| `block_tools.py` | Block count, block-by-height/hash, best-hash, rewards, and rolling recent block summaries. |
25+
| `transaction_tools.py` | Transaction counts, raw tx retrieval (by hash or block), and transfer event extraction. |
26+
| `contract_tools.py` / `sc_call_tools.py` | Contract inventories, verified contract metadata, invoke history filtered by contract/address/tx. |
27+
| `nep_tools.py` | Specialized NEP-11/NEP-17 transfer feeds (by address, block height, contract hash) plus balance helpers. |
28+
| `governance_tools.py` / `voting_tools.py` | Committee info, candidate/voter tallies, on-chain vote call traces. |
29+
| `log_state_tools.py` | Application log/state fetchers for debugging contract execution. |
30+
| `neo_provider.py`, `base.py` | Shared provider, RPC request helpers, normalization utilities, and graceful fallbacks when neo-mamba lacks a direct method. |
31+
32+
## Usage Patterns
33+
34+
### Address intelligence
35+
```python
36+
from spoon_toolkits.crypto.neo import GetAddressInfoTool
37+
38+
tool = GetAddressInfoTool()
39+
result = await tool.execute(
40+
address="Nf2CXE8s1R6yoZ6e52xX5yb7Z9Uv7S3N1h",
41+
network="mainnet",
42+
)
43+
balances = result.output # includes NEP-17 balances + script hash
44+
```
45+
46+
### Asset metadata & balances
47+
```python
48+
from spoon_toolkits.crypto.neo import GetAssetInfoByHashTool, GetAssetsInfoByUserAddressTool
49+
50+
asset_info = await GetAssetInfoByHashTool().execute(
51+
asset_hash="0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5", # GAS
52+
network="mainnet",
53+
)
54+
55+
portfolio = await GetAssetsInfoByUserAddressTool().execute(
56+
address="Nf2CXE8s1R6yoZ6e52xX5yb7Z9Uv7S3N1h",
57+
network="mainnet",
58+
Limit=50,
59+
)
60+
```
61+
62+
### Block & transaction lookups
63+
```python
64+
from spoon_toolkits.crypto.neo import GetBlockByHeightTool, GetRawTransactionByHashTool
65+
66+
block = await GetBlockByHeightTool().execute(block_height=4500000, network="mainnet")
67+
tx = await GetRawTransactionByHashTool().execute(transaction_hash="0x...", network="mainnet")
68+
```
69+
70+
### Governance snapshots
71+
```python
72+
from spoon_toolkits.crypto.neo import GetCommitteeInfoTool, GetVotesByCandidateAddressTool
73+
74+
committee = await GetCommitteeInfoTool().execute(network="mainnet")
75+
votes = await GetVotesByCandidateAddressTool().execute(candidate_address="NVSX...", network="mainnet")
76+
```
77+
78+
## Operational Notes
79+
80+
- Some RPC extensions (e.g., `GetTagByAddresses`) are not fully implemented in `neo-mamba`. The toolkit surfaces shim behaviors or explanatory messages so agents fail gracefully; check `ToolResult.output` for strings such as “not available with current implementation”.
81+
- Long-running scans (e.g., iterating transfers) reuse `NeoProvider._make_request` with built-in retries governed by `NEO_RPC_TIMEOUT`. For heavy workflows, pool results externally rather than looping inside a single tool call.
82+
- Always `await` tool execution; the provider relies on async context managers to open/close RPC sessions cleanly. If you compose multiple calls, instantiate the tool once and re-use it to avoid repeated class construction overhead.

0 commit comments

Comments
 (0)