mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-20 19:55:54 +00:00
Refactor Send XRP: reliable sub, folders by language
- Use reliable transaction submission methods where available - Update text to describe the functions (esp. xrpl.js 2.0 stuff) - Move Send XRP code samples to subfolders by language for consistency with other tutorials
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
// In browsers, use a <script> tag. In Node.js, uncomment the following line:
|
||||
// const xrpl = require('xrpl')
|
||||
|
||||
// Wrap code in an async function so we can use await
|
||||
async function main() {
|
||||
|
||||
@@ -7,7 +10,7 @@ async function main() {
|
||||
|
||||
// ... custom code goes here
|
||||
|
||||
// Disconnect when done so Node.js can end the process
|
||||
// Disconnect when done (If you omit this, Node.js won't end the process)
|
||||
client.disconnect()
|
||||
}
|
||||
|
||||
|
||||
53
content/_code-samples/send-xrp/js/send-xrp.js
Normal file
53
content/_code-samples/send-xrp/js/send-xrp.js
Normal file
@@ -0,0 +1,53 @@
|
||||
// Dependencies for Node.js.
|
||||
// In browsers, use a <script> tag instead.
|
||||
if (typeof module !== "undefined") {
|
||||
// gotta use var here because const/let are block-scoped to the if statement.
|
||||
var xrpl = require('xrpl')
|
||||
}
|
||||
|
||||
// Example credentials
|
||||
const wallet = xrpl.Wallet.fromSeed("sn3nxiW7v8KXzPzAqzyHXbSSKNuN9")
|
||||
|
||||
// Connect -------------------------------------------------------------------
|
||||
async function main() {
|
||||
console.log("Connecting to Testnet...")
|
||||
const api = new xrpl.Client('wss://s.altnet.rippletest.net:51233')
|
||||
await api.connect()
|
||||
|
||||
// Get credentials from the Testnet Faucet -----------------------------------
|
||||
console.log("Getting a wallet from the Testnet faucet...")
|
||||
const {wallet, balance} = await api.fundWallet()
|
||||
|
||||
// Prepare transaction -------------------------------------------------------
|
||||
const prepared = await api.autofill({
|
||||
"TransactionType": "Payment",
|
||||
"Account": wallet.address,
|
||||
"Amount": xrpl.xrpToDrops("22"),
|
||||
"Destination": "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe"
|
||||
})
|
||||
const max_ledger = prepared.LastLedgerSequence
|
||||
console.log("Prepared transaction instructions:", prepared)
|
||||
console.log("Transaction cost:", xrpl.dropsToXrp(prepared.Fee), "XRP")
|
||||
console.log("Transaction expires after ledger:", max_ledger)
|
||||
|
||||
// Sign prepared instructions ------------------------------------------------
|
||||
const signed = wallet.sign(prepared)
|
||||
console.log("Identifying hash:", signed.hash)
|
||||
console.log("Signed blob:", signed.tx_blob)
|
||||
|
||||
// Submit signed blob --------------------------------------------------------
|
||||
const tx = await api.submitSignedReliable(signed.tx_blob)
|
||||
// This raises an exception if the transaction isn't confirmed.
|
||||
|
||||
// Wait for validation -------------------------------------------------------
|
||||
// submitSignedReliable() handles this automatically, but it can take 4-7s.
|
||||
|
||||
// Check transaction results -------------------------------------------------
|
||||
console.log("Transaction result:", tx.result.meta.TransactionResult)
|
||||
console.log("Balance changes:", JSON.stringify(xrpl.getBalanceChanges(tx.result.meta), null, 2))
|
||||
|
||||
// End of main()
|
||||
api.disconnect()
|
||||
}
|
||||
|
||||
main()
|
||||
@@ -34,35 +34,13 @@ print("Transaction expires after ledger:", max_ledger)
|
||||
print("Identifying hash:", tx_id)
|
||||
|
||||
# Submit transaction -----------------------------------------------------------
|
||||
validated_index = xrpl.ledger.get_latest_validated_ledger_sequence(client)
|
||||
min_ledger = validated_index + 1
|
||||
print(f"Can be validated in ledger range: {min_ledger} - {max_ledger}")
|
||||
|
||||
# Tip: you can use xrpl.transaction.send_reliable_submission(signed_tx, client)
|
||||
# to send the transaction and wait for the results to be validated.
|
||||
try:
|
||||
prelim_result = xrpl.transaction.submit_transaction(signed_tx, client)
|
||||
except xrpl.clients.XRPLRequestFailureException as e:
|
||||
tx_response = xrpl.transaction.send_reliable_submission(signed_tx, client)
|
||||
except xrpl.transaction.XRPLReliableSubmissionException as e:
|
||||
exit(f"Submit failed: {e}")
|
||||
print("Preliminary transaction result:", prelim_result)
|
||||
|
||||
# Wait for validation ----------------------------------------------------------
|
||||
# Note: If you used xrpl.transaction.send_reliable_submission, you can skip this
|
||||
# and use the result of that method directly.
|
||||
from time import sleep
|
||||
while True:
|
||||
sleep(1)
|
||||
validated_ledger = xrpl.ledger.get_latest_validated_ledger_sequence(client)
|
||||
tx_response = xrpl.transaction.get_transaction_from_hash(tx_id, client)
|
||||
if tx_response.is_successful():
|
||||
if tx_response.result.get("validated"):
|
||||
print("Got validated result!")
|
||||
break
|
||||
else:
|
||||
print(f"Results not yet validated... "
|
||||
f"({validated_ledger}/{max_ledger})")
|
||||
if validated_ledger > max_ledger:
|
||||
print("max_ledger has passed. Last tx response:", tx_response)
|
||||
# send_reliable_submission() handles this automatically, but it can take 4-7s.
|
||||
|
||||
# Check transaction results ----------------------------------------------------
|
||||
import json
|
||||
@@ -1,87 +0,0 @@
|
||||
// Example credentials
|
||||
const wallet = xrpl.Wallet.fromSeed("sn3nxiW7v8KXzPzAqzyHXbSSKNuN9")
|
||||
|
||||
// Connect ---------------------------------------------------------------------
|
||||
// const xrpl = require('xrpl') // For Node.js. In browsers, use <script>.
|
||||
const api = new xrpl.Client('wss://s.altnet.rippletest.net:51233')
|
||||
api.connect()
|
||||
api.on('connected', async () => {
|
||||
|
||||
// Get credentials from the Testnet Faucet -----------------------------------
|
||||
console.log("Getting a wallet from the Testnet faucet...")
|
||||
const {wallet, balance} = await api.fundWallet()
|
||||
|
||||
// Prepare transaction -------------------------------------------------------
|
||||
const prepared = await api.autofill({
|
||||
"TransactionType": "Payment",
|
||||
"Account": wallet.address,
|
||||
"Amount": xrpl.xrpToDrops("22"),
|
||||
"Destination": "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe"
|
||||
})
|
||||
const max_ledger = prepared.LastLedgerSequence
|
||||
console.log("Prepared transaction instructions:", prepared)
|
||||
console.log("Transaction cost:", xrpl.dropsToXrp(prepared.Fee), "XRP")
|
||||
console.log("Transaction expires after ledger:", max_ledger)
|
||||
|
||||
// Sign prepared instructions ------------------------------------------------
|
||||
const signed = wallet.sign(prepared)
|
||||
console.log("Identifying hash:", signed.hash)
|
||||
console.log("Signed blob:", signed.tx_blob)
|
||||
|
||||
// Submit signed blob --------------------------------------------------------
|
||||
// The earliest ledger a transaction could appear in is the first ledger
|
||||
// after the one that's already validated at the time it's *first* submitted.
|
||||
const min_ledger = (await api.getLedgerIndex()) + 1
|
||||
const result = await api.submit(signed.tx_blob)
|
||||
console.log("Tentative result code:", result.result.engine_result)
|
||||
console.log("Tentative result message:", result.result.engine_result_message)
|
||||
|
||||
// Wait for validation -------------------------------------------------------
|
||||
let has_final_status = false
|
||||
api.request({
|
||||
"command": "subscribe",
|
||||
"accounts": [wallet.address]
|
||||
})
|
||||
api.connection.on("transaction", (event) => {
|
||||
if (event.transaction.hash == signed.hash) {
|
||||
console.log("Transaction has executed!", event)
|
||||
has_final_status = true
|
||||
}
|
||||
})
|
||||
api.on('ledgerClosed', ledger => {
|
||||
if (ledger.ledger_index > max_ledger && !has_final_status) {
|
||||
console.log("Ledger version", ledger.ledger_index, "was validated.")
|
||||
console.log("If the transaction hasn't succeeded by now, it's expired")
|
||||
has_final_status = true
|
||||
}
|
||||
})
|
||||
|
||||
// There are other ways to do this, but they're more complicated.
|
||||
// See https://xrpl.org/reliable-transaction-submission.html for details.
|
||||
while (!has_final_status) {
|
||||
await new Promise(resolve => setTimeout(resolve, 1000))
|
||||
}
|
||||
|
||||
// Check transaction results -------------------------------------------------
|
||||
try {
|
||||
const tx = await api.request({
|
||||
command: "tx",
|
||||
transaction: signed.hash,
|
||||
min_ledger: min_ledger,
|
||||
max_ledger: max_ledger
|
||||
})
|
||||
if (tx.result.validated) {
|
||||
console.log("This result is validated by consensus and final.")
|
||||
} else {
|
||||
console.log("This result is pending.")
|
||||
}
|
||||
console.log("Transaction result:", tx.result.meta.TransactionResult)
|
||||
|
||||
if (typeof tx.result.meta.delivered_amount === "string" &&
|
||||
typeof tx.result.meta.delivered_amount !== "unavailable")
|
||||
console.log("Delivered:", xrpl.dropsToXrp(tx.result.meta.delivered_amount), "XRP")
|
||||
} catch(error) {
|
||||
console.log("Couldn't get transaction outcome:", error)
|
||||
}
|
||||
|
||||
}) // End of api.on.('connected')
|
||||
@@ -42,15 +42,15 @@ To transact on the XRP Ledger, you need an address and secret key, and some XRP.
|
||||
|
||||
_JavaScript_
|
||||
|
||||
{{ include_code("_code-samples/send-xrp/send-xrp.js", end_before="// Connect", language="js") }}
|
||||
{{ include_code("_code-samples/send-xrp/js/send-xrp.js", start_with="// Example credentials", end_before="// Connect", language="js") }}
|
||||
|
||||
_Python_
|
||||
|
||||
{{ include_code("_code-samples/send-xrp/send-xrp.py", end_before="# Connect", language="py") }}
|
||||
{{ include_code("_code-samples/send-xrp/py/send-xrp.py", end_before="# Connect", language="py") }}
|
||||
|
||||
_Java_
|
||||
|
||||
{{ include_code("_code-samples/send-xrp/SendXrp.java", end_before="// Connect", language="java") }}
|
||||
{{ include_code("_code-samples/send-xrp/java/SendXrp.java", end_before="// Connect", language="java") }}
|
||||
|
||||
<!-- MULTICODE_BLOCK_END -->
|
||||
|
||||
@@ -63,23 +63,23 @@ When you're [building actual production-ready software](production-readiness.htm
|
||||
|
||||
### {{n.next()}}. Connect to a Testnet Server
|
||||
|
||||
First, you must connect to an XRP Ledger server so you can get the current status of your account and the shared ledger. You can use this information to automatically fill in certain required fields of a transaction. (For more security, you can sign transactions from a machine that doesn't have an internet connection, but only if you can provide all of the necessary details.) You also must be connected to the network to submit transactions to it.
|
||||
First, you must connect to an XRP Ledger server so you can get the current status of your account and the shared ledger. You can use this information to [automatically fill in some required fields of a transaction](transaction-common-fields.html#auto-fillable-fields). You also must be connected to the network to submit transactions to it.
|
||||
|
||||
The following code connects to one of the public Testnet servers that Ripple runs:
|
||||
The following code connects to a public Testnet servers:
|
||||
|
||||
<!-- MULTICODE_BLOCK_START -->
|
||||
|
||||
_JavaScript_
|
||||
|
||||
{{ include_code("_code-samples/send-xrp/send-xrp.js", start_with="// Connect", end_before="// Get credentials", language="js") }}
|
||||
{{ include_code("_code-samples/get-started/js/base.js", language="js") }}
|
||||
|
||||
_Python_
|
||||
|
||||
{{ include_code("_code-samples/send-xrp/send-xrp.py", start_with="# Connect", end_before="# Get credentials", language="py") }}
|
||||
{{ include_code("_code-samples/send-xrp/py/send-xrp.py", start_with="# Connect", end_before="# Get credentials", language="py") }}
|
||||
|
||||
_Java_
|
||||
|
||||
{{ include_code("_code-samples/send-xrp/SendXrp.java", start_with="// Connect", end_before="// Prepare transaction", language="java") }}
|
||||
{{ include_code("_code-samples/send-xrp/java/SendXrp.java", start_with="// Connect", end_before="// Prepare transaction", language="java") }}
|
||||
|
||||
<!-- MULTICODE_BLOCK_END -->
|
||||
|
||||
@@ -122,15 +122,15 @@ Here's an example of preparing the above payment:
|
||||
|
||||
_JavaScript_
|
||||
|
||||
{{ include_code("_code-samples/send-xrp/send-xrp.js", start_with="// Prepare", end_before="// Sign", language="js" ) }}
|
||||
{{ include_code("_code-samples/send-xrp/js/send-xrp.js", start_with="// Prepare", end_before="// Sign", language="js" ) }}
|
||||
|
||||
_Python_
|
||||
|
||||
{{ include_code("_code-samples/send-xrp/send-xrp.py", start_with="# Prepare", end_before="# Sign", language="py" ) }}
|
||||
{{ include_code("_code-samples/send-xrp/py/send-xrp.py", start_with="# Prepare", end_before="# Sign", language="py" ) }}
|
||||
|
||||
_Java_
|
||||
|
||||
{{ include_code("_code-samples/send-xrp/SendXrp.java", start_with="// Prepare", end_before="// Sign", language="java") }}
|
||||
{{ include_code("_code-samples/send-xrp/java/SendXrp.java", start_with="// Prepare", end_before="// Sign", language="java") }}
|
||||
|
||||
<!-- MULTICODE_BLOCK_END -->
|
||||
|
||||
@@ -164,17 +164,17 @@ Signing a transaction uses your credentials to authorize the transaction on your
|
||||
|
||||
_JavaScript_
|
||||
|
||||
{{ include_code("_code-samples/send-xrp/send-xrp.js",
|
||||
{{ include_code("_code-samples/send-xrp/js/send-xrp.js",
|
||||
start_with="// Sign", end_before="// Submit", language="js" ) }}
|
||||
|
||||
_Python_
|
||||
|
||||
{{ include_code("_code-samples/send-xrp/send-xrp.py",
|
||||
{{ include_code("_code-samples/send-xrp/py/send-xrp.py",
|
||||
start_with="# Sign", end_before="# Submit", language="py" ) }}
|
||||
|
||||
_Java_
|
||||
|
||||
{{ include_code("_code-samples/send-xrp/SendXrp.java",
|
||||
{{ include_code("_code-samples/send-xrp/java/SendXrp.java",
|
||||
start_with="// Sign", end_before="// Submit", language="java" ) }}
|
||||
|
||||
<!-- MULTICODE_BLOCK_END -->
|
||||
@@ -204,14 +204,14 @@ Now that you have a signed transaction, you can submit it to an XRP Ledger serve
|
||||
|
||||
_JavaScript_
|
||||
|
||||
{{ include_code("_code-samples/send-xrp/send-xrp.js", start_with="// Submit", end_before="// Wait", language="js" ) }}
|
||||
{{ include_code("_code-samples/send-xrp/js/send-xrp.js", start_with="// Submit", end_before="// Wait", language="js" ) }}
|
||||
|
||||
_Python_
|
||||
|
||||
{{ include_code("_code-samples/send-xrp/send-xrp.py", start_with="# Submit", end_before="# Wait", language="py") }}
|
||||
{{ include_code("_code-samples/send-xrp/py/send-xrp.py", start_with="# Submit", end_before="# Wait", language="py") }}
|
||||
|
||||
_Java_
|
||||
{{ include_code("_code-samples/send-xrp/SendXrp.java", start_with="// Submit", end_before="// Wait", language="java" ) }}
|
||||
{{ include_code("_code-samples/send-xrp/java/SendXrp.java", start_with="// Submit", end_before="// Wait", language="java" ) }}
|
||||
|
||||
<!-- MULTICODE_BLOCK_END -->
|
||||
|
||||
@@ -238,10 +238,9 @@ example transaction</button>
|
||||
|
||||
Most transactions are accepted into the next ledger version after they're submitted, which means it may take 4-7 seconds for a transaction's outcome to be final. If the XRP Ledger is busy or poor network connectivity delays a transaction from being relayed throughout the network, a transaction may take longer to be confirmed. (For more information on expiration of unconfirmed transactions, see [Reliable Transaction Submission](reliable-transaction-submission.html).)
|
||||
|
||||
- **JavaScript:** Use an account [subscription](rippleapi-reference.html#listening-to-streams) to listen for an event when the transaction is confirmed. Use the `ledger` event type to trigger your code to run whenever there is a new validated ledger version so that you can know if the transaction can no longer be confirmed.
|
||||
- **Python:** Poll the [`xrpl.transaction.get_transaction_from_hash()` method](https://xrpl-py.readthedocs.io/en/latest/source/xrpl.transaction.html#xrpl.transaction.get_transaction_from_hash) to see if your transaction has a final result. Periodically use the [`xrpl.ledger.get_latest_validated_ledger_sequence()` method](https://xrpl-py.readthedocs.io/en/latest/source/xrpl.ledger.html#xrpl.ledger.get_latest_validated_ledger_sequence) so you can know if the transaction can no longer be confirmed.
|
||||
- **JavaScript:** If you used the [`.submitSignedReliable()` method](https://js.xrpl.org/classes/Client.html#submitSignedReliable), you can wait until the returned Promise resolves. Other, more asynchronous approaches are also possible.
|
||||
|
||||
**Tip:** The [`xrpl.transaction.send_reliable_submission()` method](https://xrpl-py.readthedocs.io/en/latest/source/xrpl.transaction.html#xrpl.transaction.send_reliable_submission) handles this process all in one call. You can use this instead of `submit_transaction()` wherever it's appropriate for your code to stop and wait for a transaction's [final result](finality-of-results.html) to be confirmed.
|
||||
- **Python:** If you used the [`xrpl.transaction.send_reliable_submission()` method](https://xrpl-py.readthedocs.io/en/latest/source/xrpl.transaction.html#xrpl.transaction.send_reliable_submission), you can wait for the function to return. Other approaches, including asynchronous ones using the WebSocket client, are also possible.
|
||||
|
||||
- **Java** Poll the [`XrplClient.transaction()` method](https://javadoc.io/doc/org.xrpl/xrpl4j-client/latest/org/xrpl/xrpl4j/client/XrplClient.html#transaction(org.xrpl.xrpl4j.model.client.transactions.TransactionRequestParams,java.lang.Class)) to see if your transaction has a final result. Periodically check that the latest validated ledger index has not passed the `LastLedgerIndex` of the transaction using the [`XrplClient.ledger()`](https://javadoc.io/doc/org.xrpl/xrpl4j-client/latest/org/xrpl/xrpl4j/client/XrplClient.html#ledger(org.xrpl.xrpl4j.model.client.ledger.LedgerRequestParams)) method.
|
||||
|
||||
@@ -249,15 +248,15 @@ Most transactions are accepted into the next ledger version after they're submit
|
||||
|
||||
_JavaScript_
|
||||
|
||||
{{ include_code("_code-samples/send-xrp/send-xrp.js", start_with="// Wait", end_before="// There are other", language="js" ) }}
|
||||
{{ include_code("_code-samples/send-xrp/js/send-xrp.js", start_with="// Wait", end_before="// Check", language="js" ) }}
|
||||
|
||||
_Python_
|
||||
|
||||
{{ include_code("_code-samples/send-xrp/send-xrp.py", start_with="# Wait", end_before="# Check", language="py") }}
|
||||
{{ include_code("_code-samples/send-xrp/py/send-xrp.py", start_with="# Wait", end_before="# Check", language="py") }}
|
||||
|
||||
_Java_
|
||||
|
||||
{{ include_code("_code-samples/send-xrp/SendXrp.java", start_with="// Wait", end_before="// Check", language="java" ) }}
|
||||
{{ include_code("_code-samples/send-xrp/java/SendXrp.java", start_with="// Wait", end_before="// Check", language="java" ) }}
|
||||
|
||||
<!-- MULTICODE_BLOCK_END -->
|
||||
|
||||
@@ -270,29 +269,31 @@ _Java_
|
||||
|
||||
To know for sure what a transaction did, you must look up the outcome of the transaction when it appears in a validated ledger version.
|
||||
|
||||
- **JavaScript:** Use the [`getTransaction()` method](rippleapi-reference.html#gettransaction) to check the status of a transaction.
|
||||
- **Python:** The response of [`xrpl.transaction.get_transaction_from_hash()` method](https://xrpl-py.readthedocs.io/en/latest/source/xrpl.transaction.html#xrpl.transaction.get_transaction_from_hash) contains the results if the transaction has been validated by consensus. (See the [tx method response format](tx.html#response-format) for a detailed reference of the fields this can contain.)
|
||||
- **JavaScript:** Use the response from `submitSignedReliable()` or call the [tx method][] using [`Client.request()`](https://js.xrpl.org/classes/Client.html#request).
|
||||
|
||||
**Tip:** In **TypeScript** you can pass a [`TxRequest`](https://js.xrpl.org/interfaces/TxRequest.html) to the [`Client.request()`](https://js.xrpl.org/classes/Client.html#request) method.
|
||||
|
||||
- **Python:** Use the response from `send_reliable_submission()` or call the [`xrpl.transaction.get_transaction_from_hash()` method](https://xrpl-py.readthedocs.io/en/latest/source/xrpl.transaction.html#xrpl.transaction.get_transaction_from_hash). (See the [tx method response format](tx.html#response-format) for a detailed reference of the fields this can contain.)
|
||||
|
||||
- **Java:** Use the [`XrplClient.transaction()`](https://javadoc.io/doc/org.xrpl/xrpl4j-client/latest/org/xrpl/xrpl4j/client/XrplClient.html#transaction(org.xrpl.xrpl4j.model.client.transactions.TransactionRequestParams,java.lang.Class)) method to check the status of a transaction.
|
||||
|
||||
<!-- MULTICODE_BLOCK_START -->
|
||||
|
||||
_JavaScript_
|
||||
|
||||
{{ include_code("_code-samples/send-xrp/send-xrp.js", start_with="// Check", language="js" ) }}
|
||||
{{ include_code("_code-samples/send-xrp/js/send-xrp.js", start_with="// Check", end_before="// End of", language="js" ) }}
|
||||
|
||||
_Python_
|
||||
|
||||
{{ include_code("_code-samples/send-xrp/send-xrp.py", start_with="# Check", language="py") }}
|
||||
{{ include_code("_code-samples/send-xrp/py/send-xrp.py", start_with="# Check", language="py") }}
|
||||
|
||||
_Java_
|
||||
|
||||
{{ include_code("_code-samples/send-xrp/SendXrp.java", start_with="// Check", language="java" ) }}
|
||||
{{ include_code("_code-samples/send-xrp/java/SendXrp.java", start_with="// Check", language="java" ) }}
|
||||
|
||||
<!-- MULTICODE_BLOCK_END -->
|
||||
|
||||
The RippleAPI `getTransaction()` method only returns success if the transaction is in a validated ledger version. Otherwise, the `await` expression raises an exception.
|
||||
|
||||
**Caution:** Other APIs, including `xrpl-py`, may return tentative results from ledger versions that have not yet been validated. For example, if you use the `rippled` APIs' [tx method][], be sure to look for `"validated": true` in the response to confirm that the data comes from a validated ledger version. Transaction results that are not from a validated ledger version are subject to change. For more information, see [Finality of Results](finality-of-results.html).
|
||||
**Caution:** XRP Ledger APIs may return tentative results from ledger versions that have not yet been validated. For example, in [tx method][] response, be sure to look for `"validated": true` to confirm that the data comes from a validated ledger version. Transaction results that are not from a validated ledger version are subject to change. For more information, see [Finality of Results](finality-of-results.html).
|
||||
|
||||
{{ start_step("Check") }}
|
||||
<button id="get-tx-button" class="btn btn-primary previous-steps-required">Check transaction status</button>
|
||||
@@ -316,9 +317,9 @@ This tutorial uses a button to get an address that's already funded with Test Ne
|
||||
_JavaScript_
|
||||
|
||||
```js
|
||||
const generated = api.generateAddress()
|
||||
console.log(generated.address) // Example: rGCkuB7PBr5tNy68tPEABEtcdno4hE6Y7f
|
||||
console.log(generated.secret) // Example: sp6JS7f14BuwFY8Mw6bTtLKWauoUs
|
||||
const wallet = new xrpl.Wallet()
|
||||
console.log(wallet.address) // Example: rGCkuB7PBr5tNy68tPEABEtcdno4hE6Y7f
|
||||
console.log(wallet.seed) // Example: sp6JS7f14BuwFY8Mw6bTtLKWauoUs
|
||||
```
|
||||
|
||||
_Python_
|
||||
|
||||
Reference in New Issue
Block a user