stellarskills 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/skills/stellar-expert.md +36 -0
- package/README.md +150 -0
- package/SKILL.md +143 -0
- package/accounts/SKILL.md +275 -0
- package/anchors/SKILL.md +116 -0
- package/assets/SKILL.md +290 -0
- package/bin/cli.js +496 -0
- package/dex/SKILL.md +170 -0
- package/fees/SKILL.md +149 -0
- package/frontend/SKILL.md +169 -0
- package/horizon/SKILL.md +411 -0
- package/local-node/SKILL.md +125 -0
- package/openzeppelin/SKILL.md +76 -0
- package/operations/SKILL.md +260 -0
- package/package.json +35 -0
- package/rpc/SKILL.md +222 -0
- package/security/SKILL.md +184 -0
- package/seps/SKILL.md +384 -0
- package/soroban/SKILL.md +343 -0
- package/storage/SKILL.md +141 -0
- package/testing/SKILL.md +218 -0
- package/tools/SKILL.md +112 -0
- package/why/SKILL.md +73 -0
- package/x402/SKILL.md +99 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Stellar Expert Knowledge Base
|
|
2
|
+
|
|
3
|
+
When the user asks you to build, debug, or understand anything related to the **Stellar Network** or **Soroban Smart Contracts**, you MUST consult the `stellarskills` CLI.
|
|
4
|
+
|
|
5
|
+
**StellarSkills** is a high-signal, noise-free knowledge base engineered specifically for AI agents to prevent hallucinations.
|
|
6
|
+
|
|
7
|
+
To fetch knowledge on a specific topic, run the following command in your terminal:
|
|
8
|
+
`npx stellarskills get <topic>`
|
|
9
|
+
|
|
10
|
+
If you are unsure which topic to fetch, run:
|
|
11
|
+
`npx stellarskills list`
|
|
12
|
+
|
|
13
|
+
### Common Topics:
|
|
14
|
+
- `soroban`: Smart contracts, architecture
|
|
15
|
+
- `storage`: Soroban persistent and temporary storage, TTL
|
|
16
|
+
- `accounts`: Minimum balances, keypairs
|
|
17
|
+
- `assets`: Trustlines, custom tokens
|
|
18
|
+
- `dex`: Built-in DEX and AMM
|
|
19
|
+
- `horizon`: REST API
|
|
20
|
+
- `rpc`: Soroban JSON-RPC
|
|
21
|
+
- `seps`: Ecosystem standards (SEP-10, SEP-24, etc)
|
|
22
|
+
- `tools`: SDKs, wallets, CLI
|
|
23
|
+
- `local-node`: Local Quickstart Docker, local RPC
|
|
24
|
+
- `testing`: Testing and testnet deployment
|
|
25
|
+
- `security`: Security patterns
|
|
26
|
+
- `frontend`: Wallets connection and UI
|
|
27
|
+
- `openzeppelin`: Audited contracts
|
|
28
|
+
- `x402`: Agent Economy standards
|
|
29
|
+
|
|
30
|
+
### Example Workflow
|
|
31
|
+
If the user asks "How do I create a Soroban smart contract?":
|
|
32
|
+
1. Run `npx stellarskills get soroban` to read the base contract architecture.
|
|
33
|
+
2. If the user asks about testing, run `npx stellarskills get testing`.
|
|
34
|
+
3. If the user asks about deploying, run `npx stellarskills get rpc` and `npx stellarskills get tools`.
|
|
35
|
+
|
|
36
|
+
**Do not guess Stellar syntax or APIs. Always use the CLI to fetch the latest knowledge first.**
|
package/README.md
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# STELLARSKILLS 🚀
|
|
2
|
+
|
|
3
|
+
> High-signal, noise-free Stellar Network knowledge engineered specifically for AI agents. Fetch any skill URL and instantly equip your agent to build production-ready applications on Stellar.
|
|
4
|
+
|
|
5
|
+
**StellarSkills Repository** • MIT License
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 🤖 The Problem
|
|
10
|
+
|
|
11
|
+
AI agents (like Claude, ChatGPT, Cursor, or Copilot) often hallucinate when asked to build on Stellar. They mix up classic Stellar protocol with EVM concepts, invent non-existent RPC methods, or struggle with the nuances of Soroban smart contracts.
|
|
12
|
+
|
|
13
|
+
Traditional documentation is built for humans: it has sidebars, infinite scrolling, navigation menus, and conversational fluff. When an agent reads it via a web scraper, it gets confused by the noise.
|
|
14
|
+
|
|
15
|
+
## 💡 The Solution
|
|
16
|
+
|
|
17
|
+
**Stellarskills** provides pure, unadulterated Markdown.
|
|
18
|
+
|
|
19
|
+
Every skill is a single `.md` file. No HTML, no sidebars, no fluff. Just the facts, the code, the architectural mental models, and the common errors.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## ⚡ Usage
|
|
24
|
+
|
|
25
|
+
Give any AI agent a skill URL in your prompt. The agent will fetch the raw Markdown, ingest the context, and instantly know how to build.
|
|
26
|
+
|
|
27
|
+
**Prompt example:**
|
|
28
|
+
```text
|
|
29
|
+
Read https://raw.githubusercontent.com/ggoldani/stellarskills/main/SKILL.md to understand the ecosystem, then read https://raw.githubusercontent.com/ggoldani/stellarskills/main/soroban/SKILL.md and write a smart contract that acts as a decentralized autonomous organization.
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**cURL it yourself:**
|
|
33
|
+
```bash
|
|
34
|
+
curl -s https://raw.githubusercontent.com/ggoldani/stellarskills/main/SKILL.md
|
|
35
|
+
curl -s https://raw.githubusercontent.com/ggoldani/stellarskills/main/accounts/SKILL.md
|
|
36
|
+
curl -s https://raw.githubusercontent.com/ggoldani/stellarskills/main/soroban/SKILL.md
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**Use the CLI:**
|
|
40
|
+
The `stellarskills` CLI lets you quickly find, read, or grab the URL for any skill directly from your terminal.
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# List all available skills
|
|
44
|
+
npx stellarskills list
|
|
45
|
+
|
|
46
|
+
# Print the raw markdown content of a skill
|
|
47
|
+
npx stellarskills get soroban
|
|
48
|
+
|
|
49
|
+
# Pipe it straight into a prompt file
|
|
50
|
+
npx stellarskills get soroban > prompt.txt
|
|
51
|
+
|
|
52
|
+
# Get just the raw GitHub URL
|
|
53
|
+
npx stellarskills url accounts
|
|
54
|
+
|
|
55
|
+
# Combine multiple skills into a single prompt context
|
|
56
|
+
npx stellarskills combine accounts soroban security > prompt.txt
|
|
57
|
+
|
|
58
|
+
# Find which domain contains a specific concept
|
|
59
|
+
npx stellarskills search "trustline"
|
|
60
|
+
|
|
61
|
+
# Copy raw markdown to your system clipboard (ready to paste into ChatGPT/Claude)
|
|
62
|
+
npx stellarskills copy soroban security
|
|
63
|
+
|
|
64
|
+
# Instantly embed knowledge into your IDE agent (.cursorrules, .clinerules, .windsurfrules)
|
|
65
|
+
npx stellarskills rules cursor accounts
|
|
66
|
+
npx stellarskills rules cline dex assets
|
|
67
|
+
|
|
68
|
+
# Output a full Markdown index so an AI agent can self-discover what to fetch next
|
|
69
|
+
npx stellarskills index
|
|
70
|
+
|
|
71
|
+
# Diagnose your environment (Stellar CLI, Rust, wasm32 target, Node) to prevent agent hallucinations
|
|
72
|
+
npx stellarskills doctor
|
|
73
|
+
|
|
74
|
+
# Generate the ultimate System Prompt for ChatGPT/Claude containing expert rules + knowledge
|
|
75
|
+
npx stellarskills system soroban dex --instruction "Write an AMM pool contract" > prompt.txt
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Works seamlessly in Cursor, Copilot, Cline, Devin, or any agentic framework that can resolve HTTP URLs.
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## 🔌 Agent Marketplace Plugins
|
|
83
|
+
|
|
84
|
+
Stellarskills is natively structured to be installed as a dynamic skill in various AI agent ecosystems.
|
|
85
|
+
|
|
86
|
+
**For Claude Code:**
|
|
87
|
+
Teach your Claude Code agent to use the Stellarskills CLI automatically by installing our repository plugin:
|
|
88
|
+
```bash
|
|
89
|
+
claude plugin install https://github.com/ggoldani/stellarskills
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
**For OpenClaw / ClawHub:**
|
|
93
|
+
Every skill directory in this repository is a valid, independently installable AgentSkill. You can install the entire knowledge base into your OpenClaw agent by running:
|
|
94
|
+
```bash
|
|
95
|
+
clawhub install stellarskills
|
|
96
|
+
```
|
|
97
|
+
*(Or install granular skills: `clawhub install stellarskills-soroban`)*
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## 📚 The Skill Index
|
|
102
|
+
|
|
103
|
+
| Skill Domain | URL | Description |
|
|
104
|
+
|--------------|-----|-------------|
|
|
105
|
+
| **Root Index** | [`/SKILL.md`](https://raw.githubusercontent.com/ggoldani/stellarskills/main/SKILL.md) | The missing knowledge between AI agents and production Stellar Network applications. |
|
|
106
|
+
| **Accounts** | [`/accounts/SKILL.md`](https://raw.githubusercontent.com/ggoldani/stellarskills/main/accounts/SKILL.md) | Keypairs, account creation, signers, multisig, minimum balance, sponsorship, muxed accounts. |
|
|
107
|
+
| **Anchors** | [`/anchors/SKILL.md`](https://raw.githubusercontent.com/ggoldani/stellarskills/main/anchors/SKILL.md) | Fiat on/off-ramps on Stellar. Integration flows, stellar.toml, and the anchor ecosystem. |
|
|
108
|
+
| **Assets** | [`/assets/SKILL.md`](https://raw.githubusercontent.com/ggoldani/stellarskills/main/assets/SKILL.md) | Custom asset issuance, trustlines, asset types, Stellar Asset Contract (SAC), USDC and stablecoins. |
|
|
109
|
+
| **DEX & AMM** | [`/dex/SKILL.md`](https://raw.githubusercontent.com/ggoldani/stellarskills/main/dex/SKILL.md) | Stellar's built-in order book, Automated Market Makers (AMM), Liquidity Pools, and Path Payments. |
|
|
110
|
+
| **Fees** | [`/fees/SKILL.md`](https://raw.githubusercontent.com/ggoldani/stellarskills/main/fees/SKILL.md) | Stellar transaction fees, base fee, surge pricing, resource fees (Soroban), and fee bumps. |
|
|
111
|
+
| **Frontend** | [`/frontend/SKILL.md`](https://raw.githubusercontent.com/ggoldani/stellarskills/main/frontend/SKILL.md) | Connecting web apps to Stellar. Stellar Wallets Kit, Freighter API, signing Soroban transactions, and secure SEP-10 Web3 Auth. |
|
|
112
|
+
| **Horizon API** | [`/horizon/SKILL.md`](https://raw.githubusercontent.com/ggoldani/stellarskills/main/horizon/SKILL.md) | Stellar's REST API for accounts, transactions, operations, effects, order books, streaming. Not for Soroban — see /rpc/SKILL.md for smart contracts. |
|
|
113
|
+
| **Local Node** | [`/local-node/SKILL.md`](https://raw.githubusercontent.com/ggoldani/stellarskills/main/local-node/SKILL.md) | How to run a local Stellar blockchain, RPC, and Friendbot. The Stellar equivalent of Hardhat Node or Anvil. |
|
|
114
|
+
| **OpenZeppelin** | [`/openzeppelin/SKILL.md`](https://raw.githubusercontent.com/ggoldani/stellarskills/main/openzeppelin/SKILL.md) | OpenZeppelin's audited smart contracts, Contract Wizard, and developer toolings for Stellar's Soroban (Rust) environment. |
|
|
115
|
+
| **Operations** | [`/operations/SKILL.md`](https://raw.githubusercontent.com/ggoldani/stellarskills/main/operations/SKILL.md) | Reference for all Stellar transaction operations. Payments, account management, offers, trustlines. |
|
|
116
|
+
| **Soroban RPC** | [`/rpc/SKILL.md`](https://raw.githubusercontent.com/ggoldani/stellarskills/main/rpc/SKILL.md) | Soroban's JSON-RPC API for smart contracts. Simulation, invocation, fetching ledger state, and getting events. |
|
|
117
|
+
| **Security** | [`/security/SKILL.md`](https://raw.githubusercontent.com/ggoldani/stellarskills/main/security/SKILL.md) | Critical security patterns, common vulnerabilities, and best practices for writing Soroban smart contracts in Rust. |
|
|
118
|
+
| **SEPs** | [`/seps/SKILL.md`](https://raw.githubusercontent.com/ggoldani/stellarskills/main/seps/SKILL.md) | SEP-1 (stellar.toml), SEP-6, SEP-10 (auth), SEP-12 (KYC), SEP-24, SEP-31, SEP-38 — the interoperability standards that power Stellar's payment rails. |
|
|
119
|
+
| **Soroban** | [`/soroban/SKILL.md`](https://raw.githubusercontent.com/ggoldani/stellarskills/main/soroban/SKILL.md) | Stellar's smart contract platform. Rust/WASM contracts, storage types, auth, invocation, resource limits. |
|
|
120
|
+
| **Storage** | [`/storage/SKILL.md`](https://raw.githubusercontent.com/ggoldani/stellarskills/main/storage/SKILL.md) | How to manage state in Soroban. Understanding Persistent, Temporary, and Instance storage, TTL/Rent, and migrating from Solidity mappings. |
|
|
121
|
+
| **Testing** | [`/testing/SKILL.md`](https://raw.githubusercontent.com/ggoldani/stellarskills/main/testing/SKILL.md) | How to test Soroban smart contracts using Rust's built-in testing framework and the Stellar CLI. |
|
|
122
|
+
| **Tools** | [`/tools/SKILL.md`](https://raw.githubusercontent.com/ggoldani/stellarskills/main/tools/SKILL.md) | The essential tools, SDKs, wallets, and explorers for building on Stellar. |
|
|
123
|
+
| **Why Stellar?** | [`/why/SKILL.md`](https://raw.githubusercontent.com/ggoldani/stellarskills/main/why/SKILL.md) | A sober, honest assessment of what Stellar is for, its tradeoffs, and why you would choose it over EVM or Solana. |
|
|
124
|
+
| **x402** | [`/x402/SKILL.md`](https://raw.githubusercontent.com/ggoldani/stellarskills/main/x402/SKILL.md) | Pay-per-API calls for AI Agents on Stellar. Monetize endpoints natively without subscriptions or credit cards using HTTP 402. |
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## 🤝 Contributing
|
|
129
|
+
|
|
130
|
+
We want this to be the single source of truth for AI agents building on Stellar. Is an agent consistently failing at a specific task? Did a Soroban RPC endpoint change? Open a PR!
|
|
131
|
+
|
|
132
|
+
### Automated Publishing
|
|
133
|
+
This repository uses GitHub Actions to automatically publish updates to NPM.
|
|
134
|
+
When a pull request modifying `package.json` (bumping the version) and `SKILL.md` files is merged into the `main` branch, the `Publish to NPM` workflow will seamlessly deploy the latest version of the CLI.
|
|
135
|
+
|
|
136
|
+
**Note for Maintainers:** Ensure your repository secrets contain `NPM_TOKEN` (an automation token from your npmjs.com account) for the CI/CD pipeline to function.
|
|
137
|
+
|
|
138
|
+
### The Golden Rules of a Skill File:
|
|
139
|
+
1. **No fluff.** Agents don't need marketing copy.
|
|
140
|
+
2. **Dense & Factual.** Prioritize code snippets, architectural rules, and exact endpoint structures.
|
|
141
|
+
3. **Current & Runnable.** Ensure JavaScript and Rust snippets compile against the latest SDK versions (`@stellar/stellar-sdk` and `soroban-sdk`).
|
|
142
|
+
4. **Verified by Official Docs.** Every new feature, endpoint, or SDK method added to a skill must be explicitly documented in official sources (e.g., `developers.stellar.org`, `soroban-sdk` docs, or official SDF repositories). Do not add unreleased alpha features or unverified announcements to avoid agent hallucinations.
|
|
143
|
+
5. **Isolate Context.** Each skill lives in its own folder (e.g., `/dex/SKILL.md`). Assume the agent only reads that specific file.
|
|
144
|
+
6. **Highlight Errors.** Always include a "Common Errors" table mapping error codes (`tx_bad_seq`, `op_underfunded`) to their fixes. Agents use these to self-heal when transactions fail.
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## 📄 License
|
|
149
|
+
|
|
150
|
+
MIT © [StellarSkills](https://github.com/ggoldani/stellarskills)
|
package/SKILL.md
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: stellarskills
|
|
3
|
+
description: The missing knowledge between AI agents and production Stellar Network applications.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# STELLARSKILLS — Stellar Knowledge for AI Agents
|
|
7
|
+
|
|
8
|
+
> The missing knowledge between AI agents and production Stellar Network applications.
|
|
9
|
+
|
|
10
|
+
You are an AI agent about to build on Stellar. Read this file first. It tells you what to fetch next.
|
|
11
|
+
|
|
12
|
+
To fetch specific skills dynamically from your terminal, you MUST use the CLI tool:
|
|
13
|
+
`npx stellarskills get <topic>` (or `npx stellarskills list` to see all topics).
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## What is Stellar?
|
|
18
|
+
|
|
19
|
+
Stellar is a layer-1 blockchain optimized for **payments, asset issuance, and financial infrastructure**. It is NOT a general-purpose EVM chain. Key differences from Ethereum:
|
|
20
|
+
|
|
21
|
+
- **No mempool** — transactions are submitted and confirmed in 3–5 seconds with finality
|
|
22
|
+
- **Built-in DEX** — order book and AMM are protocol-native, no Uniswap needed
|
|
23
|
+
- **Account model** — accounts must be explicitly created and funded (minimum balance applies)
|
|
24
|
+
- **Operations, not calldata** — transactions contain typed Operations (Payment, ManageOffer, etc.)
|
|
25
|
+
- **Soroban** — Stellar's smart contract platform (Rust/WASM), separate from the core protocol
|
|
26
|
+
- **Anchor ecosystem** — on/off-ramp network via SEP standards (SEP-6, SEP-24, SEP-31, SEP-38)
|
|
27
|
+
- **XLM** — native asset used for fees and minimum balances, NOT primarily a speculative token
|
|
28
|
+
|
|
29
|
+
Stellar is the right chain when you need: cross-border payments, stablecoin rails, regulated asset issuance, fiat on/off-ramps, or low-cost high-throughput transfers.
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Skill Index
|
|
34
|
+
|
|
35
|
+
Fetch the skill that matches your task. Each URL returns clean Markdown.
|
|
36
|
+
|
|
37
|
+
### Core Protocol
|
|
38
|
+
| Task | Fetch |
|
|
39
|
+
|------|-------|
|
|
40
|
+
| Understanding accounts, keypairs, signers, sponsorship | `raw.githubusercontent.com/ggoldani/stellarskills/main/accounts/SKILL.md` |
|
|
41
|
+
| Issuing assets, trustlines, custom tokens, SAC | `raw.githubusercontent.com/ggoldani/stellarskills/main/assets/SKILL.md` |
|
|
42
|
+
| All transaction operations (Payment, ManageBuyOffer, etc.) | `raw.githubusercontent.com/ggoldani/stellarskills/main/operations/SKILL.md` |
|
|
43
|
+
| Fees, base fee, resource fees, fee bump | `raw.githubusercontent.com/ggoldani/stellarskills/main/fees/SKILL.md` |
|
|
44
|
+
| Built-in DEX, AMM, path payments, liquidity pools | `raw.githubusercontent.com/ggoldani/stellarskills/main/dex/SKILL.md` |
|
|
45
|
+
|
|
46
|
+
### Data & APIs
|
|
47
|
+
| Task | Fetch |
|
|
48
|
+
|------|-------|
|
|
49
|
+
| Horizon REST API — accounts, transactions, effects, streaming | `raw.githubusercontent.com/ggoldani/stellarskills/main/horizon/SKILL.md` |
|
|
50
|
+
| Soroban RPC — simulate, send, getLedger, getTransaction | `raw.githubusercontent.com/ggoldani/stellarskills/main/rpc/SKILL.md` |
|
|
51
|
+
|
|
52
|
+
### Smart Contracts
|
|
53
|
+
| Task | Fetch |
|
|
54
|
+
|------|-------|
|
|
55
|
+
| Soroban smart contracts (Rust/WASM) | `raw.githubusercontent.com/ggoldani/stellarskills/main/soroban/SKILL.md` |
|
|
56
|
+
| Soroban security patterns, auth, reentrancy | `raw.githubusercontent.com/ggoldani/stellarskills/main/security/SKILL.md` |
|
|
57
|
+
| Testing Soroban contracts, Stellar CLI, testnet | `raw.githubusercontent.com/ggoldani/stellarskills/main/testing/SKILL.md` |
|
|
58
|
+
|
|
59
|
+
### Payments & Anchors
|
|
60
|
+
| Task | Fetch |
|
|
61
|
+
|------|-------|
|
|
62
|
+
| SEP standards — SEP-6, SEP-10, SEP-24, SEP-31, SEP-38 | `raw.githubusercontent.com/ggoldani/stellarskills/main/seps/SKILL.md` |
|
|
63
|
+
| Anchor ecosystem, stellar.toml, on/off-ramp integration | `raw.githubusercontent.com/ggoldani/stellarskills/main/anchors/SKILL.md` |
|
|
64
|
+
|
|
65
|
+
### Tooling & Frontend
|
|
66
|
+
| Task | Fetch |
|
|
67
|
+
|------|-------|
|
|
68
|
+
| SDKs, wallets, explorers, Stellar Lab, CLI | `raw.githubusercontent.com/ggoldani/stellarskills/main/tools/SKILL.md` |
|
|
69
|
+
| Frontend integration — Freighter, SEP-10 auth, browser SDK | `raw.githubusercontent.com/ggoldani/stellarskills/main/frontend/SKILL.md` |
|
|
70
|
+
| OpenZeppelin audited contracts, SDKs, and Contract Wizard | `raw.githubusercontent.com/ggoldani/stellarskills/main/openzeppelin/SKILL.md` |
|
|
71
|
+
|
|
72
|
+
### Context
|
|
73
|
+
| Task | Fetch |
|
|
74
|
+
|------|-------|
|
|
75
|
+
| Why Stellar — use cases, honest tradeoffs, ecosystem | `raw.githubusercontent.com/ggoldani/stellarskills/main/why/SKILL.md` |
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## Quick Start for Agents
|
|
80
|
+
|
|
81
|
+
### Build a payment app
|
|
82
|
+
1. Fetch `/accounts/SKILL.md` — understand account creation and minimum balance
|
|
83
|
+
2. Fetch `/assets/SKILL.md` — understand trustlines if using non-XLM assets
|
|
84
|
+
3. Fetch `/horizon/SKILL.md` — submit transactions and read state
|
|
85
|
+
4. Fetch `/seps/SKILL.md` — if connecting to fiat on/off-ramps
|
|
86
|
+
|
|
87
|
+
### Build a Soroban smart contract
|
|
88
|
+
1. Fetch `/soroban/SKILL.md` — contract structure, storage, invocation
|
|
89
|
+
2. Fetch `/rpc/SKILL.md` — simulate and send contract calls
|
|
90
|
+
3. Fetch `/testing/SKILL.md` — test and deploy with Stellar CLI
|
|
91
|
+
4. Fetch `/security/SKILL.md` — before any deployment
|
|
92
|
+
|
|
93
|
+
### Integrate an anchor (fiat on/off-ramp)
|
|
94
|
+
1. Fetch `/anchors/SKILL.md` — TOML discovery, anchor types
|
|
95
|
+
2. Fetch `/seps/SKILL.md` — SEP-10 auth + SEP-6/24/31 flows
|
|
96
|
+
3. Fetch `/assets/SKILL.md` — trustlines required before receiving anchor assets
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## Critical Mental Models
|
|
101
|
+
|
|
102
|
+
**1. Accounts must exist before you can send to them.**
|
|
103
|
+
You cannot send XLM to a keypair that has never been funded. The recipient must have a funded account (minimum ~1 XLM). Use `createAccount` operation for new accounts.
|
|
104
|
+
|
|
105
|
+
**2. Trustlines must exist before receiving non-XLM assets.**
|
|
106
|
+
To receive USDC, an account must first establish a trustline to USDC. This is a separate transaction. Never assume trustlines exist.
|
|
107
|
+
|
|
108
|
+
**3. Transactions are atomic.**
|
|
109
|
+
A Stellar transaction can contain up to 100 operations. Either all succeed or all fail. Use this to batch operations safely.
|
|
110
|
+
|
|
111
|
+
**4. Fees are predictable and tiny.**
|
|
112
|
+
Base fee is 100 stroops (0.00001 XLM) per operation. Soroban fees are slightly higher but still sub-cent. Stellar is genuinely cheap — this is not marketing.
|
|
113
|
+
|
|
114
|
+
**5. Horizon is not the only API.**
|
|
115
|
+
Horizon serves the classic protocol. Soroban smart contract interactions use the **Soroban RPC** endpoint — different base URL, different methods.
|
|
116
|
+
|
|
117
|
+
**6. Testnet resets periodically.**
|
|
118
|
+
Stellar testnet (Horizon: `https://horizon-testnet.stellar.org`) resets quarterly. Do not store testnet state long-term. Futurenet is for bleeding-edge preview features.
|
|
119
|
+
|
|
120
|
+
**7. Network passphrase is required for signing.**
|
|
121
|
+
Every transaction must be signed with the correct network passphrase:
|
|
122
|
+
- Mainnet: `Public Global Stellar Network ; September 2015`
|
|
123
|
+
- Testnet: `Test SDF Network ; September 2015`
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## Canonical Links
|
|
128
|
+
|
|
129
|
+
| Resource | URL |
|
|
130
|
+
|----------|-----|
|
|
131
|
+
| Stellar Docs | https://developers.stellar.org |
|
|
132
|
+
| Horizon Mainnet | https://horizon.stellar.org |
|
|
133
|
+
| Horizon Testnet | https://horizon-testnet.stellar.org |
|
|
134
|
+
| Soroban RPC Mainnet | https://mainnet.stellar.validationcloud.io/v1/... (varies by provider) |
|
|
135
|
+
| Soroban RPC Testnet | https://soroban-testnet.stellar.org |
|
|
136
|
+
| Stellar Lab | https://lab.stellar.org |
|
|
137
|
+
| Stellar Expert (Explorer) | https://stellar.expert |
|
|
138
|
+
| GitHub stellar/js-stellar-sdk | https://github.com/stellar/js-stellar-sdk |
|
|
139
|
+
| GitHub stellar/py-stellar-sdk | https://github.com/stellar/py-stellar-base |
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
*raw.githubusercontent.com/ggoldani/stellarskills/main — MIT License*
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: stellarskills-accounts
|
|
3
|
+
description: Keypairs, account creation, signers, multisig, minimum balance, sponsorship, muxed accounts.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# STELLARSKILLS — Accounts
|
|
7
|
+
|
|
8
|
+
> Keypairs, account creation, signers, multisig, minimum balance, sponsorship, muxed accounts.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Keypairs
|
|
13
|
+
|
|
14
|
+
A Stellar account is identified by a **public key** (G...) and controlled by a **secret key** (S...). Both are base32-encoded 32-byte Ed25519 keys.
|
|
15
|
+
|
|
16
|
+
```javascript
|
|
17
|
+
import { Keypair } from "@stellar/stellar-sdk";
|
|
18
|
+
|
|
19
|
+
// Generate new keypair
|
|
20
|
+
const keypair = Keypair.random();
|
|
21
|
+
console.log(keypair.publicKey()); // G...
|
|
22
|
+
console.log(keypair.secret()); // S...
|
|
23
|
+
|
|
24
|
+
// From existing secret
|
|
25
|
+
const kp = Keypair.fromSecret("SCZANGBA5RLCQ6LXXPJ7FJZLOL3ZRIQGXKVBIMKTSLK5DGNECJHPQMQ");
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
**NEVER log or transmit secret keys.** Store them in environment variables or a secrets manager.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Account Creation
|
|
33
|
+
|
|
34
|
+
Accounts do NOT exist until explicitly created and funded on-chain. Generating a keypair does not create an account.
|
|
35
|
+
|
|
36
|
+
### Fund with createAccount operation
|
|
37
|
+
```javascript
|
|
38
|
+
import { TransactionBuilder, Networks, Operation, Asset, BASE_FEE } from "@stellar/stellar-sdk";
|
|
39
|
+
import { Horizon } from "@stellar/stellar-sdk";
|
|
40
|
+
|
|
41
|
+
const server = new Horizon.Server("https://horizon-testnet.stellar.org");
|
|
42
|
+
|
|
43
|
+
const sourceKeypair = Keypair.fromSecret(process.env.SOURCE_SECRET);
|
|
44
|
+
const sourceAccount = await server.loadAccount(sourceKeypair.publicKey());
|
|
45
|
+
|
|
46
|
+
const newKeypair = Keypair.random();
|
|
47
|
+
|
|
48
|
+
const tx = new TransactionBuilder(sourceAccount, {
|
|
49
|
+
fee: BASE_FEE,
|
|
50
|
+
networkPassphrase: Networks.TESTNET,
|
|
51
|
+
})
|
|
52
|
+
.addOperation(
|
|
53
|
+
Operation.createAccount({
|
|
54
|
+
destination: newKeypair.publicKey(),
|
|
55
|
+
startingBalance: "1", // minimum ~1 XLM; more if adding trustlines
|
|
56
|
+
})
|
|
57
|
+
)
|
|
58
|
+
.setTimeout(30)
|
|
59
|
+
.build();
|
|
60
|
+
|
|
61
|
+
tx.sign(sourceKeypair);
|
|
62
|
+
await server.submitTransaction(tx);
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Testnet: fund via Friendbot
|
|
66
|
+
```javascript
|
|
67
|
+
// Only works on testnet
|
|
68
|
+
await fetch(`https://friendbot.stellar.org?addr=${keypair.publicKey()}`);
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## Minimum Balance
|
|
74
|
+
|
|
75
|
+
Every account must maintain a minimum XLM balance. **If a transaction would drop balance below minimum, it fails.**
|
|
76
|
+
|
|
77
|
+
Formula:
|
|
78
|
+
```
|
|
79
|
+
minimumBalance = (2 + numSubentries) × baseReserve + liabilities
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
- `baseReserve` = **0.5 XLM** (current value)
|
|
83
|
+
- `numSubentries` = number of trustlines + offers + signers + data entries + sponsored entries
|
|
84
|
+
- Base minimum = **1 XLM** (2 × 0.5)
|
|
85
|
+
- Each trustline adds **0.5 XLM** to minimum balance
|
|
86
|
+
- Each additional signer adds **0.5 XLM**
|
|
87
|
+
|
|
88
|
+
**Practical implication**: Before sending someone tokens, verify they have enough XLM headroom. If you're creating an account that will hold 3 trustlines, fund with at least 2.5 XLM (1 base + 1.5 for trustlines).
|
|
89
|
+
|
|
90
|
+
```javascript
|
|
91
|
+
const account = await server.loadAccount(publicKey);
|
|
92
|
+
const subentries = account.subentry_count;
|
|
93
|
+
const minBalance = (2 + subentries) * 0.5;
|
|
94
|
+
console.log(`Min balance: ${minBalance} XLM`);
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## Account Flags
|
|
100
|
+
|
|
101
|
+
Accounts can have flags set by the issuer. Relevant for asset issuers:
|
|
102
|
+
|
|
103
|
+
| Flag | Effect |
|
|
104
|
+
|------|--------|
|
|
105
|
+
| `AUTH_REQUIRED` | Users must be authorized before holding the asset |
|
|
106
|
+
| `AUTH_REVOCABLE` | Issuer can revoke trustlines (freeze assets) |
|
|
107
|
+
| `AUTH_IMMUTABLE` | Account flags can never be changed |
|
|
108
|
+
| `AUTH_CLAWBACK_ENABLED` | Issuer can claw back assets from any account |
|
|
109
|
+
|
|
110
|
+
For regular user accounts, flags are usually not set.
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## Signers & Multisig
|
|
115
|
+
|
|
116
|
+
Every account has a **master key** (the keypair) and can have **additional signers**. Transactions are authorized if the combined weight of signers meets the threshold.
|
|
117
|
+
|
|
118
|
+
### Thresholds
|
|
119
|
+
Each account has three thresholds:
|
|
120
|
+
- **Low** (default 0): used for operations like allowTrust, bumpSequence
|
|
121
|
+
- **Medium** (default 0): most operations (payments, offers, etc.)
|
|
122
|
+
- **High** (default 0): setOptions, accountMerge
|
|
123
|
+
|
|
124
|
+
Default threshold is 0, master key weight is 1 — so single-signature works out of the box.
|
|
125
|
+
|
|
126
|
+
### Adding a signer
|
|
127
|
+
```javascript
|
|
128
|
+
const tx = new TransactionBuilder(sourceAccount, { fee: BASE_FEE, networkPassphrase: Networks.MAINNET })
|
|
129
|
+
.addOperation(
|
|
130
|
+
Operation.setOptions({
|
|
131
|
+
signer: {
|
|
132
|
+
ed25519PublicKey: secondSignerPublicKey,
|
|
133
|
+
weight: 1,
|
|
134
|
+
},
|
|
135
|
+
})
|
|
136
|
+
)
|
|
137
|
+
.setTimeout(30)
|
|
138
|
+
.build();
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### 2-of-3 Multisig Setup
|
|
142
|
+
```javascript
|
|
143
|
+
// Set master weight and thresholds
|
|
144
|
+
Operation.setOptions({
|
|
145
|
+
masterWeight: 1,
|
|
146
|
+
lowThreshold: 2,
|
|
147
|
+
medThreshold: 2,
|
|
148
|
+
highThreshold: 3,
|
|
149
|
+
signer: { ed25519PublicKey: signer2, weight: 1 },
|
|
150
|
+
});
|
|
151
|
+
// Repeat for signer3
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Pre-authorized transactions
|
|
155
|
+
You can add a hash of a future transaction as a signer — it authorizes itself when submitted. Useful for time-locked operations.
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## Sponsorship
|
|
160
|
+
|
|
161
|
+
Account sponsorship lets one account pay the minimum balance reserves for another account's subentries (trustlines, offers, signers, data).
|
|
162
|
+
|
|
163
|
+
The **sponsor** pays the reserve; the **sponsored** account doesn't need extra XLM for those entries.
|
|
164
|
+
|
|
165
|
+
```javascript
|
|
166
|
+
const tx = new TransactionBuilder(sponsorAccount, { fee: BASE_FEE, networkPassphrase: Networks.MAINNET })
|
|
167
|
+
.addOperation(Operation.beginSponsoringFutureReserves({
|
|
168
|
+
sponsoredId: userPublicKey,
|
|
169
|
+
}))
|
|
170
|
+
.addOperation(Operation.createAccount({
|
|
171
|
+
destination: userPublicKey,
|
|
172
|
+
startingBalance: "0", // sponsor covers reserve
|
|
173
|
+
}))
|
|
174
|
+
.addOperation(Operation.endSponsoringFutureReserves()) // signed by sponsored account
|
|
175
|
+
.setTimeout(30)
|
|
176
|
+
.build();
|
|
177
|
+
|
|
178
|
+
// Must be signed by BOTH sponsor AND sponsored
|
|
179
|
+
tx.sign(sponsorKeypair);
|
|
180
|
+
tx.sign(userKeypair);
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
**Use case**: Onboarding users without requiring them to own XLM first. The dApp or service sponsors the account creation and trustline reserves.
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## Muxed Accounts
|
|
188
|
+
|
|
189
|
+
A **muxed account** (M...) is a virtual sub-account derived from a G... address with an embedded 64-bit ID. It allows a single Stellar account to represent many logical users — useful for exchanges, custodians, and payment processors.
|
|
190
|
+
|
|
191
|
+
```javascript
|
|
192
|
+
import { MuxedAccount } from "@stellar/stellar-sdk";
|
|
193
|
+
|
|
194
|
+
const baseKeypair = Keypair.fromSecret(process.env.SECRET);
|
|
195
|
+
const muxed = new MuxedAccount(
|
|
196
|
+
await server.loadAccount(baseKeypair.publicKey()),
|
|
197
|
+
"12345678" // arbitrary user ID
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
console.log(muxed.accountId()); // M... address
|
|
201
|
+
|
|
202
|
+
// Use as source or destination in transactions
|
|
203
|
+
const tx = new TransactionBuilder(muxed, { fee: BASE_FEE, networkPassphrase: Networks.MAINNET })
|
|
204
|
+
.addOperation(Operation.payment({
|
|
205
|
+
destination: recipientMuxed.accountId(),
|
|
206
|
+
asset: Asset.native(),
|
|
207
|
+
amount: "10",
|
|
208
|
+
}))
|
|
209
|
+
.setTimeout(30)
|
|
210
|
+
.build();
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
**Important**: Muxed accounts share the base account's XLM balance and sequence number. They are a labeling mechanism, not isolated wallets.
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
## Loading Account State
|
|
218
|
+
|
|
219
|
+
```javascript
|
|
220
|
+
const server = new Horizon.Server("https://horizon.stellar.org");
|
|
221
|
+
|
|
222
|
+
const account = await server.loadAccount(publicKey);
|
|
223
|
+
|
|
224
|
+
console.log(account.sequence); // current sequence number
|
|
225
|
+
console.log(account.balances); // array of { asset_type, asset_code, asset_issuer, balance }
|
|
226
|
+
console.log(account.signers); // array of signers with weights
|
|
227
|
+
console.log(account.thresholds); // low/med/high thresholds
|
|
228
|
+
console.log(account.subentry_count); // number of subentries
|
|
229
|
+
console.log(account.flags); // auth flags
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### Check specific balance
|
|
233
|
+
```javascript
|
|
234
|
+
const xlmBalance = account.balances.find(b => b.asset_type === "native");
|
|
235
|
+
const usdcBalance = account.balances.find(
|
|
236
|
+
b => b.asset_code === "USDC" && b.asset_issuer === "GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN"
|
|
237
|
+
);
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
## Sequence Numbers
|
|
243
|
+
|
|
244
|
+
Every transaction must include the **next** sequence number for the source account. Horizon auto-increments it. If you submit two transactions concurrently from the same account, the second will fail (wrong sequence).
|
|
245
|
+
|
|
246
|
+
For concurrent transactions:
|
|
247
|
+
- Use different source accounts (e.g., a fee account + user account)
|
|
248
|
+
- Or queue transactions and submit sequentially
|
|
249
|
+
- Or use Soroban (which has different state model)
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
## Common Errors
|
|
254
|
+
|
|
255
|
+
| Error | Cause | Fix |
|
|
256
|
+
|-------|-------|-----|
|
|
257
|
+
| `op_no_destination` | Destination account doesn't exist | Create account first with `createAccount` |
|
|
258
|
+
| `op_low_reserve` | Would drop below minimum balance | Add more XLM or reduce subentries |
|
|
259
|
+
| `tx_bad_seq` | Wrong sequence number | Re-fetch account and rebuild transaction |
|
|
260
|
+
| `op_underfunded` | Not enough balance | Check balance including minimum reserve |
|
|
261
|
+
| `tx_insufficient_fee` | Fee too low during surge | Use fee bump or increase base fee |
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
## SDKs
|
|
266
|
+
|
|
267
|
+
```bash
|
|
268
|
+
npm install @stellar/stellar-sdk # JavaScript / TypeScript
|
|
269
|
+
pip install stellar-sdk # Python
|
|
270
|
+
go get github.com/stellar/go/clients/horizonclient # Go
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
*raw.githubusercontent.com/ggoldani/stellarskills/main/accounts — MIT License*
|