-
Notifications
You must be signed in to change notification settings - Fork 31
Add wallet skill: use the Stellar CLI as a wallet #49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
aristidesstaffieri
wants to merge
5
commits into
main
Choose a base branch
from
feat/wallet-skills-cli
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
532d5ae
Add wallet skills package (stellar-wallet-skills)
aristidesstaffieri ad44cca
Document Stellar account & transaction model in wallet skill
aristidesstaffieri d975c38
Route to DeFi skills for Soroban protocol interactions
aristidesstaffieri b6ecf5e
Address Copilot review comments
aristidesstaffieri 2f3dd63
Fix wallet skill docs against real CLI behavior
aristidesstaffieri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,139 @@ | ||
| --- | ||
| name: wallet | ||
| description: Use the Stellar CLI (`stellar`) as a wallet. Covers install and RPC/relayer configuration, key lifecycle and private-key security, funding, balances and account readiness, trustlines, value transfer, the `stellar token` client (SEP-41 / SAC), and transaction diagnosis, composed from existing commands with structured JSON output. Use when holding funds, moving value, managing tokens, checking balances, or transacting on Stellar from the command line. | ||
| user-invocable: true | ||
| argument-hint: "[wallet task]" | ||
| --- | ||
|
|
||
| # Wallet: the Stellar CLI as a wallet | ||
|
|
||
| There is no `stellar wallet` command. The "wallet" is a set of composed CLI commands: `keys` for custody and selection, `ledger` for reads, `tx` for building and submitting, `token` for SEP-41 / SAC value transfer, and `contract` for contract interactions. This skill maps each wallet operation to the command that performs it, when to reach for it, and how to read the errors it returns. | ||
|
|
||
| Two habits apply everywhere: | ||
|
|
||
| 1. **Pass `--output json`** on any command that supports it. You get a machine-readable object instead of formatted text, so the next step can parse it instead of scraping. | ||
| 2. **Discover before you guess.** `stellar <cmd> --help` prints the exact args for any command. Do not hardcode contract IDs, fees, or sequence numbers — the pipeline resolves them. | ||
|
|
||
| ## Read the file that matches the task | ||
|
|
||
| | Task | File | | ||
| |------|------| | ||
| | Create / import / export / list / select keys, private-key security, fund an account | [keys.md](keys.md) | | ||
| | Check balances and account readiness, trustlines, diagnose a transaction, sign + submit a prepared XDR, drain an account | [accounts-and-tx.md](accounts-and-tx.md) | | ||
| | Transfer / approve / burn tokens, read token metadata, SAC admin ops, pull a token list, asset anatomy | [tokens.md](tokens.md) | | ||
|
|
||
| ## Composition map | ||
|
|
||
| | Wallet operation | Composed from | Covered in | | ||
| |------------------|---------------|------------| | ||
| | create a key | `keys generate` | [keys.md](keys.md) | | ||
| | import a key | `keys add` | [keys.md](keys.md) | | ||
| | export a secret | `keys secret` | [keys.md](keys.md) | | ||
| | fund an account | `keys fund` | [keys.md](keys.md) | | ||
| | list keys | `keys ls` | [keys.md](keys.md) | | ||
| | select the default key | `keys use` | [keys.md](keys.md) | | ||
| | check XLM balance and reserves | `ledger entry fetch account` | [accounts-and-tx.md](accounts-and-tx.md) | | ||
| | check a trustline | `ledger entry fetch trustline` | [accounts-and-tx.md](accounts-and-tx.md) | | ||
| | check a token balance | `token balance` | [tokens.md](tokens.md) | | ||
| | add or change a trustline | `tx new change-trust` | [accounts-and-tx.md](accounts-and-tx.md) | | ||
| | transfer value | `token transfer` | [tokens.md](tokens.md) | | ||
| | diagnose a transaction | `tx fetch --hash` | [accounts-and-tx.md](accounts-and-tx.md) | | ||
| | sign and submit a prepared XDR | `tx sign` + `tx send` | [accounts-and-tx.md](accounts-and-tx.md) | | ||
| | drain an account (sweep + close) | `token transfer` + `tx new account-merge` | [accounts-and-tx.md](accounts-and-tx.md) | | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| ### Install the CLI | ||
|
|
||
| Install `stellar` (the Stellar CLI, package `stellar-cli`). Pick one: | ||
|
|
||
| ```bash | ||
| brew install stellar-cli # macOS / Linux (Homebrew) | ||
| cargo install --locked stellar-cli # any platform with a Rust toolchain | ||
| winget install --id Stellar.StellarCLI # Windows | ||
| npm install --global @stellar/cli # via npm | ||
| ``` | ||
|
|
||
| Verify: `stellar --version`. Full matrix and latest instructions: <https://developers.stellar.org/docs/tools/cli/install-cli>. | ||
|
|
||
| ### Configure the network (RPC) | ||
|
|
||
| The CLI uses a [Stellar RPC](https://developers.stellar.org/docs/build/guides/rpc) to read ledger entries, simulate transactions, and submit them. **`testnet`, `pubnet`, `futurenet`, and `local` ship built-in — you do not `network add` them.** The built-in default is `testnet` (RPC `https://soroban-testnet.stellar.org`), so a bare command with no `--network` / `-n` runs against testnet. | ||
|
|
||
| ```bash | ||
| stellar network ls # list networks (built-ins are already present) | ||
| stellar network use testnet # set the default so you can omit --network / -n | ||
| stellar network health # confirm the RPC is reachable | ||
|
|
||
| # …or select a network per command instead of setting a default | ||
| stellar <cmd> --network testnet # (or -n testnet) | ||
| ``` | ||
|
|
||
| `stellar network add` is only for a **custom or private** RPC (or to override a built-in's endpoint): | ||
|
|
||
| ```bash | ||
| stellar network add my-rpc \ | ||
| --rpc-url https://my-private-rpc.example.com \ | ||
| --network-passphrase "Test SDF Network ; September 2015" | ||
| ``` | ||
|
|
||
| You can also pass `--rpc-url` / `STELLAR_RPC_URL` and `--network-passphrase` / `STELLAR_NETWORK_PASSPHRASE` per command instead of saving a network. A provider list is at <https://developers.stellar.org/docs/data/apis/rpc/providers>. | ||
|
|
||
| ### Configure a relayer (optional) | ||
|
|
||
| A relayer wraps your transaction in a fee-bump and signs + submits it, so the wallet key needs no XLM for fees. Configuration is `--relayer-url` / `STELLAR_RELAYER_URL` (plus `--relayer-header` for auth). Without a relayer, transactions are self-funded from the source account. | ||
|
|
||
| Learn more about the Relayer service at <https://developers.stellar.org/docs/tools/openzeppelin-relayer>. | ||
|
|
||
| ## Structured output and errors | ||
|
|
||
| The CLI is designed for progressive disclosure and programmatic recovery: | ||
|
|
||
| - **Structured output.** `--output json` returns predictable keys. A state-changing command returns a *receipt* — result, tx hash, fee, decoded events. A read returns the decoded value. | ||
|
|
||
| ```jsonc | ||
| // stellar token balance --id native --of alice --output json | ||
| { "status": "ok", "result": "9999999500", "error": null } | ||
| ``` | ||
|
|
||
| - **Structured errors.** On failure the object carries a code you can branch on and a remediation path: | ||
|
|
||
| ```jsonc | ||
| { | ||
| "status": "error", | ||
| "result": null, | ||
| "error": { | ||
| "code": "tx_simulation_failed", | ||
| "domain": "tx", | ||
| "message": "host invocation failed: Error(Contract, #2)", | ||
| "details": { "error_name": "InsufficientBalance", "contract_id": "C…" } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| Read `error.code` / `error.details.error_name`, not the human message. The named-error → next-command table lives in [tokens.md](tokens.md#error-remediation). | ||
|
|
||
| ## Working with Soroban protocols (DeFi) | ||
|
|
||
| This skill covers wallet primitives — moving value, trustlines, and transaction mechanics. It does **not** teach how any specific Soroban protocol works. Reference the DeFi skills when you need to: | ||
|
|
||
| 1. **Understand how a protocol works** — its architecture, contracts, and on-chain addresses. | ||
| 2. **Craft the transaction (or sequence of transactions)** to perform a protocol action — swap or quote, lend / borrow / repay, deposit / withdraw from a vault, provide liquidity. | ||
|
|
||
| The DeFi playbooks map each protocol's operations to concrete `contract invoke` / `stellar token` calls and carry the current contract references, so you act on the protocol instead of reverse-engineering it from raw ledger data. | ||
|
|
||
| Find them under [`../defi/SKILL.md`](../defi/SKILL.md) | ||
|
|
||
| ## Related skills | ||
|
|
||
| - Classic assets, trustlines, authorization flags, and the SAC bridge → [`../assets/SKILL.md`](../assets/SKILL.md) | ||
| - The SEP-41 token contracts and SACs these commands call → [`../smart-contracts/SKILL.md`](../smart-contracts/SKILL.md) | ||
| - Querying chain data over RPC / Horizon → [`../data/SKILL.md`](../data/SKILL.md) | ||
| - SEP-41 and other standards → [`../standards/SKILL.md`](../standards/SKILL.md) | ||
| - Paying x402 / MPP services → [`../agentic-payments/SKILL.md`](../agentic-payments/SKILL.md) | ||
| - Acting on Soroban protocols (swap, lend, vaults) → [Working with Soroban protocols](#working-with-soroban-protocols-defi) | ||
|
|
||
| ## Documentation | ||
|
|
||
| - [Stellar CLI manual](https://developers.stellar.org/docs/tools/cli/stellar-cli) | ||
| - [Anatomy of an asset](https://developers.stellar.org/docs/tokens/anatomy-of-an-asset) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.