mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-12-02 09:35:53 +00:00
Escrow tutorial: fix typo with wrong Escrow tx name
This commit is contained in:
@@ -154,7 +154,7 @@ Response:
|
|||||||
|
|
||||||
### 6. Submit EscrowFinish transaction
|
### 6. Submit EscrowFinish transaction
|
||||||
|
|
||||||
[Sign and submit](reference-transaction-format.html#signing-and-submitting-transactions) an [EscrowCreate transaction][] to execute the release of the funds after the `FinishAfter` time has passed. Set the `Owner` field of the transaction to the `Account` address from the EscrowCreate transaction, and the `OfferSequence` to the `Sequence` number from the EscrowCreate transaction. For an escrow held only by time, omit the `Condition` and `Fulfillment` fields.
|
[Sign and submit](reference-transaction-format.html#signing-and-submitting-transactions) an [EscrowFinish transaction][] to execute the release of the funds after the `FinishAfter` time has passed. Set the `Owner` field of the transaction to the `Account` address from the EscrowCreate transaction, and the `OfferSequence` to the `Sequence` number from the EscrowCreate transaction. For an escrow held only by time, omit the `Condition` and `Fulfillment` fields.
|
||||||
|
|
||||||
**Tip:** The EscrowFinish transaction is necessary because the XRP Ledger's state can only be modified by transactions. The sender of this transaction may be the recipient of the escrow, the original sender of the escrow, or any other XRP Ledger address.
|
**Tip:** The EscrowFinish transaction is necessary because the XRP Ledger's state can only be modified by transactions. The sender of this transaction may be the recipient of the escrow, the original sender of the escrow, or any other XRP Ledger address.
|
||||||
|
|
||||||
@@ -343,7 +343,7 @@ Response:
|
|||||||
|
|
||||||
### 6. Submit EscrowFinish transaction
|
### 6. Submit EscrowFinish transaction
|
||||||
|
|
||||||
[Sign and submit](reference-transaction-format.html#signing-and-submitting-transactions) an [EscrowCreate transaction][] to execute the release of the funds after the `FinishAfter` time has passed. Set the `Owner` field of the transaction to the `Account` address from the EscrowCreate transaction, and the `OfferSequence` to the `Sequence` number from the EscrowCreate transaction. Set the `Condition` and `Fulfillment` fields to the condition and fulfillment values, in hexadecimal, that you generated in step 1. Set the `Fee` ([transaction cost](concept-transaction-cost.html)) value based on the size of the fulfillment in bytes: a conditional EscrowFinish requires at least 330 drops of XRP plus 10 drops per 16 bytes in the size of the fulfillment.
|
[Sign and submit](reference-transaction-format.html#signing-and-submitting-transactions) an [EscrowFinish transaction][] to execute the release of the funds after the `FinishAfter` time has passed. Set the `Owner` field of the transaction to the `Account` address from the EscrowCreate transaction, and the `OfferSequence` to the `Sequence` number from the EscrowCreate transaction. Set the `Condition` and `Fulfillment` fields to the condition and fulfillment values, in hexadecimal, that you generated in step 1. Set the `Fee` ([transaction cost](concept-transaction-cost.html)) value based on the size of the fulfillment in bytes: a conditional EscrowFinish requires at least 330 drops of XRP plus 10 drops per 16 bytes in the size of the fulfillment.
|
||||||
|
|
||||||
**Note:** If you included a `FinishAfter` field in the EscrowCreate transaction, you cannot execute it before that time has passed, even if you provide the correct fulfillment for the Escrow's condition. The EscrowFinish transaction fails with the [result code](reference-transaction-format.html#transaction-results) `tecNO_PERMISSION` if the previously-closed ledger's close time is before the `FinishAfter` time.
|
**Note:** If you included a `FinishAfter` field in the EscrowCreate transaction, you cannot execute it before that time has passed, even if you provide the correct fulfillment for the Escrow's condition. The EscrowFinish transaction fails with the [result code](reference-transaction-format.html#transaction-results) `tecNO_PERMISSION` if the previously-closed ledger's close time is before the `FinishAfter` time.
|
||||||
|
|
||||||
|
|||||||
@@ -174,7 +174,7 @@
|
|||||||
<main class="main" role="main">
|
<main class="main" role="main">
|
||||||
<div class='content'>
|
<div class='content'>
|
||||||
<h1 id="escrow-tutorials">Escrow Tutorials</h1>
|
<h1 id="escrow-tutorials">Escrow Tutorials</h1>
|
||||||
<p>The XRP Ledger supports held payments, or <em>escrows</em>, that can be executed only after a certain time has passed or a cryptographic condition has been fulfilled. Escrows can only send XRP, not issued currencies. You can use these simple features to build publicly-provable smart contracts. This article explains basic tasks relating to held payments.</p>
|
<p>The XRP Ledger supports held payments, or <em>escrows</em>, that can be executed only after a certain time has passed or a cryptographic condition has been fulfilled. Escrows can only send XRP, not issued currencies. You can use these features to build publicly-provable smart contracts. This article explains basic tasks relating to held payments.</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="#send-a-time-held-escrow">Send a time-held escrow</a></li>
|
<li><a href="#send-a-time-held-escrow">Send a time-held escrow</a></li>
|
||||||
<li><a href="#send-a-conditionally-held-escrow">Send a conditionally-held escrow</a></li>
|
<li><a href="#send-a-conditionally-held-escrow">Send a conditionally-held escrow</a></li>
|
||||||
@@ -251,7 +251,7 @@ console.log(release_date_ripple);
|
|||||||
}
|
}
|
||||||
</code></pre></div>
|
</code></pre></div>
|
||||||
</div>
|
</div>
|
||||||
<p>Take note of the transaction's identifying <code>hash</code> value so you can easily check its final status when it is included in a validated ledger version.</p>
|
<p>Take note of the transaction's identifying <code>hash</code> value so you can check its final status when it is included in a validated ledger version.</p>
|
||||||
<h3 id="3-wait-for-validation">3. Wait for validation</h3>
|
<h3 id="3-wait-for-validation">3. Wait for validation</h3>
|
||||||
<p>On the live network or the Ripple Test Net, you can wait 4-7 seconds for the ledger to close automatically.</p>
|
<p>On the live network or the Ripple Test Net, you can wait 4-7 seconds for the ledger to close automatically.</p>
|
||||||
<p>If you're running <code>rippled</code> in stand-alone mode, use the <a href="reference-rippled.html#ledger-accept"><code>ledger_accept</code> command</a> to manually close the ledger.</p>
|
<p>If you're running <code>rippled</code> in stand-alone mode, use the <a href="reference-rippled.html#ledger-accept"><code>ledger_accept</code> command</a> to manually close the ledger.</p>
|
||||||
@@ -397,7 +397,7 @@ console.log(release_date_ripple);
|
|||||||
</code></pre></div>
|
</code></pre></div>
|
||||||
</div>
|
</div>
|
||||||
<h3 id="6-submit-escrowfinish-transaction">6. Submit EscrowFinish transaction</h3>
|
<h3 id="6-submit-escrowfinish-transaction">6. Submit EscrowFinish transaction</h3>
|
||||||
<p><a href="reference-transaction-format.html#signing-and-submitting-transactions">Sign and submit</a> an <a href="reference-transaction-format.html#escrowcreate">EscrowCreate transaction</a> to execute the release of the funds after the <code>FinishAfter</code> time has passed. Set the <code>Owner</code> field of the transaction to the <code>Account</code> address from the EscrowCreate transaction, and the <code>OfferSequence</code> to the <code>Sequence</code> number from the EscrowCreate transaction. For an escrow held only by time, omit the <code>Condition</code> and <code>Fulfillment</code> fields.</p>
|
<p><a href="reference-transaction-format.html#signing-and-submitting-transactions">Sign and submit</a> an <a href="reference-transaction-format.html#escrowfinish">EscrowFinish transaction</a> to execute the release of the funds after the <code>FinishAfter</code> time has passed. Set the <code>Owner</code> field of the transaction to the <code>Account</code> address from the EscrowCreate transaction, and the <code>OfferSequence</code> to the <code>Sequence</code> number from the EscrowCreate transaction. For an escrow held only by time, omit the <code>Condition</code> and <code>Fulfillment</code> fields.</p>
|
||||||
<p class="devportal-callout tip"><strong>Tip:</strong> The EscrowFinish transaction is necessary because the XRP Ledger's state can only be modified by transactions. The sender of this transaction may be the recipient of the escrow, the original sender of the escrow, or any other XRP Ledger address.</p>
|
<p class="devportal-callout tip"><strong>Tip:</strong> The EscrowFinish transaction is necessary because the XRP Ledger's state can only be modified by transactions. The sender of this transaction may be the recipient of the escrow, the original sender of the escrow, or any other XRP Ledger address.</p>
|
||||||
<p class="devportal-callout caution"><strong>Caution:</strong> Never submit a secret key to a server you do not control. Do not send a secret key unencrypted over the network.</p>
|
<p class="devportal-callout caution"><strong>Caution:</strong> Never submit a secret key to a server you do not control. Do not send a secret key unencrypted over the network.</p>
|
||||||
<p>Request:</p>
|
<p>Request:</p>
|
||||||
@@ -443,7 +443,7 @@ console.log(release_date_ripple);
|
|||||||
}
|
}
|
||||||
</code></pre></div>
|
</code></pre></div>
|
||||||
</div>
|
</div>
|
||||||
<p>Take note of the transaction's identifying <code>hash</code> value so you can easily check its final status when it is included in a validated ledger version.</p>
|
<p>Take note of the transaction's identifying <code>hash</code> value so you can check its final status when it is included in a validated ledger version.</p>
|
||||||
<h3 id="7-wait-for-validation">7. Wait for validation</h3>
|
<h3 id="7-wait-for-validation">7. Wait for validation</h3>
|
||||||
<p>On the live network or the Ripple Test Net, you can wait 4-7 seconds for the ledger to close automatically.</p>
|
<p>On the live network or the Ripple Test Net, you can wait 4-7 seconds for the ledger to close automatically.</p>
|
||||||
<p>If you're running <code>rippled</code> in stand-alone mode, use the <a href="reference-rippled.html#ledger-accept"><code>ledger_accept</code> command</a> to manually close the ledger.</p>
|
<p>If you're running <code>rippled</code> in stand-alone mode, use the <a href="reference-rippled.html#ledger-accept"><code>ledger_accept</code> command</a> to manually close the ledger.</p>
|
||||||
@@ -558,9 +558,9 @@ console.log(release_date_ripple);
|
|||||||
</div>
|
</div>
|
||||||
<h2 id="send-a-conditionally-held-escrow">Send a conditionally-held escrow</h2>
|
<h2 id="send-a-conditionally-held-escrow">Send a conditionally-held escrow</h2>
|
||||||
<h3 id="1-generate-condition-and-fulfillment">1. Generate condition and fulfillment</h3>
|
<h3 id="1-generate-condition-and-fulfillment">1. Generate condition and fulfillment</h3>
|
||||||
<p>XRP Ledger escrows require PREIMGE-SHA-256 <a href="https://tools.ietf.org/html/draft-thomas-crypto-conditions-03">Crypto-Conditions</a>. To calculate a condition and fulfillment in the proper format, you should use a Crypto-Conditions library such as <a href="https://github.com/interledgerjs/five-bells-condition">five-bells-condition</a>. For fulfillments, Ripple recommends using one of the following methods to generate the fulfillment:</p>
|
<p>XRP Ledger escrows require PREIMAGE-SHA-256 <a href="https://tools.ietf.org/html/draft-thomas-crypto-conditions-03">Crypto-Conditions</a>. To calculate a condition and fulfillment in the proper format, you should use a Crypto-Conditions library such as <a href="https://github.com/interledgerjs/five-bells-condition">five-bells-condition</a>. For fulfillments, Ripple recommends using one of the following methods to generate the fulfillment:</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>Use a cryptographically secure source of randomness to generate at least 32 random bytes</li>
|
<li>Use a cryptographically secure source of randomness to generate at least 32 random bytes.</li>
|
||||||
<li>Follow Interledger Protocol's <a href="https://github.com/interledger/rfcs/blob/master/0016-pre-shared-key/0016-pre-shared-key.md">PSK specification</a> and use an HMAC-SHA-256 of the ILP packet as the fulfillment.</li>
|
<li>Follow Interledger Protocol's <a href="https://github.com/interledger/rfcs/blob/master/0016-pre-shared-key/0016-pre-shared-key.md">PSK specification</a> and use an HMAC-SHA-256 of the ILP packet as the fulfillment.</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p>Example JavaScript code for a random fulfillment and condition:</p>
|
<p>Example JavaScript code for a random fulfillment and condition:</p>
|
||||||
@@ -574,26 +574,20 @@ console.log(myFulfillment.serializeBinary().toString('hex'));
|
|||||||
console.log(myFulfillment.getConditionBinary().toString('hex'));
|
console.log(myFulfillment.getConditionBinary().toString('hex'));
|
||||||
// (Random hexadecimal, 78 chars in length)
|
// (Random hexadecimal, 78 chars in length)
|
||||||
</code></pre>
|
</code></pre>
|
||||||
<p>Save the condition and the fulfillment for later. Be sure to keep the fulfillment secret until you want to finish executing the held payment; anyone who knows the fulfillment can finish the escrow, releasing the held funds to their intended destination.</p>
|
<p>Save the condition and the fulfillment for later. Be sure to keep the fulfillment secret until you want to finish executing the held payment. Anyone who knows the fulfillment can finish the escrow, releasing the held funds to their intended destination.</p>
|
||||||
<h3 id="2-calculate-release-or-cancel-time">2. Calculate release or cancel time</h3>
|
<h3 id="2-calculate-release-or-cancel-time">2. Calculate release or cancel time</h3>
|
||||||
<p>A Conditional <code>Escrow</code> transaction must contain either a <code>CancelAfter</code> or <code>FinishAfter</code> field, or both. The <code>CancelAfter</code> field lets the XRP revert to the sender if the condition is not fulfilled before the specified time. The <code>FinishAfter</code> field specifies a time before which the escrow cannot execute, even if someone sends the correct fulfillment. Whichever field you provide, the time it specifies must be in the future.</p>
|
<p>A Conditional <code>Escrow</code> transaction must contain either a <code>CancelAfter</code> or <code>FinishAfter</code> field, or both. The <code>CancelAfter</code> field lets the XRP revert to the sender if the condition is not fulfilled before the specified time. The <code>FinishAfter</code> field specifies a time before which the escrow cannot execute, even if someone sends the correct fulfillment. Whichever field you provide, the time it specifies must be in the future.</p>
|
||||||
<p>Example for setting a <code>CancelAfter</code> time of 24 hours in the future:</p>
|
<p>Example for setting a <code>CancelAfter</code> time of 24 hours in the future:</p>
|
||||||
<div class="multicode" id="code-11"><ul class="codetabs"><li><a href="#code-11-0">JavaScript</a></li><li><a href="#code-11-1">Python 2/3</a></li></ul>
|
<div class="multicode" id="code-11"><ul class="codetabs"><li><a href="#code-11-0">JavaScript</a></li></ul>
|
||||||
|
|
||||||
<div class="code_sample" id="code-11-0" style="position: static;"><pre><code class="js">const rippleOffset = 946684800;
|
<div class="code_sample" id="code-11-0" style="position: static;"><pre><code class="js">const rippleOffset = 946684800;
|
||||||
const CancelAfter = Math.floor(Date.now() / 1000) + (24*60*60) - rippleOffset;
|
const CancelAfter = Math.floor(Date.now() / 1000) + (24*60*60) - rippleOffset;
|
||||||
console.log(CancelAfter);
|
console.log(CancelAfter);
|
||||||
// Example: 556927412
|
// Example: 556927412
|
||||||
</code></pre></div>
|
</code></pre></div>
|
||||||
|
<!-- -->
|
||||||
<div class="code_sample" id="code-11-1" style="position: static;"><pre><code class="python">from time import time
|
|
||||||
ripple_offset = 946684800
|
|
||||||
cancel_after = int(time()) + (24*60*60) - 946684800
|
|
||||||
print(cancel_after)
|
|
||||||
# Example: 556927412
|
|
||||||
</code></pre></div>
|
|
||||||
</div>
|
</div>
|
||||||
<p class="devportal-callout warning"><strong>Warning:</strong> In the XRP Ledger, you must specify time as seconds since the Ripple Epoch (2000-01-01T00:00:00Z). If you use a UNIX time in the <code>CancelAfter</code> or <code>FinishAfter</code> field without converting to the equivalent Ripple time first, that sets the unlock time to an extra <strong>30 years</strong> in the future!</p>
|
<p class="devportal-callout warning"><strong>Warning:</strong> In the XRP Ledger, you must specify time as <strong>seconds since the Ripple Epoch</strong> (2000-01-01T00:00:00Z). If you use a UNIX time in the <code>CancelAfter</code> or <code>FinishAfter</code> field without converting to the equivalent Ripple time first, that sets the unlock time to an extra <strong>30 years</strong> in the future!</p>
|
||||||
<h3 id="3-submit-escrowcreate-transaction">3. Submit EscrowCreate transaction</h3>
|
<h3 id="3-submit-escrowcreate-transaction">3. Submit EscrowCreate transaction</h3>
|
||||||
<p><a href="reference-transaction-format.html#signing-and-submitting-transactions">Sign and submit</a> an <a href="reference-transaction-format.html#escrowcreate">EscrowCreate transaction</a>. Set the <code>Condition</code> field of the transaction to the time when the held payment should be released. Set the <code>Destination</code> to the recipient, which can be the same address as the sender. Include the <code>CancelAfter</code> or <code>FinishAfter</code> time you calculated in the previous step.</p>
|
<p><a href="reference-transaction-format.html#signing-and-submitting-transactions">Sign and submit</a> an <a href="reference-transaction-format.html#escrowcreate">EscrowCreate transaction</a>. Set the <code>Condition</code> field of the transaction to the time when the held payment should be released. Set the <code>Destination</code> to the recipient, which can be the same address as the sender. Include the <code>CancelAfter</code> or <code>FinishAfter</code> time you calculated in the previous step.</p>
|
||||||
<p class="devportal-callout caution"><strong>Caution:</strong> Never submit a secret key to a server you do not control. Do not send a secret key unencrypted over the network.</p>
|
<p class="devportal-callout caution"><strong>Caution:</strong> Never submit a secret key to a server you do not control. Do not send a secret key unencrypted over the network.</p>
|
||||||
@@ -745,7 +739,7 @@ print(cancel_after)
|
|||||||
</code></pre></div>
|
</code></pre></div>
|
||||||
</div>
|
</div>
|
||||||
<h3 id="6-submit-escrowfinish-transaction-1">6. Submit EscrowFinish transaction</h3>
|
<h3 id="6-submit-escrowfinish-transaction-1">6. Submit EscrowFinish transaction</h3>
|
||||||
<p><a href="reference-transaction-format.html#signing-and-submitting-transactions">Sign and submit</a> an <a href="reference-transaction-format.html#escrowcreate">EscrowCreate transaction</a> to execute the release of the funds after the <code>FinishAfter</code> time has passed. Set the <code>Owner</code> field of the transaction to the <code>Account</code> address from the EscrowCreate transaction, and the <code>OfferSequence</code> to the <code>Sequence</code> number from the EscrowCreate transaction. Set the <code>Condition</code> and <code>Fulfillment</code> fields to the condition and fulfillment values, in hexadecimal, that you generated in step 1. Set the <code>Fee</code> (<a href="concept-transaction-cost.html">transaction cost</a>) value based on the size of the fulfillment in bytes: a conditional EscrowFinish requires at least 330 drops of XRP plus 10 drops per 16 bytes in the size of the fulfillment.</p>
|
<p><a href="reference-transaction-format.html#signing-and-submitting-transactions">Sign and submit</a> an <a href="reference-transaction-format.html#escrowfinish">EscrowFinish transaction</a> to execute the release of the funds after the <code>FinishAfter</code> time has passed. Set the <code>Owner</code> field of the transaction to the <code>Account</code> address from the EscrowCreate transaction, and the <code>OfferSequence</code> to the <code>Sequence</code> number from the EscrowCreate transaction. Set the <code>Condition</code> and <code>Fulfillment</code> fields to the condition and fulfillment values, in hexadecimal, that you generated in step 1. Set the <code>Fee</code> (<a href="concept-transaction-cost.html">transaction cost</a>) value based on the size of the fulfillment in bytes: a conditional EscrowFinish requires at least 330 drops of XRP plus 10 drops per 16 bytes in the size of the fulfillment.</p>
|
||||||
<p class="devportal-callout note"><strong>Note:</strong> If you included a <code>FinishAfter</code> field in the EscrowCreate transaction, you cannot execute it before that time has passed, even if you provide the correct fulfillment for the Escrow's condition. The EscrowFinish transaction fails with the <a href="reference-transaction-format.html#transaction-results">result code</a> <code>tecNO_PERMISSION</code> if the previously-closed ledger's close time is before the <code>FinishAfter</code> time.</p>
|
<p class="devportal-callout note"><strong>Note:</strong> If you included a <code>FinishAfter</code> field in the EscrowCreate transaction, you cannot execute it before that time has passed, even if you provide the correct fulfillment for the Escrow's condition. The EscrowFinish transaction fails with the <a href="reference-transaction-format.html#transaction-results">result code</a> <code>tecNO_PERMISSION</code> if the previously-closed ledger's close time is before the <code>FinishAfter</code> time.</p>
|
||||||
<p class="devportal-callout caution"><strong>Caution:</strong> Never submit a secret key to a server you do not control. Do not send a secret key unencrypted over the network.</p>
|
<p class="devportal-callout caution"><strong>Caution:</strong> Never submit a secret key to a server you do not control. Do not send a secret key unencrypted over the network.</p>
|
||||||
<div class="multicode" id="code-16"><ul class="codetabs"><li><a href="#code-16-0">Websocket</a></li></ul>
|
<div class="multicode" id="code-16"><ul class="codetabs"><li><a href="#code-16-0">Websocket</a></li></ul>
|
||||||
@@ -795,7 +789,7 @@ print(cancel_after)
|
|||||||
}
|
}
|
||||||
</code></pre></div>
|
</code></pre></div>
|
||||||
</div>
|
</div>
|
||||||
<p>Take note of the transaction's identifying <code>hash</code> value so you can easily check its final status when it is included in a validated ledger version.</p>
|
<p>Take note of the transaction's identifying <code>hash</code> value so you can check its final status when it is included in a validated ledger version.</p>
|
||||||
<h3 id="7-wait-for-validation-1">7. Wait for validation</h3>
|
<h3 id="7-wait-for-validation-1">7. Wait for validation</h3>
|
||||||
<p>On the live network or the Ripple Test Net, you can wait 4-7 seconds for the ledger to close automatically.</p>
|
<p>On the live network or the Ripple Test Net, you can wait 4-7 seconds for the ledger to close automatically.</p>
|
||||||
<p>If you're running <code>rippled</code> in stand-alone mode, use the <a href="reference-rippled.html#ledger-accept"><code>ledger_accept</code> command</a> to manually close the ledger.</p>
|
<p>If you're running <code>rippled</code> in stand-alone mode, use the <a href="reference-rippled.html#ledger-accept"><code>ledger_accept</code> command</a> to manually close the ledger.</p>
|
||||||
|
|||||||
Reference in New Issue
Block a user