Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

docs: add a guide for choosing a randomness source in contracts - #3223

Open
nema1502 wants to merge 4 commits into
stellar:mainfrom
nema1502:docs/randomness-guide
Open

nema1502 wants to merge 4 commits into
stellar:mainfrom
nema1502:docs/randomness-guide

Conversation

@nema1502

Copy link
Copy Markdown

Closes #2874

@kaankacar, this is the guide whose scope you approved on the issue (October 6). Could you review it?

What

A new page, docs/build/guides/conventions/choose-a-randomness-source.mdx, and one line in docs.json that adds it to Contract Conventions, in alphabetical order. It changes no other page.

The page starts from the problem: a contract can't toss a coin, so who could learn or tilt the result? Then it compares the options: the built-in PRNG, commit-reveal (with the PRNG, or between participants), a future drand quicknet round verified in the contract with the CAP-59 host functions, a drand relay, and a VRF oracle. For each one it says what it guarantees, what it leaves open, what it costs, and when to use it.

It includes:

The examples aren't production contracts: a warning on the page says why commit isn't safe to deploy as written.

What to look at first

  1. The third-party paragraph in "Three ways to bring the value on-chain". It names Drand-Relay and Stellar-VRF as examples, at pinned commits and without prices. Drand-Relay is yours, so a second reviewer for it would be welcome. If it shouldn't stay, it's one paragraph to delete.
  2. "Commit to a future round": the margin, and the way out when a round never arrives, are judgment calls, and the page says why it makes them.
  3. The Mainnet rent comparison in "Measured costs".
  4. Length. It covers the scope approved on the issue. If you'd rather have two pages, the natural cut is options and trade-offs in one, and verifying a drand round plus Measured costs in the other.

Disclosure

I build Tinkazo, a draw project that verifies drand rounds on Soroban, as I said on the issue. The guide and the example repository don't name or link it.

Things to know

  • Why the example is in its own repository. It carries the measured data and the exact Wasm behind the cost table. If it helps, I can bring the commit-reveal contract to stellar/soroban-examples in a separate PR, since Write an example that uses PRNG soroban-examples#255 asks for a PRNG example.
  • Versions. The pinned links to Stellar code, and the example, use the versions that Software Versions lists for protocol 30 on Mainnet (soroban-sdk 29.0.1). soroban-sdk 30.0.0 came out on November 24. I can move the example to it once Software Versions lists it.
  • Where it lives. The page is under Contract Conventions. If it belongs elsewhere, tell me before merging, so the URL doesn't have to move later.

How I checked it (November 29, 2026)

  • The steps of pnpm check pass, except that mint broken-links flags links to /assets/ on other pages, because my local clone leaves that folder out. It reports nothing on this page, and CI runs it on a full checkout.
  • Every Rust block is the same text as the example's source, and every formula and number on the page is recomputed from the measured data.
  • In mint dev, the page renders its five Mermaid diagrams and all its math without errors, in light and dark mode and at phone width.
  • The example repository: cargo test --locked --workspace passes (26 tests, plus 2 that need the built Wasm), and the build gives the same Wasm, byte for byte, as the one measured. Its CI runs the tests on every push.

Say default branch for the CAP links, which point to master. Define the
close time as CAP-88 does: the validator proposes it, and the ledger
timestamp is that value rounded down to whole seconds. Name the closed
stellar-core pull request that implemented ECVRF, which the issue cites.
Shorter paragraphs, fewer sentences that only announce the next section, a Mainnet rent caveat next to the first cost table, VRF and oracle in the glossary, and the Looking ahead section now says what CAP-89 is today and what to plan for.
@mintlify

mintlify Bot commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit ca5eb7c.

Approve preview

@stellar-doxie

stellar-doxie Bot commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

🤖 Automated message from Doxie.

Commenting because this is a new community PR. I saw it, but nobody has called me in yet, so I did not review it.

How to reach me:

  • Anyone with write permission on this repo can call me in with a /triage comment or the bot:take label.
  • The PR author can send me away with /triage stop. People with write permission can also use the bot:hands-off label.
  • A review request to a maintainer does not call me in. It asks for that person's judgment.

This branch has not been deployed

No deployments
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.

Add an options guide for randomness in Soroban contracts

1 participant