Skip to content

Commit abf0edc

Browse files
committed
move blockstack-cli to contrib
1 parent 88058ef commit abf0edc

File tree

6 files changed

+81
-27
lines changed

6 files changed

+81
-27
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/blockstack-cli"
1516
]
1617

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

contrib/blockstack-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 = "blockstack-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/blockstack-cli/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# blockstack-cli
2+
3+
A CLI for building and signing Stacks transactions and interacting with Clarity contracts.
4+
5+
Features:
6+
- `publish` — deploy Clarity smart contracts
7+
- `contract-call` — call public functions on deployed contracts
8+
- `token-transfer` — send STX between accounts
9+
- Decoding helpers for transactions and payloads
10+
11+
Build:
12+
```bash
13+
cargo build -p blockstack-cli
14+
```
15+
16+
Basic usage:
17+
```bash
18+
cargo run -p blockstack-cli --help
19+
```
20+
21+
Examples:
22+
```bash
23+
# Publish a contract
24+
cargo run -p blockstack-cli publish --path <CLARITY-CONTRACT-PATH> --sender <PRIVKEY> --network <NETWORK>
25+
26+
# Call a contract function
27+
cargo run -p blockstack-cli contract-call --contract <PRINCIPAL.contract> --function <fn-name> --args '[(int 1)]' --sender <PRIVKEY>
28+
29+
# Transfer STX
30+
cargo run -p blockstack-cli token-transfer --amount 100000 --sender <PRIVKEY> --recipient <PRINCIPAL>
31+
```
32+
33+
See `--help` on each subcommand for complete options.

stackslib/src/blockstack_cli.rs renamed to contrib/blockstack-cli/src/main.rs

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// Copyright (C) 2013-2020 Blockstack PBC, a public benefit corporation
2-
// Copyright (C) 2020 Stacks Open Internet Foundation
1+
// Copyright (C) 2025 Stacks Open Internet Foundation
32
//
43
// This program is free software: you can redistribute it and/or modify
54
// it under the terms of the GNU General Public License as published by
@@ -18,38 +17,38 @@
1817
#![allow(non_snake_case)]
1918
#![allow(non_upper_case_globals)]
2019

21-
extern crate blockstack_lib;
2220
extern crate clarity;
2321
extern crate stacks_common;
22+
extern crate stackslib;
2423

24+
use std::io::Read;
2525
#[cfg(test)]
2626
use std::io::prelude::*;
27-
use std::io::Read;
2827
use std::{env, fs, io};
2928

