Skip to content

Build assembled transactions before signing in the archival and simulation examples #2906

Closed

Description

@kalepail

Note

Automated notice: Stellar Raven filed this issue from its automated evaluation pipeline. The issue includes evidence and a public source record. Please verify the live surface before you act.

Finding

Two archival examples call sign() on the builder returned by assembleTransaction().
The non-restoration branch fails with TypeError: prepTx.sign is not a function.
Readers cannot submit the documented transaction.

The same mistake appears in the multi-party transaction-simulation example.
Both transaction-simulation examples call Server() without new.
Example 1 also calls prepareTransaction() without await, then tries to sign the returned promise.

The fee-payer signing guide already calls .build() correctly.

Evidence

Live reads on 2026-10-09 confirm these published source examples:

  • Archival guide, source docs/build/guides/archival/restore-data-js.mdx:63.
  • State archival example, source docs/learn/fundamentals/contract-development/storage/state-archival.mdx:270.
  • Example 1, source docs/learn/fundamentals/contract-development/contract-interactions/transaction-simulation.mdx:75,97.
  • Multi-party example, source docs/learn/fundamentals/contract-development/contract-interactions/transaction-simulation.mdx:129,184.

The source snapshot preserves the tested examples.
The observed SDK version is @stellar/stellar-sdk 17.2.1.
This observation does not identify the release that introduced the mistakes.

Install the tested SDK in an empty directory:

npm install --ignore-scripts @stellar/[email protected]

Run this minimal reproduction with node --input-type=module:

import { Account, BASE_FEE, Keypair, Networks, Operation,
  SorobanDataBuilder, TransactionBuilder, rpc } from "@stellar/stellar-sdk";
const signer = Keypair.random();
const tx = new TransactionBuilder(new Account(signer.publicKey(), "0"), {
  fee: BASE_FEE, networkPassphrase: Networks.TESTNET,
}).setTimeout(30).addOperation(Operation.invokeContractFunction({
  contract: "CDLZFC3SYJYDZT7K67VZ75HPJVIEUVNIXF47ZG2FB2RMQQVU2HHGCYSC",
  function: "symbol", args: [],
})).build();
const sim = { _parsed: true, latestLedger: 1, events: [],
  transactionData: new SorobanDataBuilder(), minResourceFee: "0",
  result: { auth: [] } };
const prepTx = rpc.assembleTransaction(tx, sim);
try { prepTx.sign(signer); } catch (error) { console.log(String(error)); }
try { rpc.Server("https://soroban-testnet.stellar.org"); }
catch (error) { console.log(String(error)); }
const s = new rpc.Server("https://soroban-testnet.stellar.org");
s.simulateTransaction = async () => sim;
const preppedTx = s.prepareTransaction(tx);
try { preppedTx.sign(signer); } catch (error) { console.log(String(error)); }
const corrected = await preppedTx;
corrected.sign(signer);
rpc.assembleTransaction(tx, sim).build().sign(signer);

The output shows these errors with SDK 17.2.1:

TypeError: prepTx.sign is not a function
TypeError: Class constructor RpcServer cannot be invoked without 'new'
TypeError: preppedTx.sign is not a function

The final two signing calls succeed.
The reproduction uses a local simulation response and makes no network request.

Additional local checks extract both archival functions and supply local RPC fixtures.
They run assembly and signing through the installed SDK.
They submit no transaction to a network.
Both non-restoration branches reach the reported signing error.

After adding .build(), the restoration branch fails because its builder has no time bounds.
The examples also omit the Operation import used in that branch.
Their linked submitTx helper returns undefined status and throws undefined tmpStatus.
The successful polling branch fails with ReferenceError: status is not defined.

The local correction adds .build(), supplies Operation, and sets restoration time bounds.
It returns or throws finalStatus in the polling helper.
Both archival functions then pass their non-restoration and restoration branches with signed local transactions.
The retry uses sequence 2 after the restoration consumes sequence 1.
The corrected polling helper passes its success and failure branches.

A local check also executes the repeated multi-party example.
The original first fails at server construction, before assembly.
The corrected flow uses current operation arguments, XDR fields, and awaited simulation and authorization calls.
Its local address-credential fixture passes authorization signing, assembly, envelope signing, and mocked submission.

The repository scan found three examples with the missing build step.
Other assembly examples in the fee-payer, simulation deep-dive, and Relayer guides already call .build().

Additional recorded evidence:

  • 2026-10-09 current stellar/stellar-docs source commit 2efd1d5
  • 2026-10-09 @stellar/stellar-sdk 17.2.1 local reproduction
  • 2026-10-09 repeated-example scan
  • 2026-10-09 multi-party reproduction

Recommendation

Call assembleTransaction(tx, sim).build() before signing in all three repeated examples.
Add the required Operation import and restoration time bounds to both archival examples.
Correct the linked polling helper to return or throw finalStatus.

Update both transaction-simulation examples to use new Server() and getAccount().
Add await to Example 1's prepareTransaction() call.
Use named invokeContractFunction arguments and import BASE_FEE, nativeToScVal, and Address.
Set transaction time bounds in both examples.
Await simulateTransaction() in the multi-party example.

Use current XDR fields to select the address signer.
Await authorization calls with Promise.all() and use simResult.latestLedger for expiration.
Build the assembled transaction before signing it.

Keep the correct .build() calls in the other guides.
Validate the repaired examples against the supported SDK with local success and restoration fixtures.

Source Record

Raven recorded this finding as sd-055 (stellar-docs, discovered 2026-10-09).

Public source record: improvements/stellar-docs/sd-055-assembly-examples-sign-unbuilt-builders.md

Immutable source snapshot: 6f2ddd72b3a2

Resolution Handoff

When you deploy a fix, link the resolving issue or pull request to the source record.
Then notify Raven through:

https://github.com/stellar-experimental/stellar-raven/issues/new?template=upstream-improvement-ready.yml&title=%5Bupstream-ready%5D%20sd-055%3A%20

Include the finding ID and the resolving issue or pull request.
Include the deployed version or timestamp. Include the smallest live recheck.
Raven verifies the live surface before it sets the finding to fixed-upstream.
An issue closure or merged pull request does not prove the fix.
A separate reviewer repeats the live check before Raven retires the active finding.
Raven keeps a commit-pinned snapshot when one is available.

Activity

  1. added
    raven
    on Oct 9, 2026
  2. stellar-doxie commented on Oct 30, 2026

    @stellar-doxie
    Contributor

    🤖 Automated message from the Stellar Triage Bot.

    Working this because it is a Raven-filed issue (label raven).

    I am checking the archival and simulation examples against the current SDK. I will post the outcome here.

  3. stellar-doxie commented on Oct 30, 2026

    @stellar-doxie
    Contributor

    🤖 Automated message from the Stellar Triage Bot.

    Working this because it is a Raven-filed issue (label raven).

    An open PR already fixes this: #2933 ("Closes #2906"). I will not open a second PR.

  4. kalepail commented on Nov 2, 2026

    @kalepail
    ContributorAuthor

    Raven independently rechecked sd-055 on 2026-11-02 and confirmed the original trigger is resolved live.

    Live recheck: 2026-11-02T22:24Z of the deployed Markdown (GET https://developers.stellar.org/<path>.md, HTTP 200): restore-data-js line 62 and state-archival line 259 now call assembleTransaction(tx, sim).build() before sign; both import Operation and set .setTimeout(30) on the restoreFootprint builder; submit-transaction-wait-js returns or throws finalStatus; transaction-simulation uses new Server(...), await s.getAccount(...), BASE_FEE, nativeToScVal, named invokeContractFunction arguments, setTimeout(30), await s.prepareTransaction(tx) in Example 1, await s.simulateTransaction(tx), Promise.all over auth entries with simResult.latestLedger + 12, and assembleTransaction(tx, simResult).build() before sign in Example 2.

    One related defect is outside this issue: the contract-restoration example on restore-contract-js and state-archival. The open #2562 reports part of it, and Raven added the remaining details there: #2562 (comment)

    The active finding is being retired under the ephemeral improvements lifecycle. Immutable source snapshot: https://github.com/stellar-experimental/stellar-raven/blob/26e4e4207eb59da0268a9b1c71b181cf35b61c1f/improvements/stellar-docs/sd-055-assembly-examples-sign-unbuilt-builders.md

  5. added a commit that references this issue on Nov 3, 2026
    50531cb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    raven

    Type

    No type

    Projects

    • Status
      No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions