Skip to content

Code blocks on RPC sendTransaction page fail #1390

Closed

Description

@leighmcculloch

This issue captures a couple issues with the examples on the sendTransaction RPC page:

1‍⃣ The Python SDK guide on the RPC sendTransaction page does not work as it is missing a step.

Image

https://developers.stellar.org/docs/data/rpc/api-reference/methods/sendTransaction

It shows creating a contract invocation and then signing and submitting the transaction without calling prepare_transaction. The transaction is guaranteed to error in this case because it's not configured with fees or resources.

To make the transaction succeed, at the least you need to call the following prior to signing:

transaction = server.prepare_transaction(transaction)

2‍⃣ A second issue is that all the examples (Python, JS, Java) still wouldn't work out of the box, because they references a contract that doesn't exist. Instead of using a random increment contract, the example could be written to use the CDLZFC3SYJYDZT7K67VZ75HPJVIEUVNIXF47ZG2FB2RMQQVU2HHGCYSC contract, which is the native asset on the test network. The example could get the balance of a known predictable address such as the network root account.

The example would then create a much better developer experience, be ready to go without the developer having to navigate so many errors.

cc @stellar/platform-eng

Activity

  1. added
    bug
    on Mar 11, 2025
  2. ElliotFriend commented on Mar 18, 2025

    @ElliotFriend
    Contributor

    @overcat Any chance you could chime in with some insights or a PR?

  3. overcat commented on Mar 19, 2025

    @overcat
    Contributor

    The reason for the failure is as @leighmcculloch mentioned, we did not call prepare_transaction. I will submit a PR later to fix this use case.

    Additionally, after each testnet reset, the use cases may become unexecutable, users need to manually modify the keys and contract addresses. Perhaps we can prepare a preset script to initialize these keys and contracts after each testnet reset?

  4. ElliotFriend commented on Mar 19, 2025

    @ElliotFriend
    Contributor

    Thanks so much for the PR @overcat!!

    We do have "someday" plans to create a testnet reset script that would help with a lot of similar issues in the docs. We closed the issue (#519) since it was a bit stale, but we still have it "on the books" in our discussions "dream journal" (#1197)

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

    bug

    Type

    No type

    Projects

    • Status
      No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions