Skip to content

Commit d03b7f8

Browse files
authored
fix: improved cli documentation (#10)
1 parent 3b37769 commit d03b7f8

File tree

1 file changed

+195
-42
lines changed

1 file changed

+195
-42
lines changed

cli/README.md

Lines changed: 195 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,51 @@
11
# Yellowstone Shield CLI
22

3+
A command-line interface for managing Yellowstone Shield access control policies on Solana. This tool enables you to create permission-based policies that control access for validators, wallets, and programs.
4+
35
## Overview
46

57
The Yellowstone Shield CLI is a command-line tool for managing access policies for Solana identities, such as validators, wallets, or programs. It allows users to create and manage policies, add, update and remove identites, and configure various settings related to the policy.
68

79
## Installation
810

9-
To install the CLI, ensure you have Rust and Cargo installed on your system. Then, clone the repository and build the project:
11+
### Prerequisites
12+
- Rust and Cargo (latest stable version)
13+
- Solana CLI tools configured with a valid RPC endpoint
14+
- A funded Solana wallet for transaction fees
15+
16+
### Build from Source
1017

1118
```bash
1219
git clone https://github.com/rpcpool/yellowstone-shield
1320
cd yellowstone-shield
1421
cargo build --release --bin yellowstone-shield-cli
1522
```
1623

24+
The binary will be available at `target/release/yellowstone-shield-cli`
25+
26+
## Configuration
27+
28+
The CLI uses your Solana CLI configuration by default. Ensure you have:
29+
30+
```bash
31+
# Set your RPC endpoint
32+
solana config set --url https://api.mainnet-beta.solana.com
33+
34+
# Set your keypair
35+
solana config set --keypair ~/.config/solana/id.json
36+
```
37+
1738
The binary should be located at `./target/release/yellowstone-shield-cli`.
1839

1940
## Usage
2041

21-
The CLI provides several commands to interact with the shield policies and identities. Below are the available commands and their options:
42+
### Global Options
2243

23-
### General Options
44+
- `-r, --rpc <URL>` - Override the RPC endpoint from Solana config
45+
- `-k, --keypair <PATH>` - Override the keypair path from Solana config
46+
- `-l, --log-level <LEVEL>` - Set log verbosity (default: "off")
47+
48+
### Policy Commands
2449

2550
- `-r, --rpc <URL>`: RPC endpoint url to override using the Solana config.
2651
- `-T, --timeout <SECONDS>`: Set the timeout duration (default is 90 seconds).
@@ -44,64 +69,192 @@ Before creating a new Policy, plan ahead by creating a URI-addressable JSON file
4469

4570
After uploading your metadata to a publicly accessible URI, you will use the URI with the `--uri` parameter when creating the Policy.
4671

47-
### Commands
72+
#### Create a Policy
73+
74+
Create a new access control policy with metadata:
75+
76+
```bash
77+
# Create an Allow policy
78+
yellowstone-shield-cli policy create \
79+
--strategy Allow \
80+
--name "Validator Access Policy" \
81+
--symbol "VAP" \
82+
--uri "https://example.com/policy-metadata.json"
83+
84+
# Create a Deny policy (blocklist)
85+
yellowstone-shield-cli policy create \
86+
--strategy Deny \
87+
--name "Restricted Access" \
88+
--symbol "BLOCK" \
89+
--uri "https://example.com/blocklist.json"
90+
```
4891

49-
- **Create a Policy**
92+
**Parameters:**
93+
- `--strategy` - Permission strategy: `Allow` (whitelist) or `Deny` (blocklist)
94+
- `--name` - Human-readable policy name
95+
- `--symbol` - Short identifier (like a token symbol)
96+
- `--uri` - Metadata URI for additional policy information
5097

51-
```bash
52-
yellowstone-shield-cli policy create [OPTIONS] --strategy <STRATEGY> --name <NAME> --symbol <SYMBOL> --uri <URI>
53-
```
98+
#### Show Policy Details
5499

55-
- `-r, --rpc <RPC>`: RPC endpoint URL to override using the Solana config.
56-
- `--strategy <STRATEGY>`: The strategy to use for the policy. Valid options are 'allow' or 'deny'.
57-
- `-l, --log-level <LOG_LEVEL>`: Log level (default is "off").
58-
- `--name <NAME>`: The name of the policy.
59-
- `-k, --keypair <KEYPAIR>`: Path to the local owner keypair file -- not a hardware wallet.
60-
- `--symbol <SYMBOL>`: The symbol of the policy.
61-
- `--uri <URI>`: The URI of the policy.
62-
- `-h, --help`: Print help.
100+
Display policy information and list all authorized identities:
63101

64-
After creating a new Policy, you will receive CLI output including the Mint address required in the following steps.
102+
```bash
103+
yellowstone-shield-cli policy show \
104+
--mint 7xKXtg2CW87d7TXQ3xgBwSEGD6YA1F3PtdxqMtfqdW4m
105+
```
65106

66-
- **Add Identities**
107+
#### Delete a Policy
67108

68-
```bash
69-
yellowstone-shield-cli identities add --mint <MINT> --identities-path <IDENTITIES>
70-
```
109+
Remove a policy (requires ownership):
71110

72-
- `--mint <MINT>`: The mint address linked to the shield policy.
73-
- `--identities-path <IDENTITIES>`: File path to a list of public keys, each on a new line, to be added.
111+
```bash
112+
yellowstone-shield-cli policy delete \
113+
--mint 7xKXtg2CW87d7TXQ3xgBwSEGD6YA1F3PtdxqMtfqdW4m
114+
```
74115

75-
- **Update Identities**
116+
### Identity Management Commands
76117

77-
```bash
78-
yellowstone-shield-cli identities update --mint <MINT> --identities-path <IDENTITIES>
79-
```
118+
#### Add Identities
80119

81-
- `--mint <MINT>`: The mint address linked to the shield policy.
82-
- `--identities-path <IDENTITIES>`: File path to a list of public keys, each on a new line, to be updated/replaced.
120+
Add authorized identities to a policy from a file:
83121

84-
- **Remove Identities**
122+
```bash
123+
# Create a file with pubkeys (one per line)
124+
cat > validators.txt << EOF
125+
DfXygSm4jCyNCybVYYK6DwvWqjKee8pbDmJGcLWNDXjh
126+
ADuUkR4vqLUMWXxW9gh6D6L8pMSawimctcNZ5pGwDcEt
127+
CiDwVBFgWV9E5MvXWoLgnEgn2hK7rJikbvfWavzAQz3
128+
EOF
129+
130+
# Add all identities to the policy
131+
yellowstone-shield-cli identities add \
132+
--mint 7xKXtg2CW87d7TXQ3xgBwSEGD6YA1F3PtdxqMtfqdW4m \
133+
--identities-path validators.txt
134+
```
85135

86-
```bash
87-
yellowstone-shield-cli identities remove --mint <MINT> --identities-path <IDENTITIES>
88-
```
136+
The command will:
137+
- Skip identities that are already in the policy
138+
- Process additions in batches of 20 for efficiency
139+
- Show transaction signatures for each batch
89140

90-
- `--mint <MINT>`: The mint address linked to the shield policy.
91-
- `--identities-path <IDENTITIES>`: File path to a list of public keys, each on a new line, to be removed.
141+
#### Remove Identities
92142

93-
## Configuration
143+
Remove identities from a policy:
144+
145+
```bash
146+
# Create a file with pubkeys to remove
147+
cat > remove_list.txt << EOF
148+
ADuUkR4vqLUMWXxW9gh6D6L8pMSawimctcNZ5pGwDcEt
149+
EOF
150+
151+
yellowstone-shield-cli identities remove \
152+
--mint 7xKXtg2CW87d7TXQ3xgBwSEGD6YA1F3PtdxqMtfqdW4m \
153+
--identities-path remove_list.txt
154+
```
155+
156+
## Example Workflows
157+
158+
### 1. Validator Access Control
159+
160+
Create a whitelist for authorized validators:
161+
162+
```bash
163+
# Create policy
164+
yellowstone-shield-cli policy create \
165+
--strategy Allow \
166+
--name "Mainnet Validators" \
167+
--symbol "MVAL" \
168+
--uri "https://validators.example.com/metadata.json"
169+
170+
# Note the mint address from output
171+
# Add validators
172+
yellowstone-shield-cli identities add \
173+
--mint <MINT_ADDRESS> \
174+
--identities-path mainnet_validators.txt
175+
```
176+
177+
### 2. Program Blocklist
178+
179+
Create a blocklist for restricted programs:
180+
181+
```bash
182+
# Create deny policy
183+
yellowstone-shield-cli policy create \
184+
--strategy Deny \
185+
--name "Restricted Programs" \
186+
--symbol "DENY" \
187+
--uri "https://security.example.com/blocklist.json"
188+
189+
# Add restricted program IDs
190+
yellowstone-shield-cli identities add \
191+
--mint <MINT_ADDRESS> \
192+
--identities-path restricted_programs.txt
193+
```
194+
195+
### 3. Dynamic Access Management
196+
197+
Update access lists programmatically:
198+
199+
```bash
200+
#!/bin/bash
201+
POLICY_MINT="7xKXtg2CW87d7TXQ3xgBwSEGD6YA1F3PtdxqMtfqdW4m"
202+
203+
# Add new validators
204+
yellowstone-shield-cli identities add \
205+
--mint $POLICY_MINT \
206+
--identities-path new_validators.txt
207+
208+
# Remove deactivated validators
209+
yellowstone-shield-cli identities remove \
210+
--mint $POLICY_MINT \
211+
--identities-path removed_validators.txt
212+
213+
# Show current state
214+
yellowstone-shield-cli policy show --mint $POLICY_MINT
215+
```
216+
217+
## Output Format
218+
219+
The CLI provides formatted output with emojis for better readability:
220+
221+
```
222+
📜 Policy
223+
--------------------------------
224+
🏠 Addresses
225+
📜 Policy: 5we4Bk6DxGMnMbrUMmVpLjgyHrqh7k7F4vhYVzkeQcH2
226+
🔑 Mint: 7xKXtg2CW87d7TXQ3xgBwSEGD6YA1F3PtdxqMtfqdW4m
227+
--------------------------------
228+
🔍 Details
229+
✅ Strategy: Allow
230+
🏷️ Name: Validator Access Policy
231+
🔖 Symbol: VAP
232+
🌐 URI: https://example.com/policy-metadata.json
233+
--------------------------------
234+
```
235+
236+
## Best Practices
237+
238+
1. **Batch Operations**: When adding/removing many identities, use files to batch operations
239+
2. **Backup Mint Addresses**: Save policy mint addresses for future reference
240+
3. **Metadata URIs**: Host policy metadata on IPFS or Arweave for permanence
241+
4. **Access Strategy**: Choose between Allow (whitelist) and Deny (blocklist) based on your security model
242+
5. **Regular Audits**: Use `policy show` to regularly audit access lists
94243

95-
The CLI uses the Solana CLI configuration file to manage RPC endpoints and keypair paths. You can override these settings using the command-line options provided.
244+
## Troubleshooting
96245

97-
## Contributing
246+
### Common Issues
98247

99-
Contributions are welcome! Please fork the repository and submit a pull request with your changes.
248+
1. **Insufficient SOL**: Ensure your wallet has enough SOL for transaction fees
249+
2. **RPC Errors**: Try using a different RPC endpoint with `-r` flag
250+
3. **Large Identity Lists**: Files are processed in batches of 20 to avoid transaction size limits
251+
4. **Permission Errors**: Only the policy owner can modify identities
100252

101253
## License
102254

103-
This project is licensed under the MIT License. See the [LICENSE](../LICENSE) file for details.
255+
This project is licensed under the AGPL-3.0 License. See the [LICENSE](../LICENSE) file for details.
104256

105-
## Contact
257+
## Support
106258

107-
For questions or support, please open an issue on github.
259+
- 📚 [Documentation](https://docs.triton.one/shield-transaction-policies)
260+
- 🐛 [Issue Tracker](https://github.com/rpcpool/yellowstone-shield/issues)

0 commit comments

Comments
 (0)