Skip to content

Commit 5934517

Browse files
authored
Merge pull request #6520 from Jiloc/chore/move-blockstack-cli-to-contrib
chore: rename `blockstack-cli` to `stacks-cli` and move it to `contrib`
2 parents 7832607 + 0b1d244 commit 5934517

File tree

6 files changed

+158
-115
lines changed

6 files changed

+158
-115
lines changed

Cargo.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ members = [
1111
"libsigner",
1212
"stacks-signer",
1313
"stacks-node",
14-
"contrib/stacks-inspect"
14+
"contrib/stacks-inspect",
15+
"contrib/stacks-cli"
1516
]
1617

1718
exclude = ["contrib/tools/config-docs-generator"]

contrib/stacks-cli/Cargo.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[package]
2+
name = "stacks-cli"
3+
version = "0.1.0"
4+
edition = "2024"
5+
6+
[dependencies]
7+
stackslib = { package = "stackslib", path = "../../stackslib", default-features = false }
8+
clarity = { path = "../../clarity", default-features = false }
9+
stacks-common = { path = "../../stacks-common", default-features = false }
10+
serde_json = { workspace = true }
11+
12+
[dev-dependencies]
13+
stacks-common = { path = "../../stacks-common", default-features = false, features = ["testing"] }
14+
tempfile = { version = "3.3", default-features = false }

contrib/stacks-cli/README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# stacks-cli
2+
3+
A CLI for building and signing Stacks transactions and interacting with Clarity contracts.
4+
5+
### Features
6+
7+
* **Transaction Building:**
8+
* `publish`: Deploy Clarity smart contracts.
9+
* `contract-call`: Call public functions on deployed contracts.
10+
* `token-transfer`: Transfer STX between accounts.
11+
* **Key Management:**
12+
* `generate-sk`: Generate a new Stacks private key.
13+
* `addresses`: Derive Stacks and Bitcoin addresses from a private key.
14+
* **Decoding Helpers:**
15+
* `decode-tx`: Decode a hex-encoded transaction.
16+
* `decode-header`: Decode a hex-encoded block header.
17+
* `decode-block`: Decode a hex-encoded block.
18+
* `decode-microblock`: Decode a hex-encoded microblock.
19+
* `decode-microblocks`: Decode a hex-encoded stream of microblocks.
20+
21+
### Build & Run
22+
23+
```bash
24+
# Build the CLI
25+
cargo build -p stacks-cli
26+
27+
# See top-level help
28+
cargo run -p stacks-cli -- --help
29+
```
30+
*Note the extra `--` to pass flags to the binary instead of cargo.*
31+
32+
### Global Options
33+
* `--testnet[=<chain-id>]` - Generate a transaction for the testnet. An optional custom chain ID can be provided in hex (e.g., `--testnet=0x12345678`).
34+
35+
### Examples
36+
37+
**Note:** All arguments are positional.
38+
39+
```bash
40+
# Publish a contract on testnet
41+
cargo run -p stacks-cli -- --testnet publish <SENDER_PRIVATE_KEY> <FEE_RATE> <NONCE> <CONTRACT_NAME> <PATH_TO_CLARITY_FILE>
42+
43+
# Call a contract function
44+
# Function arguments are passed using flags: -e (evaluate), -x (hex), or --hex-file
45+
cargo run -p stacks-cli -- contract-call <SENDER_PRIVATE_KEY> <FEE_RATE> <NONCE> <CONTRACT_ADDRESS> <CONTRACT_NAME> <FUNCTION_NAME> -e "'ST1...'" -e "u100"
46+
47+
# Transfer STX (amount is in micro-STX, memo is optional)
48+
cargo run -p stacks-cli -- token-transfer <SENDER_PRIVATE_KEY> <FEE_RATE> <NONCE> <RECIPIENT_ADDRESS> <AMOUNT_USTX> "my memo"
49+
50+
# Generate a new key and associated addresses
51+
cargo run -p stacks-cli -- generate-sk
52+
53+
# Decode a hex-encoded transaction from a string or stdin
54+
cargo run -p stacks-cli -- decode-tx <HEX_ENCODED_TRANSACTION>
55+
```
56+
57+
See `--help` on each subcommand for complete options (e.g., `cargo run -p stacks-cli -- publish -h`).

0 commit comments

Comments
 (0)