30-
use blockstack_lib::burnchains::bitcoin::address::{
31-
ADDRESS_VERSION_MAINNET_SINGLESIG, ADDRESS_VERSION_TESTNET_SINGLESIG,
32-
};
33-
use blockstack_lib::burnchains::Address;
34-
use blockstack_lib::chainstate::stacks::{
35-
StacksBlock, StacksBlockHeader, StacksMicroblock, StacksPrivateKey, StacksPublicKey,
36-
StacksTransaction, StacksTransactionSigner, TokenTransferMemo, TransactionAnchorMode,
37-
TransactionAuth, TransactionContractCall, TransactionPayload, TransactionPostConditionMode,
38-
TransactionSmartContract, TransactionSpendingCondition, TransactionVersion,
39-
C32_ADDRESS_VERSION_MAINNET_SINGLESIG, C32_ADDRESS_VERSION_TESTNET_SINGLESIG,
40-
};
41-
use blockstack_lib::clarity_cli::vm_execute;
42-
use blockstack_lib::core::{CHAIN_ID_MAINNET, CHAIN_ID_TESTNET};
43-
use blockstack_lib::net::Error as NetError;
44-
use blockstack_lib::util_lib::strings::StacksString;
4529
use clarity::vm::errors::{Error as ClarityError, RuntimeErrorType};
4630
use clarity::vm::types::PrincipalData;
4731
use clarity::vm::{ClarityName, ClarityVersion, ContractName, Value};
48-
use stacks_common::address::{b58, AddressHashMode};
32+
use stacks_common::address::{AddressHashMode, b58};
4933
use stacks_common::codec::{Error as CodecError, StacksMessageCodec};
5034
use stacks_common::types::chainstate::StacksAddress;
5135
use stacks_common::util::hash::{hex_bytes, to_hex};
5236
use stacks_common::util::retry::LogReader;
37+
use stackslib::burnchains::Address;
38+
use stackslib::burnchains::bitcoin::address::{
39+
ADDRESS_VERSION_MAINNET_SINGLESIG, ADDRESS_VERSION_TESTNET_SINGLESIG,
40+
};
41+
use stackslib::chainstate::stacks::{
42+
C32_ADDRESS_VERSION_MAINNET_SINGLESIG, C32_ADDRESS_VERSION_TESTNET_SINGLESIG, StacksBlock,
43+
StacksBlockHeader, StacksMicroblock, StacksPrivateKey, StacksPublicKey, StacksTransaction,
44+
StacksTransactionSigner, TokenTransferMemo, TransactionAnchorMode, TransactionAuth,
45+
TransactionContractCall, TransactionPayload, TransactionPostConditionMode,
46+
TransactionSmartContract, TransactionSpendingCondition, TransactionVersion,
47+
};
48+
use stackslib::clarity_cli::vm_execute;
49+
use stackslib::core::{CHAIN_ID_MAINNET, CHAIN_ID_TESTNET};
50+
use stackslib::net::Error as NetError;
51+
use stackslib::util_lib::strings::StacksString;
5352

5453
const USAGE: &str = "blockstack-cli (options) [method] [args...]
5554
@@ -1071,8 +1070,8 @@ fn main_handler(mut argv: Vec<String>) -> Result<String, CliError> {
10711070
mod test {
10721071
use std::panic;
10731072

1074-
use blockstack_lib::chainstate::stacks::TransactionPostCondition;
10751073
use stacks_common::util::cargo_workspace;
1074+
use stackslib::chainstate::stacks::TransactionPostCondition;
10761075
use tempfile::NamedTempFile;
10771076

10781077
use super::*;
@@ -1721,7 +1720,7 @@ mod test {
17211720
fn simple_decode_tx() {
17221721
let tx_args = [
17231722
"decode-tx",
1724-
"8080000000040021a3c334fc0ee50359353799e8b2605ac6be1fe4000000000000000100000000000000000100c90ae0235365f3a73c595f8c6ab3c529807feb3cb269247329c9a24218d50d3f34c7eef5d28ba26831affa652a73ec32f098fec4bf1decd1ceb3fde4b8ce216b030200000000021a21a3c334fc0ee50359353799e8b2605ac6be1fe40573746f7265096765742d76616c7565000000010d00000003666f6f"
1723+
"8080000000040021a3c334fc0ee50359353799e8b2605ac6be1fe4000000000000000100000000000000000100c90ae0235365f3a73c595f8c6ab3c529807feb3cb269247329c9a24218d50d3f34c7eef5d28ba26831affa652a73ec32f098fec4bf1decd1ceb3fde4b8ce216b030200000000021a21a3c334fc0ee50359353799e8b2605ac6be1fe40573746f7265096765742d76616c7565000000010d00000003666f6f",
17251724
];
17261725

17271726
let result = main_handler(to_string_vec(&tx_args)).unwrap();

stackslib/Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ path = "src/lib.rs"
2222
name = "clarity-cli"
2323
path = "src/clarity_cli_main.rs"
2424

25-
[[bin]]
26-
name = "blockstack-cli"
27-
path = "src/blockstack_cli.rs"
28-
2925
[dependencies]
3026
rand = { workspace = true }
3127
rand_core = { workspace = true }

0 commit comments

Comments
 (0)