From b0359388a2aafaa819b6319aa493ff0df9316dcc Mon Sep 17 00:00:00 2001 From: mDuo13 Date: Wed, 21 Jul 2021 16:32:07 -0700 Subject: [PATCH] Start Issue a Token tutorial --- assets/js/tutorials/issue-a-token.js | 70 +++++++++++++++++ .../require-destination-tags.md | 2 +- .../use-tokens/issue-a-fungible-token.md | 76 +++++++++++++++++++ dactyl-config.yml | 16 ++++ 4 files changed, 163 insertions(+), 1 deletion(-) create mode 100644 assets/js/tutorials/issue-a-token.js create mode 100644 content/tutorials/use-tokens/issue-a-fungible-token.md diff --git a/assets/js/tutorials/issue-a-token.js b/assets/js/tutorials/issue-a-token.js new file mode 100644 index 0000000000..94f5c40c86 --- /dev/null +++ b/assets/js/tutorials/issue-a-token.js @@ -0,0 +1,70 @@ +// Variant setup for generate creds button from interactive-tutorial.js. +// This version generates two sets of creds, one for the issuer and one for +// the hot wallet / receiver + +const EXAMPLE_COLD_ADDR = "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe" +const EXAMPLE_COLD_SECRET = "sIss█████████████████████████" +function setup_2x_generate_step() { + + $("#generate-2x-creds-button").click( async (event) => { + const block = $(event.target).closest(".interactive-block") + block.find(".output-area").html("") + block.find(".loader").show() + // Get faucet URL (Testnet/Devnet/etc.) + const faucet_url = $("#generate-2x-creds-button").data("fauceturl") + + try { + const data = await call_faucet(faucet_url) + const data2 = await call_faucet(faucet_url) + + block.find(".loader").hide() + block.find(".output-area").html(`
+
+
${tl("Cold Address:")} + ${data.account.address}
+
${tl("Cold Secret:")} + ${data.account.secret}
+ ${tl("XRP Balance:")} + ${Number(data.balance).toLocaleString(current_locale)} XRP +
+
+
${tl("Hot Address:")} + ${data2.account.address}
+
${tl("Hot Secret:")} + ${data2.account.secret}
+ ${tl("XRP Balance:")} + ${Number(data2.balance).toLocaleString(current_locale)} XRP +
+
`) + + // TODO: Automatically populate all examples in the page with the + // generated credentials... + // $("code span:contains('"+EXAMPLE_ADDR+"')").each( function() { + // let eltext = $(this).text() + // $(this).text( eltext.replace(EXAMPLE_ADDR, data.account.address) ) + // }) + // $("code span:contains('"+EXAMPLE_SECRET+"')").each( function() { + // let eltext = $(this).text() + // $(this).text( eltext.replace(EXAMPLE_SECRET, data.account.secret) ) + // }) + // + // block.find(".output-area").append(`

${tl("Populated this page's examples with these credentials.")}

`) + + complete_step("Generate") + + } catch(err) { + block.find(".loader").hide() + block.find(".output-area").html( + `

${tl("Error:")} + ${tl("There was an error connecting to the Faucet. Please try again.")} +

`) + return + } + }) +} + + + +$(document).ready(() => { + setup_2x_generate_step() +}) diff --git a/content/tutorials/manage-account-settings/require-destination-tags.md b/content/tutorials/manage-account-settings/require-destination-tags.md index 09ebcfccfd..67f2a9cbfb 100644 --- a/content/tutorials/manage-account-settings/require-destination-tags.md +++ b/content/tutorials/manage-account-settings/require-destination-tags.md @@ -42,7 +42,7 @@ When you're [building actual production-ready software](production-readiness.htm You must be connected to the network to submit transactions to it. -The following code uses a [ripple-lib for JavaScript](rippleapi-reference.html) instance to connect to a public XRP Testnet server: +The following code uses a [ripple-lib for JavaScript](rippleapi-reference.html) instance to connect to a public XRP Ledger Testnet server: ```js ripple = require('ripple-lib') // Node.js only. Use a + + +## Steps +{% set n = cycler(* range(1,99)) %} +### {{n.next()}}. Get Credentials + +To transact on the XRP Ledger, you need an address and secret key, and some XRP. For development purposes, you can get these using the following interface: + + +{% if use_network is undefined or use_network == "Testnet" %} + {% set use_network = "Testnet" %} + {% set faucet_url = "https://faucet.altnet.rippletest.net/accounts" %} +{% elif use_network == "Devnet" %} + {% set faucet_url = "https://faucet.devnet.rippletest.net/accounts" %} +{# No faucet for Mainnet! #} +{% endif %} +{{ start_step("Generate") }} + +
Generating Keys...
+
+{{ end_step() }} + +**Caution:** Ripple provides the [Testnet and Devnet](parallel-networks.html) for testing purposes only, and sometimes resets the state of these test networks along with all balances. As a precaution, **do not** use the same addresses on Testnet/Devnet and Mainnet. + + +When you're [building actual production-ready software](production-readiness.html), you'll instead use an existing account, and manage your keys using a [secure signing configuration](set-up-secure-signing.html). + +### {{n.next()}}. Connect to the Network + +You must be connected to the network to submit transactions to it. + +The following code uses a [ripple-lib for JavaScript](rippleapi-reference.html) instance to connect to a public XRP Ledger Testnet server: + +```js +ripple = require('ripple-lib') // Node.js only. Use a