GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add `stellar token set-authorized` subcommand by fnando · Pull Request #2719 · stellar/stellar-cli

Add stellar token set-authorized subcommand #2719

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.

Sign up for GitHub

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

Merged
fnando merged 2 commits into main from token-set-authorized
Oct 7, 2026

Uh oh!

There was an error while loading. Please reload this page.

Merged

Add stellar token set-authorized subcommand #2719

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
2 commits
Select commit Hold shift + click to select a range
e5d40ff
Add stellar token set-authorized subcommand.
fnando Sep 4, 2026
2ea5987
Reject muxed accounts in token set-authorized.
fnando Oct 7, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

Some comments aren't visible on the classic Files Changed page.

There are no files selected for viewing

51 changes: 51 additions & 0 deletions 51 FULL_HELP_DOCS.md
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -1958,6 +1958,7 @@ Interact with SEP-41 tokens and Stellar Asset Contracts
- `mint` — Mint new tokens to an account or contract (SAC admin)
- `clawback` — Claw back tokens from an account or contract (SAC admin)
- `set-admin` — Transfer administration of the token to a new admin (SAC admin)
- `set-authorized` — Authorize or deauthorize an account to hold the token (SAC admin)

## `stellar token transfer`

Expand Down Expand Up @@ -2450,6 +2451,56 @@ Calls the token's Stellar Asset Contract `set_admin` function. A non-SAC contrac
- `--fee <FEE>` — ⚠️ Deprecated, use `--inclusion-fee`. Fee amount for transaction, in stroops. 1 stroop = 0.0000001 xlm
- `--inclusion-fee <INCLUSION_FEE>` — Maximum fee amount for transaction inclusion, in stroops. 1 stroop = 0.0000001 xlm. Defaults to 100 if no arg, env, or config value is provided

## `stellar token set-authorized`

Authorize or deauthorize an account to hold the token (SAC admin)

Calls the token's Stellar Asset Contract `set_authorized` function. A non-SAC contract with a same-named function that takes different arguments will fail or misbehave — use `stellar contract invoke` for those.

**Usage:** `stellar token set-authorized [OPTIONS] --id <ID> --account <ACCOUNT> --authorize <AUTHORIZE> --source-account <SOURCE_ACCOUNT>`

###### **Global Options:**

- `--config-dir <CONFIG_DIR>` — Location of config directory. By default, it uses `$XDG_CONFIG_HOME/stellar` if set, falling back to `~/.config/stellar` otherwise. Contains configuration files, aliases, and other persistent settings

###### **Options:**

- `--id <ID>` — The token whose authorization to set: a contract id or alias, or a classic asset as `CODE:ISSUER`
- `--account <ACCOUNT>` — Account or contract whose authorization to set. Accepts a `G…` account, a `C…` contract address, or an alias
- `--authorize <AUTHORIZE>` — Whether the account is authorized (`true`) to hold and transact the token, or deauthorized/frozen (`false`)

Possible values: `true`, `false`

- `--output <OUTPUT>` — Format of the output

Default value: `text`

Possible values:
- `text`: Human-readable text
- `json`: Compact, single-line JSON output
- `json-formatted`: Formatted (multiline) JSON output

###### **RPC Options:**

- `--rpc-url <RPC_URL>` — RPC server endpoint
- `--rpc-header <RPC_HEADERS>` — RPC Header(s) to include in requests to the RPC provider, example: "X-API-Key: abc123". Multiple headers can be added by passing the option multiple times
- `--network-passphrase <NETWORK_PASSPHRASE>` — Network passphrase to sign the transaction sent to the rpc server
- `-n`, `--network <NETWORK>` — Name of network to use from config

###### **Signing Options:**

- `--sign-with-key <SIGN_WITH_KEY>` — Sign with a local key or key saved in OS secure storage. Can be an identity (--sign-with-key alice), a secret key (--sign-with-key SC36…), or a seed phrase (--sign-with-key "kite urban…"). If using seed phrase, `--hd-path` defaults to the `0` path
- `--hd-path <HD_PATH>` — If using a seed phrase to sign, sets which hierarchical deterministic path to use, e.g. `m/44'/148'/{hd_path}`. Example: `--hd-path 1`. Default: `0`
- `--sign-with-lab` — Sign with https://lab.stellar.org
- `--sign-with-ledger` — Sign with a ledger wallet
- `--auto-sign` — Sign without prompting for approval. Only applies to signatures that require user approval, like non-root Soroban auth entries

###### **Transaction Options:**

- `-s`, `--source-account <SOURCE_ACCOUNT>` [alias: `source`] — Account that where transaction originates from. Alias `source`. Can be an identity (--source alice), a public key (--source GDKW...), a muxed account (--source MDA…), a secret key (--source SC36…), or a seed phrase (--source "kite urban…"). If `--build-only` was NOT provided, this key will also be used to sign the final transaction. In that case, trying to sign with public key will fail
- `--fee <FEE>` — ⚠️ Deprecated, use `--inclusion-fee`. Fee amount for transaction, in stroops. 1 stroop = 0.0000001 xlm
- `--inclusion-fee <INCLUSION_FEE>` — Maximum fee amount for transaction inclusion, in stroops. 1 stroop = 0.0000001 xlm. Defaults to 100 if no arg, env, or config value is provided

## `stellar tx`

Sign, Simulate, and Send transactions
Expand Down
1 change: 1 addition & 0 deletions 1 cmd/crates/soroban-test/tests/it/integration/token/mod.rs
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pub mod mint;
pub mod name;
pub mod renamed;
pub mod set_admin;
pub mod set_authorized;
pub mod symbol;
pub mod transfer;
pub mod transfer_from;
Expand Down
266 changes: 266 additions & 0 deletions 266 cmd/crates/soroban-test/tests/it/integration/token/set_authorized.rs
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,266 @@
use serde_json::Value;
use soroban_test::{AssertExt, TestEnv};

use crate::integration::{
token::{add_trustline, deploy_sac, sac_id},
util::{deploy_hello, new_account, test_address},
};

/// Enable the revocable flag on `issuer`, required to deauthorize an existing
/// trustline.
fn enable_revocable(sandbox: &TestEnv, issuer: &str) {
sandbox
.new_assert_cmd("tx")
.args(["new", "set-options", "--set-revocable", "--source", issuer])
.assert()
.success();
}

/// Read whether `account` is authorized on the token through its SAC.
fn sac_authorized(sandbox: &TestEnv, contract_id: &str, account: &str) -> bool {
let stdout = sandbox
.new_assert_cmd("contract")
.args([
"invoke",
"--id",
contract_id,
"--source-account",
"test",
"--",
"authorized",
"--id",
account,
])
.assert()
.success()
.stdout_as_str();
stdout.trim().parse().unwrap()
}

#[tokio::test]
async fn set_authorized_toggles_authorization_and_returns_receipt() {
let sandbox = &TestEnv::new();
let test = test_address(sandbox);
let issuer = new_account(sandbox, "issuer");
let asset = format!("USDC:{issuer}");

// Deauthorizing an existing trustline requires the issuer to be revocable.
enable_revocable(sandbox, "issuer");
add_trustline(sandbox, "test", &asset);
deploy_sac(sandbox, &asset, "issuer");
let sac = sac_id(sandbox, &asset);

// A fresh trustline starts authorized.
assert!(
sac_authorized(sandbox, &sac, &test),
"trustline should start authorized"
);

let stdout = sandbox
.new_assert_cmd("token")
.args([
"set-authorized",
"--id",
&asset,
"--source",
"issuer",
"--account",
&test,
"--authorize",
"false",
"--output",
"json",
])
.assert()
.success()
.stdout_as_str();
let receipt: Value = serde_json::from_str(&stdout).unwrap();
assert!(
receipt["tx_hash"].as_str().is_some(),
"expected a tx hash, got: {receipt}"
);

// The account is now deauthorized on-chain.
assert!(
!sac_authorized(sandbox, &sac, &test),
"account should be deauthorized after set-authorized false"
);

sandbox
.new_assert_cmd("token")
.args([
"set-authorized",
"--id",
&asset,
"--source",
"issuer",
"--account",
&test,
"--authorize",
"true",
])
.assert()
.success();

assert!(
sac_authorized(sandbox, &sac, &test),
"account should be reauthorized after set-authorized true"
);
}

#[tokio::test]
async fn set_authorized_fails_when_sac_not_deployed() {
let sandbox = &TestEnv::new();
let test = test_address(sandbox);
let issuer = new_account(sandbox, "issuer");
let asset = format!("USDC:{issuer}");

// No SAC deployed → structured deploy-pointer error with a typed discriminator.
let stdout = sandbox
.new_assert_cmd("token")
.args([
"set-authorized",
"--id",
&asset,
"--source",
"issuer",
"--account",
&test,
"--authorize",
"true",
"--output",
"json",
])
.assert()
.failure()
.stdout_as_str();
let value: Value = serde_json::from_str(&stdout).unwrap();
assert_eq!(
value["error"]["type"], "sac_not_deployed",
"expected a typed error, got: {stdout}"
);
}

#[tokio::test]
async fn set_authorized_rejects_muxed_source_with_clear_error() {
let sandbox = &TestEnv::new();
let test = test_address(sandbox);

// Muxed (M…) source accounts aren't supported by the invoke pipeline yet
// (see #2645). Until then the command must reject them up front with a clear
// message rather than a raw strkey decode error deep in the pipeline.
let muxed = "MA3D5KRYM6CB7OWQ6TWYRR3Z4T7GNZLKERYNZGGA5SOAOPIFY6YQGAAAAAAAAAPCICBKU";
sandbox
.new_assert_cmd("token")
.args([
"set-authorized",
"--id",
"native",
"--source",
muxed,
"--account",
&test,
"--authorize",
"true",
])
.assert()
.failure()
.stderr(predicates::str::contains(
"muxed (M…) source accounts are not yet supported",
));
}

#[tokio::test]
async fn set_authorized_rejects_muxed_account_with_clear_error() {
let sandbox = &TestEnv::new();

// The SAC `set_authorized` target is a plain `Address`; a muxed (M…) account
// is rejected mid-simulation with an opaque error, so the command must reject
// one up front with a clear message.
let muxed = "MA3D5KRYM6CB7OWQ6TWYRR3Z4T7GNZLKERYNZGGA5SOAOPIFY6YQGAAAAAAAAAPCICBKU";
sandbox
.new_assert_cmd("token")
.args([
"set-authorized",
"--id",
"native",
"--source",
"test",
"--account",
muxed,
"--authorize",
"true",
])
.assert()
.failure()
.stderr(predicates::str::contains(
"muxed (M…) accounts are not yet supported",
));
}

#[tokio::test]
async fn set_authorized_warns_when_target_is_not_a_sac() {
let sandbox = &TestEnv::new();
let test = test_address(sandbox);
let contract_id = deploy_hello(sandbox).await;

// Pointing a SAC-admin command at a plain wasm contract warns. The call then
// fails (hello_world has no `set_authorized`), but the heads-up is the point.
let stderr = sandbox
.new_assert_cmd("token")
.args([
"set-authorized",
"--id",
&contract_id,
"--source",
"test",
"--account",
&test,
"--authorize",
"true",
])
.assert()
.failure()
.stderr_as_str();
assert!(
stderr.contains("is not a Stellar Asset Contract"),
"expected a non-SAC warning, got: {stderr}"
);
}

#[tokio::test]
async fn set_authorized_does_not_warn_when_target_is_a_sac() {
let sandbox = &TestEnv::new();
let test = test_address(sandbox);
let issuer = new_account(sandbox, "issuer");
let asset = format!("USDC:{issuer}");

add_trustline(sandbox, "test", &asset);
deploy_sac(sandbox, &asset, "issuer");
// Reference the SAC by its contract id, not the asset, so the check can only
// clear it by inspecting the on-chain executable — not the id's text form.
let sac = sac_id(sandbox, &asset);

// Re-authorizing an already-authorized trustline is a no-op success and needs
// no revocable flag — enough to exercise the SAC path without warning.
let stderr = sandbox
.new_assert_cmd("token")
.args([
"set-authorized",
"--id",
&sac,
"--source",
"issuer",
"--account",
&test,
"--authorize",
"true",
])
.assert()
.success()
.stderr_as_str();
assert!(
!stderr.contains("is not a Stellar Asset Contract"),
"a genuine SAC should not warn, got: {stderr}"
);
}
1 change: 1 addition & 0 deletions 1 cmd/soroban-cli/src/cli.rs
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ fn json_error_format(cmd: &commands::Cmd) -> Option<crate::output::Format> {
commands::Cmd::Token(token::Cmd::Mint(cmd)) => cmd.output.into(),
commands::Cmd::Token(token::Cmd::Clawback(cmd)) => cmd.output.into(),
commands::Cmd::Token(token::Cmd::SetAdmin(cmd)) => cmd.output.into(),
commands::Cmd::Token(token::Cmd::SetAuthorized(cmd)) => cmd.output.into(),
_ => return None,
};

Expand Down
12 changes: 12 additions & 0 deletions 12 cmd/soroban-cli/src/commands/token/mod.rs
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pub mod decimals;
pub mod mint;
pub mod name;
pub mod set_admin;
pub mod set_authorized;
pub mod symbol;
pub mod transfer;
pub mod transfer_from;
Expand Down Expand Up @@ -67,6 +68,13 @@ pub enum Cmd {
/// contract with a same-named function that takes different arguments will
/// fail or misbehave — use `stellar contract invoke` for those.
SetAdmin(set_admin::Cmd),

/// Authorize or deauthorize an account to hold the token (SAC admin)
///
/// Calls the token's Stellar Asset Contract `set_authorized` function. A
/// non-SAC contract with a same-named function that takes different arguments
/// will fail or misbehave — use `stellar contract invoke` for those.
SetAuthorized(set_authorized::Cmd),
}

#[derive(thiserror::Error, Debug)]
Expand Down Expand Up @@ -97,6 +105,8 @@ pub enum Error {
Clawback(#[from] clawback::Error),
#[error(transparent)]
SetAdmin(#[from] set_admin::Error),
#[error(transparent)]
SetAuthorized(#[from] set_authorized::Error),
}

impl Error {
Expand All @@ -117,6 +127,7 @@ impl Error {
Error::Mint(e) => e.error_type(),
Error::Clawback(e) => e.error_type(),
Error::SetAdmin(e) => e.error_type(),
Error::SetAuthorized(e) => e.error_type(),
}
}
}
Expand All @@ -137,6 +148,7 @@ impl Cmd {
Cmd::Mint(cmd) => cmd.run(global_args).await?,
Cmd::Clawback(cmd) => cmd.run(global_args).await?,
Cmd::SetAdmin(cmd) => cmd.run(global_args).await?,
Cmd::SetAuthorized(cmd) => cmd.run(global_args).await?,
}
Ok(())
}
Expand Down
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.