Skip to content

Show two possible formats of Escrow sample code #3241

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mDuo13
Copy link
Collaborator

@mDuo13 mDuo13 commented Aug 15, 2025

This is an experiment to collect feedback on preferred formats for sample code.

It creates two alternative code samples for sending a time-based escrow:

  1. send-timed-escrow-linear.js puts as much action as possible at the top level of the file, so that it resolves in a very linear order. This lends itself well to tutorials that have numbered steps, and the control flow is simply "top to bottom".
  2. send-timed-escrow-functions.js splits the action up into several functions and uses a main() function to call them. This shows the overall control flow first, and compartmentalizes the steps so that the parameters required at each step are more obvious. It's also a little closer to something you could import as a library/module. This lends itself more to a tutorial with a "code walkthrough" rather than numbered steps.

The third and fourth options, not presented here, are:

  1. A commandline utility similar to verify_credential.js that parses user input for values instead of using hard-coded values.
  2. A graphical interface such as the one in Create Time Based Escrows Using JavaScript.

Currently we are inclined towards options 1 or 2 because they are easier to write and have fewer distractions from the XRPL-specific parts of the code.

@mDuo13 mDuo13 added the javascript Pull requests that update Javascript code label Aug 15, 2025
@mDuo13
Copy link
Collaborator Author

mDuo13 commented Aug 16, 2025

For the record, this is related to #3230 and the objectives and priorities laid out there. Specifically, the goals of this project are:

  1. Modernize our sample code and tutorials, and reduce the maintenance burden involved in keeping them updated and consistent going forward.

  2. Refine our standard format and improve consistency of the sample code so that it's easier to go from one tutorial to another without getting confused because of how different they are.

  3. Produce a larger quantity of tutorials and sample code, with a mind towards enabling large language models (LLMs) to generate more high-quality code that uses the XRP Ledger.

    Personal Aside: I really don't recommend "vibe coding" with blockchains; security issues and other mistakes can be subtle and costly, and I've personally seen AIs talk about following proper security practices while simultaneously producing code that violates those practices and puts your secret keys at risk. But since people are going to be using code-generation tools regardless, we may as well do what we can to help them work better.

@shortthefomo
Copy link
Contributor

+1 for option one with the STEPS. As previous examples have been like this and switching that up now not the best IMO.
Also makes it clear do this then that.... vs functions one misses that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
javascript Pull requests that update Javascript code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants