mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-25 22:25:52 +00:00
Address review comments
This commit is contained in:
@@ -2,4 +2,4 @@
|
|||||||
|
|
||||||
Code samples showing how to create and submit a [Batch transaction](https://xrpl.org/docs/concepts/transactions/batch-transactions).
|
Code samples showing how to create and submit a [Batch transaction](https://xrpl.org/docs/concepts/transactions/batch-transactions).
|
||||||
|
|
||||||
Both for single and multi account batch transactions.
|
Both for single and multi-account batch transactions.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
Code samples showing how to create and submit a [Batch transaction](https://xrpl.org/docs/concepts/transactions/batch-transactions) with Javascript.
|
Code samples showing how to create and submit a [Batch transaction](https://xrpl.org/docs/concepts/transactions/batch-transactions) with Javascript.
|
||||||
|
|
||||||
Both for single and multi account batch transactions.
|
Both for single and multi-account batch transactions.
|
||||||
|
|
||||||
## Single Account Batch Transaction
|
## Single Account Batch Transaction
|
||||||
|
|
||||||
|
|||||||
@@ -13,11 +13,18 @@ const client = new xrpl.Client("wss://s.devnet.rippletest.net:51233/")
|
|||||||
await client.connect()
|
await client.connect()
|
||||||
|
|
||||||
// Create and fund wallets
|
// Create and fund wallets
|
||||||
console.log("=== Funding new wallets from faucet... ===")
|
console.log("=== Funding new wallets from faucet... ===");
|
||||||
const { wallet: alice } = await client.fundWallet()
|
const [
|
||||||
const { wallet: bob } = await client.fundWallet()
|
{ wallet: alice },
|
||||||
const { wallet: charlie } = await client.fundWallet()
|
{ wallet: bob },
|
||||||
const { wallet: thirdPartyWallet } = await client.fundWallet()
|
{ wallet: charlie },
|
||||||
|
{ wallet: thirdPartyWallet },
|
||||||
|
] = await Promise.all([
|
||||||
|
client.fundWallet(),
|
||||||
|
client.fundWallet(),
|
||||||
|
client.fundWallet(),
|
||||||
|
client.fundWallet(),
|
||||||
|
]);
|
||||||
|
|
||||||
console.log(`Alice: ${alice.address}, Balance: ${await client.getXrpBalance(alice.address)} XRP`)
|
console.log(`Alice: ${alice.address}, Balance: ${await client.getXrpBalance(alice.address)} XRP`)
|
||||||
console.log(`Bob: ${bob.address}, Balance: ${await client.getXrpBalance(bob.address)} XRP`)
|
console.log(`Bob: ${bob.address}, Balance: ${await client.getXrpBalance(bob.address)} XRP`)
|
||||||
@@ -26,7 +33,7 @@ console.log(`Third-party wallet: ${thirdPartyWallet.address}, Balance: ${await c
|
|||||||
|
|
||||||
// Create inner transactions --------------------------------------------
|
// Create inner transactions --------------------------------------------
|
||||||
// REQUIRED: Inner transactions MUST have the tfInnerBatchTxn flag (0x40000000).
|
// REQUIRED: Inner transactions MUST have the tfInnerBatchTxn flag (0x40000000).
|
||||||
// This marks them as part of a batch (allows Fee: 0 and empty SigningPubKey).
|
// This marks them as part of a batch (requires Fee: 0 and empty SigningPubKey).
|
||||||
|
|
||||||
// Transaction 1: Charlie pays Alice
|
// Transaction 1: Charlie pays Alice
|
||||||
const charliePayment = {
|
const charliePayment = {
|
||||||
@@ -63,8 +70,8 @@ console.log(JSON.stringify(batchTx, null, 2))
|
|||||||
// Validate the transaction structure
|
// Validate the transaction structure
|
||||||
xrpl.validate(batchTx)
|
xrpl.validate(batchTx)
|
||||||
|
|
||||||
// Set the expected number of signers for this transaction.
|
// Set the expected number of signers, which is 2 (Bob and Charlie) in this case, for this transaction.
|
||||||
// "autofill" will automatically add Fee: "0" and SigningPubKey: "".
|
// "autofill" will automatically add Fee: "0" and SigningPubKey: "" to inner transactions.
|
||||||
const autofilledBatchTx = await client.autofill(batchTx, 2)
|
const autofilledBatchTx = await client.autofill(batchTx, 2)
|
||||||
|
|
||||||
// Gather batch signatures --------------------------------
|
// Gather batch signatures --------------------------------
|
||||||
@@ -91,6 +98,7 @@ const submitResponse = await client.submitAndWait(combinedSignedTx,
|
|||||||
if (submitResponse.result.meta.TransactionResult !== "tesSUCCESS") {
|
if (submitResponse.result.meta.TransactionResult !== "tesSUCCESS") {
|
||||||
const resultCode = submitResponse.result.meta.TransactionResult
|
const resultCode = submitResponse.result.meta.TransactionResult
|
||||||
console.warn(`\nTransaction failed with result code ${resultCode}`)
|
console.warn(`\nTransaction failed with result code ${resultCode}`)
|
||||||
|
await client.disconnect()
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,6 +129,7 @@ for (let i = 0; i < rawTransactions.length; i++) {
|
|||||||
}
|
}
|
||||||
if (hasFailure) {
|
if (hasFailure) {
|
||||||
console.error("\n--- Error: One or more inner transactions failed. ---")
|
console.error("\n--- Error: One or more inner transactions failed. ---")
|
||||||
|
await client.disconnect()
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,10 +14,13 @@ const client = new xrpl.Client("wss://s.devnet.rippletest.net:51233/")
|
|||||||
await client.connect()
|
await client.connect()
|
||||||
|
|
||||||
// Create and fund wallets
|
// Create and fund wallets
|
||||||
console.log("=== Funding new wallets from faucet... ===")
|
console.log("=== Funding new wallets from faucet... ===");
|
||||||
const { wallet: sender } = await client.fundWallet()
|
const [{ wallet: sender }, { wallet: wallet1 }, { wallet: wallet2 }] =
|
||||||
const { wallet: wallet1 } = await client.fundWallet()
|
await Promise.all([
|
||||||
const { wallet: wallet2 } = await client.fundWallet()
|
client.fundWallet(),
|
||||||
|
client.fundWallet(),
|
||||||
|
client.fundWallet(),
|
||||||
|
]);
|
||||||
|
|
||||||
console.log(`Sender: ${sender.address}, Balance: ${await client.getXrpBalance(sender.address)} XRP`)
|
console.log(`Sender: ${sender.address}, Balance: ${await client.getXrpBalance(sender.address)} XRP`)
|
||||||
console.log(`Wallet1: ${wallet1.address}, Balance: ${await client.getXrpBalance(wallet1.address)} XRP`)
|
console.log(`Wallet1: ${wallet1.address}, Balance: ${await client.getXrpBalance(wallet1.address)} XRP`)
|
||||||
@@ -25,7 +28,7 @@ console.log(`Wallet2: ${wallet2.address}, Balance: ${await client.getXrpBalance(
|
|||||||
|
|
||||||
// Create inner transactions --------------------------------------------
|
// Create inner transactions --------------------------------------------
|
||||||
// REQUIRED: Inner transactions MUST have the tfInnerBatchTxn flag (0x40000000).
|
// REQUIRED: Inner transactions MUST have the tfInnerBatchTxn flag (0x40000000).
|
||||||
// This marks them as part of a batch (allows Fee: 0 and empty SigningPubKey).
|
// This marks them as part of a batch (requires Fee: 0 and empty SigningPubKey).
|
||||||
|
|
||||||
// Transaction 1
|
// Transaction 1
|
||||||
const payment1 = {
|
const payment1 = {
|
||||||
@@ -66,7 +69,7 @@ xrpl.validate(batchTx)
|
|||||||
console.log("\n=== Submitting Batch transaction... ===")
|
console.log("\n=== Submitting Batch transaction... ===")
|
||||||
const submitResponse = await client.submitAndWait(batchTx, {
|
const submitResponse = await client.submitAndWait(batchTx, {
|
||||||
wallet: sender,
|
wallet: sender,
|
||||||
// "autofill" will automatically add Fee: "0" and SigningPubKey: "".
|
// "autofill" will automatically add Fee: "0" and SigningPubKey: "" to inner transactions.
|
||||||
autofill: true
|
autofill: true
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -74,6 +77,7 @@ const submitResponse = await client.submitAndWait(batchTx, {
|
|||||||
if (submitResponse.result.meta.TransactionResult !== "tesSUCCESS") {
|
if (submitResponse.result.meta.TransactionResult !== "tesSUCCESS") {
|
||||||
const resultCode = submitResponse.result.meta.TransactionResult
|
const resultCode = submitResponse.result.meta.TransactionResult
|
||||||
console.warn(`\nTransaction failed with result code ${resultCode}`)
|
console.warn(`\nTransaction failed with result code ${resultCode}`)
|
||||||
|
await client.disconnect()
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
}
|
}
|
||||||
console.log("\nBatch transaction submitted successfully!")
|
console.log("\nBatch transaction submitted successfully!")
|
||||||
@@ -103,6 +107,7 @@ for (let i = 0; i < rawTransactions.length; i++) {
|
|||||||
}
|
}
|
||||||
if (hasFailure) {
|
if (hasFailure) {
|
||||||
console.error("\n--- Error: One or more inner transactions failed. ---")
|
console.error("\n--- Error: One or more inner transactions failed. ---")
|
||||||
|
await client.disconnect()
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,14 +9,14 @@ labels:
|
|||||||
---
|
---
|
||||||
# Send a Multi-Account Batch Transaction
|
# Send a Multi-Account Batch Transaction
|
||||||
|
|
||||||
This tutorial shows you how to create a [Batch transaction][] containing transactions from multiple accounts, where each account must sign the Batch transaction. Any account, even one not involved in the inner transactions, can submit the batch.
|
This tutorial shows you how to create a [Batch transaction][] containing transactions from multiple accounts, where each account must sign the `Batch` transaction. Any account, even one not involved in the inner transactions, can submit the batch.
|
||||||
|
|
||||||
## Goals
|
## Goals
|
||||||
|
|
||||||
By the end of this tutorial, you will be able to:
|
By the end of this tutorial, you will be able to:
|
||||||
|
|
||||||
- Create a Batch transaction with multiple inner transactions, signed by multiple accounts, and submitted by a third party account.
|
- Create a `Batch` transaction with multiple inner transactions, signed by multiple accounts, and submitted by a third party account.
|
||||||
- Configure the Batch transaction to ensure atomicity, so that either all inner transactions succeed or they all fail.
|
- Configure the `Batch` transaction to ensure atomicity, so that either all inner transactions succeed or they all fail.
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@ You can find the complete source code for this tutorial's examples in the [code
|
|||||||
|
|
||||||
## Steps
|
## Steps
|
||||||
|
|
||||||
The example in this tutorial demonstrates a scenario where Bob and Charlie both owe Alice 50 XRP each, and a third-party (such as a payment processor) submits the Batch transaction atomically to ensure Alice is paid by both parties.
|
The example in this tutorial demonstrates a scenario where Bob and Charlie both owe Alice 50 XRP each, and a third-party (such as a payment processor) submits the `Batch` transaction atomically to ensure Alice is paid by both parties.
|
||||||
|
|
||||||
### 1. Install dependencies
|
### 1. Install dependencies
|
||||||
|
|
||||||
@@ -69,25 +69,25 @@ Next, prepare the inner transactions that will be included in the batch.
|
|||||||
|
|
||||||
The first transaction sends a payment of 50 XRP from Charlie to Alice, and the second sends a payment of 50 XRP from Bob to Alice. Both transactions must include the `tfInnerBatchTxn` (0x40000000) flag to indicate that they are inner transactions of a batch.
|
The first transaction sends a payment of 50 XRP from Charlie to Alice, and the second sends a payment of 50 XRP from Bob to Alice. Both transactions must include the `tfInnerBatchTxn` (0x40000000) flag to indicate that they are inner transactions of a batch.
|
||||||
|
|
||||||
Inner transactions must have a Fee of **0** and an empty string for the `SigningPubKey`. The outer Batch transaction handles the overall fee and signing for all inner transactions.
|
Inner transactions must have a Fee of **0** and an empty string for the `SigningPubKey`. The outer `Batch` transaction handles the overall fee and signing for all inner transactions.
|
||||||
|
|
||||||
{% admonition type="info" name="Note" %}
|
{% admonition type="info" name="Note" %}
|
||||||
The `Fee` and `SigningPubKey` fields are omitted as the client library's _autofill_ functionality automatically populates these when submitting the Batch transaction.
|
The `Fee` and `SigningPubKey` fields are omitted as the client library's _autofill_ functionality automatically populates these when submitting the `Batch` transaction.
|
||||||
|
|
||||||
You typically don't need to set these manually, but if you do, ensure `Fee` is set to 0 and `SigningPubKey` is an empty string.
|
You typically don't need to set these manually, but if you do, ensure `Fee` is set to 0 and `SigningPubKey` is an empty string.
|
||||||
{% /admonition %}
|
{% /admonition %}
|
||||||
|
|
||||||
### 4. Prepare Batch transaction
|
### 4. Prepare Batch transaction
|
||||||
|
|
||||||
Create the Batch transaction and provide the inner transactions. The key fields to note are:
|
Create the `Batch` transaction and provide the inner transactions. The key fields to note are:
|
||||||
|
|
||||||
| Field | Value |
|
| Field | Value |
|
||||||
|:---------------- |:---------- |
|
|:---------------- |:---------- |
|
||||||
| TransactionType | The type of transaction, in this case `Batch`.|
|
| TransactionType | The type of transaction, in this case `Batch`.|
|
||||||
| Account | The wallet address of the account that is sending the Batch transaction. |
|
| Account | The wallet address of the account that is sending the `Batch` transaction. |
|
||||||
| Flags | The flags for the Batch transaction. For this example the transaction is configured with the `tfAllOrNothing` (0x00010000) flag to ensure that either all inner transactions succeed or they all fail atomically. See [Batch Flags](../../../references/protocol/transactions/types/batch.md#batch-flags) for other options. |
|
| Flags | The flags for the `Batch` transaction. For this example the transaction is configured with the `tfAllOrNothing` (0x00010000) flag to ensure that either all inner transactions succeed or they all fail atomically. See [Batch Flags](../../../references/protocol/transactions/types/batch.md#batch-flags) for other options. |
|
||||||
| RawTransactions | Contains the list of inner transactions to be applied. Must include a minimum of **2** transactions and a maximum of **8** transactions. These transactions can come from one account or multiple accounts. |
|
| RawTransactions | Contains the list of inner transactions to be applied. Must include a minimum of **2** transactions and a maximum of **8** transactions. These transactions can come from one account or multiple accounts. |
|
||||||
| BatchSigners | The list of signatures required for the Batch transaction. This is required because there are multiple accounts' transactions included in the batch. |
|
| BatchSigners | The list of signatures required for the `Batch` transaction. This is required because there are multiple accounts' transactions included in the batch. |
|
||||||
|
|
||||||
{% tabs %}
|
{% tabs %}
|
||||||
{% tab label="Javascript" %}
|
{% tab label="Javascript" %}
|
||||||
@@ -99,20 +99,20 @@ Because we used `autofill`, the client library automatically fills in any missin
|
|||||||
|
|
||||||
### 5. Gather batch signatures
|
### 5. Gather batch signatures
|
||||||
|
|
||||||
To add the `BatchSigners` field, you need to collect signatures from each account that's sending a transaction within the batch. In this case we need two signatures, one from Charlie and one from Bob. Each sender must sign the Batch transaction to authorize their payment.
|
To add the `BatchSigners` field, you need to collect signatures from each account that's sending a transaction within the batch. In this case we need two signatures, one from Charlie and one from Bob. Each sender must sign the `Batch` transaction to authorize their payment.
|
||||||
|
|
||||||
{% tabs %}
|
{% tabs %}
|
||||||
{% tab label="Javascript" %}
|
{% tab label="Javascript" %}
|
||||||
The **xrpl.js** library provides a helper function, `signMultiBatch()`, to sign the Batch transaction for each account.
|
The **xrpl.js** library provides a helper function, `signMultiBatch()`, to sign the `Batch` transaction for each account.
|
||||||
|
|
||||||
Then, to combine the signatures into a single signed Batch transaction, use the `combineBatchSigners()` utility function.
|
Then, to combine the signatures into a single signed `Batch` transaction, use the `combineBatchSigners()` utility function.
|
||||||
{% code-snippet file="/_code-samples/batch/js/multiAccountBatch.js" language="js" from="// Gather batch signatures" to="// Submit" /%}
|
{% code-snippet file="/_code-samples/batch/js/multiAccountBatch.js" language="js" from="// Gather batch signatures" to="// Submit" /%}
|
||||||
{% /tab %}
|
{% /tab %}
|
||||||
{% /tabs %}
|
{% /tabs %}
|
||||||
|
|
||||||
### 6. Submit Batch transaction
|
### 6. Submit Batch transaction
|
||||||
|
|
||||||
With all the required signatures gathered, the third-party wallet can now submit the Batch transaction.
|
With all the required signatures gathered, the third-party wallet can now submit the `Batch` transaction.
|
||||||
|
|
||||||
{% tabs %}
|
{% tabs %}
|
||||||
{% tab label="Javascript" %}
|
{% tab label="Javascript" %}
|
||||||
@@ -122,7 +122,7 @@ With all the required signatures gathered, the third-party wallet can now submit
|
|||||||
|
|
||||||
### 7. Check Batch transaction result
|
### 7. Check Batch transaction result
|
||||||
|
|
||||||
To check the result of the Batch transaction submission:
|
To check the result of the `Batch` transaction submission:
|
||||||
|
|
||||||
{% tabs %}
|
{% tabs %}
|
||||||
{% tab label="Javascript" %}
|
{% tab label="Javascript" %}
|
||||||
@@ -133,14 +133,14 @@ To check the result of the Batch transaction submission:
|
|||||||
The code checks for a `tesSUCCESS` result and displays the response details.
|
The code checks for a `tesSUCCESS` result and displays the response details.
|
||||||
|
|
||||||
{% admonition type="warning" name="Warning" %}
|
{% admonition type="warning" name="Warning" %}
|
||||||
A `tesSUCCESS` result indicates that the Batch transaction was processed successfully, but does not guarantee the inner transactions succeeded. For example, see the [following transaction on the XRPL Explorer](https://devnet.xrpl.org/transactions/20CFCE5CF75E93E6D1E9C1E42F8E8C8C4CB1786A65BE23D2EA77EAAB65A455C5/simple).
|
A `tesSUCCESS` result indicates that the `Batch` transaction was processed successfully, but does not guarantee the inner transactions succeeded. For example, see the [following transaction on the XRPL Explorer](https://devnet.xrpl.org/transactions/20CFCE5CF75E93E6D1E9C1E42F8E8C8C4CB1786A65BE23D2EA77EAAB65A455C5/simple).
|
||||||
{% /admonition %}
|
{% /admonition %}
|
||||||
|
|
||||||
Because the Batch transaction is configured with a `tfAllOrNothing` flag, if any inner transaction fails, **all** inner transactions wil fail, and only the Batch transaction fee is deducted from the **third-party wallet**.
|
Because the `Batch` transaction is configured with a `tfAllOrNothing` flag, if any inner transaction fails, **all** inner transactions wil fail, and only the `Batch` transaction fee is deducted from the **third-party wallet**.
|
||||||
|
|
||||||
### 8. Verify inner transactions
|
### 8. Verify inner transactions
|
||||||
|
|
||||||
Since there is no way to check the status of inner transactions in the Batch transaction result, you need to calculate the inner transaction hashes and look them up on the ledger:
|
Since there is no way to check the status of inner transactions in the `Batch` transaction result, you need to calculate the inner transaction hashes and look them up on the ledger:
|
||||||
|
|
||||||
{% tabs %}
|
{% tabs %}
|
||||||
{% tab label="Javascript" %}
|
{% tab label="Javascript" %}
|
||||||
|
|||||||
@@ -11,14 +11,14 @@ labels:
|
|||||||
|
|
||||||
A [Batch transaction][] allows you to group multiple transactions together and execute them as a single atomic operation.
|
A [Batch transaction][] allows you to group multiple transactions together and execute them as a single atomic operation.
|
||||||
|
|
||||||
This tutorial shows you how to create a Batch transaction where a single account submits multiple transactions that either all succeed together or all fail together.
|
This tutorial shows you how to create a `Batch` transaction where a single account submits multiple transactions that either all succeed together or all fail together.
|
||||||
|
|
||||||
## Goals
|
## Goals
|
||||||
|
|
||||||
By the end of this tutorial, you will be able to:
|
By the end of this tutorial, you will be able to:
|
||||||
|
|
||||||
- Create a Batch transaction with multiple inner transactions, signed and submitted by a single account.
|
- Create a `Batch` transaction with multiple inner transactions, signed and submitted by a single account.
|
||||||
- Configure the Batch transaction to ensure atomicity, so that either all inner transactions succeed or they all fail.
|
- Configure the `Batch` transaction to ensure atomicity, so that either all inner transactions succeed or they all fail.
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ You can find the complete source code for this tutorial's examples in the [code
|
|||||||
|
|
||||||
## Steps
|
## Steps
|
||||||
|
|
||||||
The example in this tutorial demonstrates a scenario where an account sends multiple payments that must be processed atomically in one Batch transaction.
|
The example in this tutorial demonstrates a scenario where an account sends multiple payments that must be processed atomically in one `Batch` transaction.
|
||||||
|
|
||||||
### 1. Install dependencies
|
### 1. Install dependencies
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ npm install xrpl
|
|||||||
|
|
||||||
### 2. Set up client and accounts
|
### 2. Set up client and accounts
|
||||||
|
|
||||||
To get started, import the client library and instantiate a client to connect to the XRPL. For this tutorial you need a funded account for the Batch transaction **sender**, and two other accounts to **receive** the payments.
|
To get started, import the client library and instantiate a client to connect to the XRPL. For this tutorial you need a funded account for the `Batch` transaction **sender**, and two other accounts to **receive** the payments.
|
||||||
|
|
||||||
{% tabs %}
|
{% tabs %}
|
||||||
{% tab label="Javascript" %}
|
{% tab label="Javascript" %}
|
||||||
@@ -71,23 +71,23 @@ Next, prepare the inner transactions that will be included in the batch.
|
|||||||
|
|
||||||
The first transaction sends a payment of 2 XRP from the sender to `wallet1`, and the second transaction sends 5 XRP from the sender to `wallet2`. Both transactions must include the `tfInnerBatchTxn` (0x40000000) flag to indicate that they are inner transactions of a batch.
|
The first transaction sends a payment of 2 XRP from the sender to `wallet1`, and the second transaction sends 5 XRP from the sender to `wallet2`. Both transactions must include the `tfInnerBatchTxn` (0x40000000) flag to indicate that they are inner transactions of a batch.
|
||||||
|
|
||||||
Inner transactions must have a Fee of **0** and an empty string for the `SigningPubKey`. The outer Batch transaction handles the overall fee and signing for all inner transactions.
|
Inner transactions must have a Fee of **0** and an empty string for the `SigningPubKey`. The outer `Batch` transaction handles the overall fee and signing for all inner transactions.
|
||||||
|
|
||||||
{% admonition type="info" name="Note" %}
|
{% admonition type="info" name="Note" %}
|
||||||
The `Fee` and `SigningPubKey` fields are omitted as the client library's _autofill_ functionality automatically populates these when submitting the Batch transaction.
|
The `Fee` and `SigningPubKey` fields are omitted as the client library's _autofill_ functionality automatically populates these when submitting the `Batch` transaction.
|
||||||
|
|
||||||
You typically don't need to set these manually, but if you do, ensure `Fee` is set to 0 and `SigningPubKey` is an empty string.
|
You typically don't need to set these manually, but if you do, ensure `Fee` is set to 0 and `SigningPubKey` is an empty string.
|
||||||
{% /admonition %}
|
{% /admonition %}
|
||||||
|
|
||||||
### 4. Prepare Batch transaction
|
### 4. Prepare Batch transaction
|
||||||
|
|
||||||
Create the Batch transaction and provide the inner transactions. The key fields to note are:
|
Create the `Batch` transaction and provide the inner transactions. The key fields to note are:
|
||||||
|
|
||||||
| Field | Value |
|
| Field | Value |
|
||||||
|:---------------- |:---------- |
|
|:---------------- |:---------- |
|
||||||
| TransactionType | The type of transaction, in this case `Batch`.|
|
| TransactionType | The type of transaction, in this case `Batch`.|
|
||||||
| Account | The wallet address of the account that is sending the Batch transaction. |
|
| Account | The wallet address of the account that is sending the `Batch` transaction. |
|
||||||
| Flags | The flags for the Batch transaction. For this example the transaction is configured with the `tfAllOrNothing` (0x00010000) flag to ensure that either all inner transactions succeed or they all fail atomically. See [Batch Flags](../../../references/protocol/transactions/types/batch.md#batch-flags) for other options. |
|
| Flags | The flags for the `Batch` transaction. For this example the transaction is configured with the `tfAllOrNothing` (0x00010000) flag to ensure that either all inner transactions succeed or they all fail atomically. See [Batch Flags](../../../references/protocol/transactions/types/batch.md#batch-flags) for other options. |
|
||||||
| RawTransactions | Contains the list of inner transactions to be applied. Must include a minimum of **2** transactions and a maximum of **8** transactions. These transactions can come from one account or multiple accounts. |
|
| RawTransactions | Contains the list of inner transactions to be applied. Must include a minimum of **2** transactions and a maximum of **8** transactions. These transactions can come from one account or multiple accounts. |
|
||||||
|
|
||||||
{% tabs %}
|
{% tabs %}
|
||||||
@@ -98,7 +98,7 @@ Create the Batch transaction and provide the inner transactions. The key fields
|
|||||||
|
|
||||||
### 5. Submit Batch transaction
|
### 5. Submit Batch transaction
|
||||||
|
|
||||||
Now the sender can submit the Batch transaction:
|
Now the sender can submit the `Batch` transaction:
|
||||||
|
|
||||||
{% tabs %}
|
{% tabs %}
|
||||||
{% tab label="Javascript" %}
|
{% tab label="Javascript" %}
|
||||||
@@ -110,7 +110,7 @@ Because `autofill` is set to `true`, the client library automatically fills in a
|
|||||||
|
|
||||||
### 6. Check Batch transaction result
|
### 6. Check Batch transaction result
|
||||||
|
|
||||||
To check the result of the Batch transaction submission:
|
To check the result of the `Batch` transaction submission:
|
||||||
|
|
||||||
{% tabs %}
|
{% tabs %}
|
||||||
{% tab label="Javascript" %}
|
{% tab label="Javascript" %}
|
||||||
@@ -121,16 +121,16 @@ To check the result of the Batch transaction submission:
|
|||||||
The code checks for a `tesSUCCESS` result and displays the response details.
|
The code checks for a `tesSUCCESS` result and displays the response details.
|
||||||
|
|
||||||
{% admonition type="warning" name="Warning" %}
|
{% admonition type="warning" name="Warning" %}
|
||||||
A `tesSUCCESS` result indicates that the Batch transaction was processed successfully, but does not guarantee the inner transactions succeeded.
|
A `tesSUCCESS` result indicates that the `Batch` transaction was processed successfully, but does not guarantee the inner transactions succeeded.
|
||||||
|
|
||||||
For example, see the [following transaction on the XRPL Explorer](https://devnet.xrpl.org/transactions/20CFCE5CF75E93E6D1E9C1E42F8E8C8C4CB1786A65BE23D2EA77EAAB65A455C5/simple).
|
For example, see the [following transaction on the XRPL Explorer](https://devnet.xrpl.org/transactions/20CFCE5CF75E93E6D1E9C1E42F8E8C8C4CB1786A65BE23D2EA77EAAB65A455C5/simple).
|
||||||
{% /admonition %}
|
{% /admonition %}
|
||||||
|
|
||||||
Because the Batch transaction is configured with a `tfAllOrNothing` flag, if any inner transaction fails, **all** inner transactions wil fail, and only the Batch transaction fee is deducted from the **third-party wallet**.
|
Because the `Batch` transaction is configured with a `tfAllOrNothing` flag, if any inner transaction fails, **all** inner transactions wil fail, and only the `Batch` transaction fee is deducted from the **third-party wallet**.
|
||||||
|
|
||||||
### 7. Verify inner transactions
|
### 7. Verify inner transactions
|
||||||
|
|
||||||
Since there is no way to check the status of inner transactions in the Batch transaction result, you need to calculate the inner transaction hashes and look them up on the ledger:
|
Since there is no way to check the status of inner transactions in the `Batch` transaction result, you need to calculate the inner transaction hashes and look them up on the ledger:
|
||||||
|
|
||||||
{% tabs %}
|
{% tabs %}
|
||||||
{% tab label="Javascript" %}
|
{% tab label="Javascript" %}
|
||||||
|
|||||||
Reference in New Issue
Block a user