`stellar contract invoke` panics when contract function returns spec type `SC_SPEC_TYPE_VAL`

Open
#2,438 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
rust
Domain
cli

Research direction

Start with the result-formatting path used by stellar contract invoke, focusing on handling ScType::Val and the SC_SPEC_TYPE_VAL contract return type. Reproduce the panic with the provided Bool(false) contract and invocation steps. Done means the command completes without panicking and displays the returned value, including false and other ScVal variants.

Written by the indexing model from the issue text.

Description

bug
What version are you using?

stellar-cli 25.1.0

What did you do?

When a Soroban contract function has return type Val (which maps to SC_SPEC_TYPE_VAL in the contract spec), and the function returns Bool(false), calling the function via stellar contract invoke panics.

Minimal reproducing contract:

#![no_std]

use soroban_sdk::{contract, contractimpl, Env, Val};

#[contract]
pub struct BoolFalseContract;

#[contractimpl]
impl BoolFalseContract {
    pub fn retval(_env: Env) -> Val {
        Val::from_bool(false).into()
    }
}

Cargo.toml:

[package]
name = "bool_false_poc"
version = "0.1.0"
edition = "2021"
publish = false

[lib]
crate-type = ["cdylib"]

[dependencies]
soroban-sdk = "25.1.0"

[dev-dependencies]
soroban-sdk = { version = "25.1.0", features = ["testutils"] }

[profile.release]
opt-level = "z"
overflow-checks = true
debug = 0
strip = "symbols"
debug-assertions = false
panic = "abort"
codegen-units = 1
lto = true

Steps to reproduce:

# Build the contract
cargo build --release --target wasm32-unknown-unknown

# Deploy to local network
stellar contract deploy \
  --wasm target/wasm32-unknown-unknown/release/bool_false_poc.wasm \
  --source deployer --network local --alias bool-false-poc

# Invoke the function — this panics
stellar contract invoke --id bool-false-poc --source deployer --network local -- retval
What did you expect to see?

The CLI should successfully display the return value, e.g.:

false
What did you see instead?

The CLI panics with:

thread 'main' panicked at 'not yet implemented: Bool(false,) doesn't have a matching Val'
Notes
  • The contract itself executes correctly — the issue is purely in the CLI's result formatting
  • All non-Void ScVal variants are affected when the spec type is SC_SPEC_TYPE_VAL, not just Bool
  • A fix would need to handle ScType::Val for all ScVal variants, likely by recursively inferring the concrete type from the value itself
Dominant language
Rust
Stars
123
Forks
141
Avg merge
2d 21h
Merged PRs (30d)
17

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from stellar/stellar-cli

All issues in stellar/stellar-cli

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.