Skip to content

Conversation

@chadoh
Copy link
Member

@chadoh chadoh commented Sep 9, 2025

Demonstrates a reasonable Step Two of the tutorial

- The HelloWorld contract is so simple as to be obtuse. It's confusing
  in its pointlessness. And it doesn't show off anything interesting
  about blockchain programming.

- GuessTheNumber represents a most-basic starting point for a contract
  that can show some interesting blockchain functionality. Already, it
  shows:

  - storing data
  - constructor
  - admin-guarded methods
  - forthcoming contracttrait composability pattern
    (stellar/rs-soroban-sdk#1522)
  - forthcoming admin SEP (https://github.com/AhaLabs/admin-sep)

- This represents the probable starting point for the contract. In its
  current state, it has many purposeful ommissions/shortcomings.

  - `unwrap` in `guess` causes error if admin did not yet call `reset`;
    need to extract number-setting logic to separate function and call
    it in both `reset` and `__constructor`
  - no XLM is currently owned by contract or awarded to winning guess;
    need to require XLM transfer from admin in `reset` as well as
    nominal fee to call `guess` (which gets added to pot)
  - can inspect contract storage to see stored number; need to obfuscate
    with fun crypto tricks

- These shortcomings would be addressed through an onboarding tutorial
  in the Stellar docs and maybe in the UI of the app itself, which so
  far has some very basic info about interacting with the contract
@chadoh chadoh marked this pull request as draft September 9, 2025 17:44

/// Guess a number between 1 and 10
pub fn guess(env: &Env, a_number: u64) -> bool {
pub fn guess(env: &Env, guesser: Address, a_number: u64) -> bool {
Copy link
Member Author

@chadoh chadoh Sep 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tutorial should explain why you need to pass guesser as an argument, instead of just requiring that the invoker—whoever they may be—signed the transaction. soroban-sdk is ~ToO fLeXiBLe~ to allow you to just check who the invoker is. This is unexpected! Make sure people understand it.

@chadoh chadoh force-pushed the feat/guess-the-number branch from 135ba07 to 6cd970d Compare October 2, 2025 16:35
Base automatically changed from feat/guess-the-number to main October 2, 2025 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants