Files
xrpl-dev-portal/content/_snippets/generate-step.md
mDuo13 eb0b9a66e5 Use Tickets tutorial upgrades
- Use Devnet for live examples
- Move code to a dedicated JS file instead of having it all inline
- Improve transaction submission logic
2021-02-01 19:05:33 -08:00

2.6 KiB

{% if faucet_url is undefined %} {% set faucet_url = "https://faucet.altnet.rippletest.net/accounts" %} {% endif %}

{{ start_step("Generate") }} Generate credentials

Generating Keys...
{{ end_step() }} <script type="application/javascript"> $(document).ready( () => {

$("#generate-creds-button").click( () => { // Wipe existing results $("#address").html("") $("#secret").html("") $("#balance").html("") $("#populate-creds-status").html("")

$("#loader-generate").show()

$.ajax({
  url: "{{faucet_url}}",
  type: 'POST',
  dataType: 'json',
  success: function(data) {
    $("#loader-generate").hide()
    $("#address").hide().html("<strong>Address:</strong> " +
      '<span id="use-address">' +
      data.account.address
      + "</span>").show()
    $("#secret").hide().html('<strong>Secret:</strong> ' +
      '<span id="use-secret">' +
      data.account.secret +
      "</span>").show()
    $("#balance").hide().html('<strong>Balance:</strong> ' +
      Number(data.balance).toLocaleString('en') +
      ' XRP').show()

    // Automatically populate examples with these credentials...
    // Set sender address
    $("code span:contains('"+EXAMPLE_ADDR+"')").each( function() {
      let eltext = $(this).text()
      $(this).text( eltext.replace(EXAMPLE_ADDR, data.account.address) )
    })

    // Set sender secret
    $("code span:contains('"+EXAMPLE_SECRET+"')").each( function() {
      let eltext = $(this).text()
      $(this).text( eltext.replace(EXAMPLE_SECRET, data.account.secret) )
    })

    $("#populate-creds-status").text("Populated this page's examples with these credentials.")

    complete_step("Generate")

  },
  error: function() {
    $("#loader-generate").hide();
    alert("There was an error with the Testnet. Please try again.");
  }
})

})

const EXAMPLE_ADDR = "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe" const EXAMPLE_SECRET = "s████████████████████████████"

}) </script>

Caution: Ripple provides the XRP Ledger Testnet for testing purposes only, and regularly resets the state of the test net along with all balances. As a precaution, Ripple recommends not using the same addresses on Testnet and Mainnet.