Skip to content

Frontend guide: replace the hand-written send and poll code in "Interacting with smart contracts" #2960

Closed

Description

@oceans404

Page: https://developers.stellar.org/docs/build/guides/dapps/frontend-guide#interacting-with-smart-contracts
File: docs/build/guides/dapps/frontend-guide.mdx:620-650

What's wrong:
The counter example sends and polls by hand, and part of it breaks on SDK v17 (current release v17.4.0):

  • It reads the return value with resultMetaXdr.v4().sorobanMeta()?.returnValue(). In v17, v4 is a property, not a method (v17.4.0 transaction-meta.ts#L227-L228), so .v4() throws.
  • It polls getTransaction in a while loop with no limit. The SDK has pollTransaction (v17.4.0).
  • It throws on any send status other than PENDING, so TRY_AGAIN_LATER and DUPLICATE read as failures.
  • A failed transaction is thrown as a string containing raw resultXdr.

Change needed:
Teach the SDK's contract client instead of the hand-written loop, or at least use the SDK's polling and return value. Link the SDK's "Invoke a Contract" guide for the full version.

Correct reference:

How to check the fix:

  • Run the updated counter example against testnet with @stellar/stellar-sdk 17.x installed: increment succeeds and the new count is shown.
  • No method-style XDR accessors are left in the snippet (.v4(), .sorobanMeta(), .switch(), .value()).
  • No hand-written polling loop is left; waiting goes through the SDK.
  • A failed call (for example, an unfunded account) shows a readable error, not raw XDR.
  • pnpm validate passes and the page renders on the preview deploy.
  • All SDK links in the page resolve.

Why it matters: This is the snippet the hand-written pipelines in HackMeridian 2026 repos match, often through AI tools reproducing it. 74 repos wrote their own build, simulate, send and poll file, and 31 wrote their own polling loop.

Related: #2564 (cross-links from JS tutorials to the SDK docs). The same page teaches the deprecated stellar contract bindings typescript command at line 820; that's a separate issue. The SDK's own send step also throws on anything but PENDING (v17.4.0 sent_transaction.ts#L85), so full TRY_AGAIN_LATER and DUPLICATE handling needs an SDK change too.

Activity

  1. stellar-doxie commented on Nov 1, 2026

    @stellar-doxie
    Contributor

    🤖 Automated message from the Stellar Triage Bot.

    I saw this issue. Nobody has called me in yet, so I will not act on it.

    How to reach me:

    • Anyone with write permission can call me in. Comment "/triage", add the bot:take label, or assign @kaankacar, @ElliotFriend or @wmendes.
    • The issue author can send me away with "/triage stop".
    • People with write permission can also add the bot:hands-off label.
  2. added
    bot:take
    on Nov 1, 2026
  3. oceans404 commented on Nov 1, 2026

    @oceans404
    ContributorAuthor

    /triage

  4. stellar-doxie commented on Nov 1, 2026

    @stellar-doxie
    Contributor

    🤖 Automated message from the Stellar Triage Bot.

    Working this because @oceans404 added bot:take.

    I am checking the claims against SDK v17 now. I will report back with a PR or a question.

  5. stellar-doxie commented on Nov 1, 2026

    @stellar-doxie
    Contributor

    🤖 Automated message from the Stellar Triage Bot.

    Working this because @oceans404 added bot:take.

    I opened #2975. The claims check out against SDK v17.4.0.

    • The example now uses pollTransaction, checks the send status and reads returnValue with scValToNative.
    • It also fixes e.value.u32() in the events snippet, which throws in v17 too.
    • I took the minimal option. A full contract client rewrite is a maintainer call.
    • The local checks did not run here. CI runs them on the PR.
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

    bot:takejs-sdk-v17

    Type

    No type

    Projects

    • Status
      No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions