Merge pull request #1855 from XRPLF/1788_set_minter

Fix set minter, misc
This commit is contained in:
Dennis Dawson
2023-04-03 10:39:33 -07:00
committed by GitHub
10 changed files with 1096 additions and 1516 deletions

View File

@@ -102,7 +102,7 @@ This function sets the authorized minter for an account. Each account can have 0
// **************** Set Minter *************************
// *******************************************************
async function setMinter(type) {
async function setMinter() {
```
Connect to the ledger and get the account.
@@ -111,19 +111,18 @@ Connect to the ledger and get the account.
let net = getNet()
const client = new xrpl.Client(net)
results = 'Connecting to ' + getNet() + '....'
document.getElementById('standbyResultField').value = results
standbyResultField.value = results
await client.connect()
results += '\nConnected, finding wallet.'
document.getElementById('standbyResultField').value = results
standbyResultField.value = results
my_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
document.getElementById('standbyResultField').value = results
```
standbyResultField.value = results ```
Define the AccountSet transaction, setting the `NFTokenMinter` account and the `asfAuthorizedNFTokenMinter` flag.
```javascript
tx_json = {
"TransactionType": "AccountSet",
"TransactionType": "AccountSet",
"Account": my_wallet.address,
```
@@ -143,30 +142,30 @@ Set the `asfAuthorizedNFTokenMinter` flag (the numeric value is _10_).
Report progress.
```javascript
results += '\n Set Minter.'
document.getElementById('standbyResultField').value = results
results += '\nSet Minter.'
standbyResultField.value = results
```
Prepare and send the transaction, then wait for results
```javascript
const prepared = await client.autofill(tx_json)
const signed = my_wallet.sign(prepared)
const result = await client.submitAndWait(signed.tx_json)
const prepared = await client.autofill(tx_json)
const signed = my_wallet.sign(prepared)
const result = await client.submitAndWait(signed.tx_blob)
```
If the transaction succeeds, show the results. If not, report that the transaction failed.
```javascript
if (result.result.meta.TransactionResult == "tesSUCCESS") {
results += '\nAccount setting succeeded.'
if (result.result.meta.TransactionResult == "tesSUCCESS") {
results += '\nAccount setting succeeded.\n'
results += JSON.stringify(result,null,2)
document.getElementById('standbyResultField').value = results
} else {
standbyResultField.value = results
} else {
throw 'Error sending transaction: ${result}'
results += '\nAccount setting failed.'
document.getElementById('standbyResultField').value = results
}
standbyResultField.value = results
}
```
Disconnect from the XRP Ledger.
@@ -193,7 +192,7 @@ Connect to the ledger and get the account.
```javascript
results = 'Connecting to ' + getNet() + '....'
document.getElementById('standbyResultField').value = results
standbyResultField.value = results
let net = getNet()
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
const client = new xrpl.Client(net)
@@ -203,13 +202,13 @@ Report success
```javascript
results += '\nConnected. Minting NFToken.'
document.getElementById('standbyResultField').value = results
standbyResultField.value = results
```
This transaction blob is the same as the one used for the previous [`mintToken()` function](mint-and-burn-nftokens.html#mint-token), with the addition of the `Issuer` field.
```javascript
const transactionBlob = {
const tx_json = {
"TransactionType": "NFTokenMint",
"Account": standby_wallet.classicAddress,
```
@@ -248,10 +247,10 @@ The `NFTokenTaxon` is an optional number field the issuer can use for their own
Submit the transaction and wait for the results.
```javascript
const tx = await client.submitAndWait(transactionBlob, { wallet: standby_wallet} )
const tx = await client.submitAndWait(tx_json, { wallet: standby_wallet} )
const nfts = await client.request({
method: "account_nfts",
account: standby_wallet.classicAddress
account: standby_wallet.classicAddress
})
```
@@ -260,10 +259,9 @@ Report the results.
```javascript
results += '\n\nTransaction result: '+ tx.result.meta.TransactionResult
results += '\n\nnfts: ' + JSON.stringify(nfts, null, 2)
document.getElementById('standbyBalanceField').value =
(await client.getXrpBalance(standby_wallet.address))
document.getElementById('standbyResultField').value = results
standbyResultField.value = results + (await
client.getXrpBalance(standby_wallet.address))
standbyResultField.value = results
```
Disconnect from the XRP Ledger.
@@ -279,19 +277,19 @@ These functions duplicate the functions of the standby account for the operation
```javascript
// *******************************************************
// *********** Operational Set Minter *******************
// *******************************************************
// **************** Set Operational Minter **************
// ********************************************************
async function oPsetMinter(type) {
async function oPsetMinter() {
let net = getNet()
const client = new xrpl.Client(net)
results = 'Connecting to ' + getNet() + '....'
document.getElementById('operationalResultField').value = results
operationalResultField.value = results
await client.connect()
results += '\nConnected, finding wallet.'
document.getElementById('operationalResultField').value = results
operationalResultField.value = results
my_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
document.getElementById('operationalResultField').value = results
operationalResultField.value = results
tx_json = {
"TransactionType": "AccountSet",
@@ -299,24 +297,25 @@ async function oPsetMinter(type) {
"NFTokenMinter": operationalMinterField.value,
"SetFlag": xrpl.AccountSetAsfFlags.asfAuthorizedNFTokenMinter
}
results += '\n Set Minter.'
document.getElementById('operationalResultField').value = results
results += '\nSet Minter.'
operationalResultField.value = results
const prepared = await client.autofill(tx_json)
const signed = my_wallet.sign(prepared)
const result = await client.submitAndWait(signed.tx_json)
if (result.result.meta.TransactionResult == "tesSUCCESS") {
results += '\nAccount setting succeeded.'
const prepared = await client.autofill(tx_json)
const signed = my_wallet.sign(prepared)
const result = await client.submitAndWait(signed.tx_blob)
if (result.result.meta.TransactionResult == "tesSUCCESS") {
results += '\nAccount setting succeeded.\n'
results += JSON.stringify(result,null,2)
document.getElementById('operationalResultField').value = results
} else {
operationalResultField.value = results
} else {
throw 'Error sending transaction: ${result}'
results += '\nAccount setting failed.'
document.getElementById('operationalResultField').value = results
}
operationalResultField.value = results
}
client.disconnect()
} // End of configureAccount()
} // End of oPsetMinter()
// *******************************************************
// ************** Operational Mint Other *****************
@@ -324,17 +323,17 @@ async function oPsetMinter(type) {
async function oPmintOther() {
results = 'Connecting to ' + getNet() + '....'
document.getElementById('operationalResultField').value = results
operationalResultField.value = results
let net = getNet()
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
const client = new xrpl.Client(net)
await client.connect()
results += '\nConnected. Minting NFToken.'
document.getElementById('operationalResultField').value = results
operationalResultField.value = results
// This version adds the "Issuer" field.
// ------------------------------------------------------------------------
const transactionBlob = {
const tx_json = {
"TransactionType": 'NFTokenMint',
"Account": operational_wallet.classicAddress,
"URI": xrpl.convertStringToHex(operationalTokenUrlField.value),
@@ -345,7 +344,7 @@ async function oPmintOther() {
}
// ----------------------------------------------------- Submit signed blob
const tx = await client.submitAndWait(transactionBlob, { wallet: operational_wallet} )
const tx = await client.submitAndWait(tx_json, { wallet: operational_wallet} )
const nfts = await client.request({
method: "account_nfts",
account: operational_wallet.classicAddress
@@ -354,10 +353,8 @@ async function oPmintOther() {
// ------------------------------------------------------- Report results
results += '\n\nTransaction result: '+ tx.result.meta.TransactionResult
results += '\n\nnfts: ' + JSON.stringify(nfts, null, 2)
document.getElementById('operationalBalanceField').value =
(await client.getXrpBalance(operational_wallet.address))
document.getElementById('operationalResultField').value = results
results += await client.getXrpBalance(operational_wallet.address)
operationalResultField.value = results
client.disconnect()
} //End of oPmintToken
```
@@ -378,7 +375,7 @@ Update the form with fields and buttons to support the new functions.
button{font-weight: bold;font-family: "Work Sans", sans-serif;}
td{vertical-align: middle;}
</style>
<script src='https://unpkg.com/xrpl@2.2.3'></script>
<script src='https://unpkg.com/xrpl@2.7.0/build/xrpl-latest-min.js'></script>
<script src='ripplex1-send-xrp.js'></script>
<script src='ripplex2-send-currency.js'></script>
<script src='ripplex3-mint-nfts.js'></script>
@@ -399,7 +396,7 @@ Update the form with fields and buttons to support the new functions.
<body>
<h1>Token Test Harness</h1>
<form id="theForm">
Choose your ledger instance:
Choose your ledger instance:
&nbsp;&nbsp;
<input type="radio" id="tn" name="server"
value="wss://s.altnet.rippletest.net:51233" checked>
@@ -754,8 +751,3 @@ Update the form with fields and buttons to support the new functions.
</body>
</html>
```
| Previous | Next |
| :--- | ---: |
| [← Broker a NFToken Sale >](broker-sale.html) | [Batch Mint NFTokens → >](batch-minting.html) |

View File

@@ -15,6 +15,8 @@ You can create an application that mints multiple NFTokens at one time. You can
A best practice is to use `Tickets` to reserve the transaction sequence numbers. If you create an application that creates NFTokens without using tickets, if any transaction fails for any reason, the application stops with an error. If you use tickets, the application continues to send transactions, and you can look into the reason for the failure afterward.
[![Batch Mint](img/quickstart33-batch-mint.png)](img/quickstart33-batch-mint.png)
## Usage
You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/quickstart/js/quickstart.zip){.github-code-download} archive to try the sample in your own browser.
@@ -66,16 +68,16 @@ async function getAccountFromSeed() {
let net = getNet()
const client = new xrpl.Client(net)
results = 'Connecting to ' + getNet() + '....'
document.getElementById('standbyResultField').value = results
standbyResultField.value = results
await client.connect()
results += '\nConnected, finding wallets.\n'
document.getElementById('standbyResultField').value = results
standbyResultField.value = results
```
Use the seed to derive the account.
```javascript
var theSeed = document.getElementById('seeds').value
var theSeed = seeds.value
const standby_wallet = xrpl.Wallet.fromSeed(theSeed)
```
@@ -88,12 +90,11 @@ Get the current XRP balance.
Populate the fields for Standby account.
```javascript
document.getElementById('standbyAccountField').value = standby_wallet.address
document.getElementById('standbyPubKeyField').value = standby_wallet.publicKey
document.getElementById('standbyPrivKeyField').value = standby_wallet.privateKey
document.getElementById('standbySeedField').value = standby_wallet.seed
document.getElementById('standbyBalanceField').value =
(await client.getXrpBalance(standby_wallet.address))
standbyAccountField.value = standby_wallet.address
standbyPubKeyField.value = standby_wallet.publicKey
standbyPrivKeyField.value = standby_wallet.privateKey
standbySeedField.value = standby_wallet.seed
standbyBalanceField.value = (await client.getXrpBalance(standby_wallet.address))
```
Disconnect from the XRP Ledger.
@@ -108,6 +109,10 @@ Disconnect from the XRP Ledger.
This version of `getTokens()` allows for a larger set of NFTokens by watching for a `marker` at the end of each batch of NFTokens.
```javascript
// *******************************************************
// **************** Get Batch Tokens *********************
// *******************************************************
async function getBatchNFTokens() {
```
@@ -118,10 +123,10 @@ Connect to the XRP Ledger and get the account.
let net = getNet()
const client = new xrpl.Client(net)
results = 'Connecting to ' + net + '...'
document.getElementById('standbyResultField').value = results
standbyResultField.value = results
await client.connect()
results += '\nConnected. Getting NFTokens...'
document.getElementById('standbyResultField').value = results
standbyResultField.value = results
```
Request the `account_nfts`. Set the `limit` to 400, the maximum amount, to retrieve up to 400 records in one batch.
@@ -142,10 +147,10 @@ If the list of `NFTokens` exceeds your limit, the result includes a `marker` fie
while (nfts.result.marker)
{
nfts = await client.request({
method: "account_nfts",
account: standby_wallet.classicAddress,
limit: 400,
marker: nfts.result.marker
method: "account_nfts",
account: standby_wallet.classicAddress,
limit: 400,
marker: nfts.result.marker
})
results += '\n' + JSON.stringify(nfts,null,2)
}
@@ -154,7 +159,7 @@ If the list of `NFTokens` exceeds your limit, the result includes a `marker` fie
Report the final results.
```javascript
document.getElementById('standbyResultField').value = results
standbyResultField.value = results
```
Disconnect from the XRP Ledger.
@@ -169,6 +174,10 @@ Disconnect from the XRP Ledger.
This script mints multiple copies of the same NFToken.
```javascript
// *******************************************************
// ****************** Batch Mint ***********************
// *******************************************************
async function batchMint() {
```
@@ -178,12 +187,12 @@ Connect to the XRP Ledger and get the account.
let net = getNet()
const client = new xrpl.Client(net)
results = 'Connecting to ' + getNet() + '....'
document.getElementById('standbyResultField').value = results
standbyResultField.value = results
await client.connect()
results += '\nConnected, finding wallet.'
document.getElementById('standbyResultField').value = results
standbyResultField.value = results
standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
document.getElementById('standbyResultField').value = results
standbyResultField.value = results
```
Get the account information, particularly the `Sequence` number.
@@ -196,7 +205,7 @@ Get the account information, particularly the `Sequence` number.
my_sequence = account_info.result.account_data.Sequence
results += "\n\nSequence Number: " + my_sequence + "\n\n"
document.getElementById('standbyResultField').value = results
standbyResultField.value = results
```
Next, create ticket numbers for the batch. Without tickets, if one transaction fails, all others in the batch fail. With tickets, there can be failures, but the rest can still succeed, and you can investigate any problems afterward.
@@ -249,7 +258,7 @@ Report the function progress.
```javascript
results += "Tickets generated, minting NFTokens.\n\n"
document.getElementById('standbyResultField').value = results
standbyResultField.value = results
```
Use a `for` loop to create the NFTokens one at a time, up to the number you specified.
@@ -292,7 +301,7 @@ Use the same logic as `getBatchNFTokens`, above, to get the list of current NFTo
})
results += JSON.stringify(nfts,null,2)
while (nfts.result.marker != null)
while (nfts.result.marker)
{
nfts = await client.request({
method: "account_nfts",
@@ -309,9 +318,8 @@ Report the results.
```javascript
results += '\n\nTransaction result: '+ tx.result.meta.TransactionResult
results += '\n\nnftokens: ' + JSON.stringify(nfts, null, 2)
document.getElementById('standbyBalanceField').value =
(await client.getXrpBalance(standby_wallet.address))
document.getElementById('standbyResultField').value = results
standbyBalanceField.value = (await client.getXrpBalance(standby_wallet.address))
standbyResultField.value = results
```
Disconnect from the XRP Ledger.
@@ -340,7 +348,7 @@ For this form:
button{font-weight: bold;font-family: "Work Sans", sans-serif;}
td{vertical-align: middle;}
</style>
<script src='https://unpkg.com/xrpl@2.2.3'></script>
<script src='https://unpkg.com/xrpl@2.7.0/build/xrpl-latest-min.js'></script>
<script src='ripplex1-send-xrp.js'></script>
<script src='ripplex3-mint-nfts.js'></script>
<script src='ripplex7-batch-minting.js'></script>
@@ -359,7 +367,7 @@ For this form:
<body>
<h1>Token Test Harness</h1>
<form id="theForm">
Choose your ledger instance:
Choose your ledger instance:
&nbsp;&nbsp;
<input type="radio" id="tn" name="server"
value="wss://s.altnet.rippletest.net:51233" checked>
@@ -455,37 +463,35 @@ For this form:
<tr>
<td align="right">
NFToken Count
</td>
<td>
<input type="text" id="standbyNFTokenCountField" size="40"></input>
<br>
</td>
</tr>
<tr>
<td align="right">Transfer Fee</td>
<td><input type="text" id="standbyTransferFeeField" value="" size="80"/></td>
</tr>
</td>
</tr>
</table>
</td>
<td align="left" valign="top">
<button type="button" onClick="batchMint()">Batch Mint</button>
<br/>
<button type="button" onClick="getBatchNFTokens()">Get Batch NFTokens</button>
<br/>
<p align="left">
<textarea id="standbyResultField" cols="80" rows="20" maxlength="524288"></textarea>
</p>
</td>
</td>
<td>
<input type="text" id="standbyNFTokenCountField" size="40"></input>
<br>
</td>
</tr>
<tr>
<td align="right">Transfer Fee</td>
<td><input type="text" id="standbyTransferFeeField" value="" size="80"/></td>
</tr>
</td>
</tr>
</table>
</td>
<td align="left" valign="top">
<button type="button" onClick="batchMint()">Batch Mint</button>
<br/>
<button type="button" onClick="getBatchNFTokens()">Get Batch NFTokens</button>
<br/>
<p align="left">
<!-- Note the increased maxlength to hold the most possible NFToken info. -->
<textarea id="standbyResultField" cols="80" rows="20" maxlength="524288"></textarea>
</p>
</td>
</tr>
</table>
</form>
</body>
</html>
```
| Previous | Next |
| :--- | ---: |
| [← Authorize Minter >](authorize-minter.html) | |

View File

@@ -21,7 +21,7 @@ This example shows how to:
2. Get a list of offers for the brokered item.
3. Broker a sale between two different accounts.
![Quickstart form with Broker Account](img/quickstart21.png)
[![Quickstart form with Broker Account](img/quickstart21.png)](img/quickstart21.png)
You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/quickstart/js/quickstart.zip){.github-code-download} archive to try each of the samples in your own browser.
@@ -38,7 +38,7 @@ You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-port
2. Click **Get New Operational Account**.
3. Click **Get New Broker Account**
![Quickstart form with Account Information](img/quickstart22.png)
[![Quickstart form with Account Information](img/quickstart22.png)](img/quickstart22.png)
## Prepare a Brokered Transaction
@@ -51,7 +51,7 @@ You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-port
6. Click **Create Sell Offer**.
![Sell Offer with Destination](img/quickstart23.png)
[![Sell Offer with Destination](img/quickstart23.png)](img/quickstart23.png)
2. Use the Operational account to create a NFToken Buy Offer.
1. Enter the **Amount** of your offer.
@@ -60,14 +60,14 @@ You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-port
4. Optionally enter the number of days until **Expiration**.
5. Click **Create Buy Offer**.
![Buy Offer](img/quickstart24.png)
[![Buy Offer](img/quickstart24.png)](img/quickstart24.png)
## Get Offers
1. Enter the **NFToken ID**.
2. Click **Get Offers**.
![Get Offers](img/quickstart25.png)
[![Get Offers](img/quickstart25.png)](img/quickstart25.png)
## Broker the Sale
@@ -76,7 +76,7 @@ You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-port
3. Enter a **Broker Fee**, in drops.
4. Click **Broker Sale**.
![Brokered Sale](img/quickstart26.png)
[![Brokered Sale](img/quickstart26.png)](img/quickstart26.png)
## Cancel Offer
@@ -86,7 +86,7 @@ After accepting a buy offer, a best practice for the broker is to cancel all oth
1. Enter the _nft_offer_index_ of the buy offer you want to cancel in the **Buy NFToken Offer Index** field.
2. Click **Cancel Offer**.
![Cancel Offer](img/quickstart27.png)
[![Cancel Offer](img/quickstart27.png)](img/quickstart27.png)
# Code Walkthrough
@@ -99,26 +99,29 @@ This script has new functions for brokered transactions and revised functions to
## Broker Get Offers
```
```javascript
// *******************************************************
// *************** Broker Get Offers *********************
// *******************************************************
async function brGetOffers() {
```
Connect to the ledger.
```
const standby_wallet = xrpl.Wallet.fromSeed(brokerSeedField.value)
```javascript
let net = getNet()
const client = new xrpl.Client(net)
results = 'Connecting to ' + getNet() + '...'
document.getElementById('brokerResultField').value = results
brokerResultField.value = results
await client.connect()
results += '\nConnected. Getting offers...'
document.getElementById('brokerResultField').value = results
brokerResultField.value = results
```
Request the list of sell offers for the token.
```
```javascript
results += '\n\n***Sell Offers***\n'
let nftSellOffers
try {
@@ -130,57 +133,57 @@ Request the list of sell offers for the token.
nftSellOffers = 'No sell offers.'
}
results += JSON.stringify(nftSellOffers,null,2)
document.getElementById('brokerResultField').value = results
brokerResultField.value = results
```
Request the list of buy offers for the token.
```
```javascript
results += '\n\n***Buy Offers***\n'
let nftBuyOffers
try {
nftBuyOffers = await client.request({
method: "nft_buy_offers",
nft_id: brokerTokenIdField.value })
} catch (err) {
nft_id: brokerTokenIdField.value
})
} catch (err) {
nftBuyOffers = 'No buy offers.'
}
results += JSON.stringify(nftBuyOffers,null,2)
document.getElementById('brokerResultField').value = results
brokerResultField.value = results
```
Disconnect from the ledger.
```
```javascript
client.disconnect()
}// End of brGetOffers()
```
## Broker Sale
```
```javascript
async function brokerSale() {
```
Connect to the ledger and get the accounts.
```
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
const broker_wallet = xrpl.Wallet.fromSeed (brokerSeedField.value)
let net = getNet()
const client = new xrpl.Client(net)
results = 'Connecting to ' + getNet() + '...'
document.getElementById('brokerResultField').value = results
await client.connect()
results += '\nConnected. Brokering sale...'
document.getElementById('brokerResultField').value = results
```javascript
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
const broker_wallet = xrpl.Wallet.fromSeed (brokerSeedField.value)
let net = getNet()
const client = new xrpl.Client(net)
results = 'Connecting to ' + getNet() + '...'
brokerResultField.value = results
await client.connect()
results += '\nConnected. Brokering sale...'
brokerResultField.value = results
```
Prepare the transaction. The difference between a brokered sale and a direct sale is that you provide both a sell offer and a buy offer, with an agreed-upon broker's fee.
```
```javascript
const transactionBlob = {
"TransactionType": "NFTokenAcceptOffer",
"Account": broker_wallet.classicAddress,
@@ -192,61 +195,63 @@ Prepare the transaction. The difference between a brokered sale and a direct sal
Submit the transaction and wait for the results.
```
```javascript
const tx = await client.submitAndWait(transactionBlob,{wallet: broker_wallet})
```
Report the results.
```
results += "\n\nTransaction result:\n" +
JSON.stringify(tx.result.meta.TransactionResult, null, 2)
results += "\nBalance changes:\n" +
JSON.stringify(xrpl.getBalanceChanges(tx.result.meta), null, 2)
document.getElementById('operationalBalanceField').value =
(await client.getXrpBalance(operational_wallet.address))
document.getElementById('standbyBalanceField').value =
(await client.getXrpBalance(standby_wallet.address))
document.getElementById('brokerBalanceField').value =
(await client.getXrpBalance(broker_wallet.address))
document.getElementById('brokerResultField').value = results
```javascript
results += "\n\nTransaction result:\n" +
JSON.stringify(tx.result.meta.TransactionResult, null, 2)
results += "\nBalance changes:\n" +
JSON.stringify(xrpl.getBalanceChanges(tx.result.meta), null, 2)
operationalBalanceField.value = (await client.getXrpBalance(operational_wallet.address))
standbyBalanceField.value = (await client.getXrpBalance(standby_wallet.address))
brokerBalanceField.value = (await client.getXrpBalance(broker_wallet.address))
brokerResultField.value = results
```
Disconnect from the ledger.
```
```javascript
client.disconnect()
}// End of brokerSale()
```
## Broker Cancel Offer
```
```javascript
// *******************************************************
// ************* Broker Cancel Offer ****************
// *******************************************************
async function brCancelOffer() {
```
Get the broker account and connect to the ledger.
```
```javascript
const wallet = xrpl.Wallet.fromSeed(brokerSeedField.value)
let net = getNet()
const client = new xrpl.Client(net)
results = 'Connecting to ' + net + '...'
document.getElementById('brokerResultField').value = results
let net = getNet()
const client = new xrpl.Client(net)
results = 'Connecting to ' + getNet() + '...'
brokerResultField.value = results
await client.connect()
results += "\nConnected. Cancelling offer..."
document.getElementById('brokerResultField').value = results
brokerResultField.value = results
```
The Token ID must be converted to an array.
```
```javascript
const tokenOfferIDs = [brokerTokenBuyOfferIndexField.value]
```
Prepare the transaction.
```
```javascript
const transactionBlob = {
"TransactionType": "NFTokenCancelOffer",
"Account": wallet.classicAddress,
@@ -256,13 +261,13 @@ Prepare the transaction.
Submit the transaction and wait for the results.
```
```javascript
const tx = await client.submitAndWait(transactionBlob,{wallet})
```
Get the sell offers and report the results.
```
```javascript
results += "\n\n***Sell Offers***\n"
let nftSellOffers
try {
@@ -278,7 +283,7 @@ Get the sell offers and report the results.
Get the buy offers and report the results.
```
```javascript
results += "\n\n***Buy Offers***\n"
let nftBuyOffers
try {
@@ -293,7 +298,7 @@ Get the buy offers and report the results.
Report the transaction results.
```
```javascript
results += "\nTransaction result:\n" +
JSON.stringify(tx.result.meta.TransactionResult, null, 2)
results += "\nBalance changes:\n" +
@@ -303,7 +308,7 @@ Report the transaction results.
Disconnect from the ledger.
```
```javascript
client.disconnect()
}// End of brCancelOffer()
```
@@ -311,13 +316,22 @@ Disconnect from the ledger.
To accommodate the broker account, override the `getAccount(type)` function to watch for the _broker_ type.
```
```javascript
// ***************************************************************************
// ************** Revised Functions ******************************************
// ***************************************************************************
// *******************************************************
// ************* Get Account *****************************
// *******************************************************
async function getAccount(type) {
```
Connect to the ledger.
```
```javascript
let net = getNet()
const client = new xrpl.Client(net)
results = 'Connecting to ' + net + '....'
@@ -325,105 +339,105 @@ Connect to the ledger.
Get the correct network host.
```
```javascript
let net = getNet()
const client = new xrpl.Client(net)
results = 'Connecting to ' + net + '....'
let faucetHost = null
if (type == 'standby') {
document.getElementById('standbyResultField').value = results
standbyResultField.value = results
}
if (type == 'operational') {
document.getElementById('operationalResultField').value = results
operationalResultField.value = results
}
if (type == 'broker') {
document.getElementById('brokerResultField').value = results
brokerResultField.value = results
}
```
Connect to the ledger.
```
```javascript
await client.connect()
results += '\nConnected, funding wallet.'
if (type == 'standby') {
document.getElementById('standbyResultField').value = results
standbyResultField.value = results
}
if (type == 'operational') {
document.getElementById('operationalResultField').value = results
operationalResultField.value = results
}
if (type == 'broker') {
document.getElementById('brokerResultField').value = results
brokerResultField.value = results
}
```
Create and fund a test account and report progress.
```
const my_wallet = (await client.fundWallet(null, { faucetHost })).wallet
```javascript
const my_wallet = (await client.fundWallet(null, { faucetHost })).wallet
results += '\nGot a wallet.'
if (type == 'standby') {
document.getElementById('standbyResultField').value = results
standbyResultField.value = results
}
if (type == 'operational') {
document.getElementById('operationalResultField').value = results
operationalResultField.value = results
}
if (type == 'broker') {
document.getElementById('brokerResultField').value = results
brokerResultField.value = results
}
```
Get the XRP balance for the new account.
```
const my_balance = (await client.getXrpBalance(my_wallet.address))
```javascript
const my_balance = (await client.getXrpBalance(my_wallet.address))
```
Populate the form fields for the appropriate account with the new account information.
```
```javascript
if (type == 'standby') {
document.getElementById('standbyAccountField').value = my_wallet.address
document.getElementById('standbyPubKeyField').value = my_wallet.publicKey
document.getElementById('standbyPrivKeyField').value = my_wallet.privateKey
document.getElementById('standbyBalanceField').value =
(await client.getXrpBalance(my_wallet.address))
document.getElementById('standbySeedField').value = my_wallet.seed
standbyAccountField.value = my_wallet.address
standbyPubKeyField.value = my_wallet.publicKey
standbyPrivKeyField.value = my_wallet.privateKey
standbyBalanceField.value = (await client.getXrpBalance(my_wallet.address))
standbySeedField.value = my_wallet.seed
results += '\nStandby account created.'
document.getElementById('standbyResultField').value = results
standbyResultField.value = results
}
if (type == 'operational') {
document.getElementById('operationalAccountField').value = my_wallet.address
document.getElementById('operationalPubKeyField').value = my_wallet.publicKey
document.getElementById('operationalPrivKeyField').value = my_wallet.privateKey
document.getElementById('operationalSeedField').value = my_wallet.seed
document.getElementById('operationalBalanceField').value =
(await client.getXrpBalance(my_wallet.address))
operationalAccountField.value = my_wallet.address
operationalPubKeyField.value = my_wallet.publicKey
operationalPrivKeyField.value = my_wallet.privateKey
operationalSeedField.value = my_wallet.seed
operationalBalanceField.value = (await client.getXrpBalance(my_wallet.address))
results += '\nOperational account created.'
document.getElementById('operationalResultField').value = results
operationalResultField.value = results
}
if (type == 'broker') {
document.getElementById('brokerAccountField').value = my_wallet.address
document.getElementById('brokerPubKeyField').value = my_wallet.publicKey
document.getElementById('brokerPrivKeyField').value = my_wallet.privateKey
document.getElementById('brokerSeedField').value = my_wallet.seed
document.getElementById('brokerBalanceField').value =
(await client.getXrpBalance(my_wallet.address))
brokerAccountField.value = my_wallet.address
brokerPubKeyField.value = my_wallet.publicKey
brokerPrivKeyField.value = my_wallet.privateKey
brokerSeedField.value = my_wallet.seed
brokerBalanceField.value = (await client.getXrpBalance(my_wallet.address))
results += '\nBroker account created.'
document.getElementById('brokerResultField').value = results
brokerResultField.value = results
}
```
Add the new account seed to corresponding line in the **Account Seeds** field.
```
document.getElementById('seeds').value = standbySeedField.value + '\n' + operationalSeedField.value + "\n" + brokerSeedField.value
```javascript
seeds.value = standbySeedField.value + '\n' + operationalSeedField.value + "\n" +
brokerSeedField.value
```
Disconnect from the ledger.
```
```javascript
client.disconnect()
} // End of getAccount()
```
@@ -432,31 +446,31 @@ Disconnect from the ledger.
Override the `getAccountsFromSeeds()` function to include the broker account fields.
```
```javascript
async function getAccountsFromSeeds() {
```
Connect to the ledger.
```
let net = getNet()
const client = new xrpl.Client(net)
results = 'Connecting to ' + getNet() + '....'
document.getElementById('standbyResultField').value = results
await client.connect()
results += '\nConnected, finding wallets.\n'
document.getElementById('standbyResultField').value = results
```javascript
let net = getNet()
const client = new xrpl.Client(net)
results = 'Connecting to ' + getNet() + '....'
standbyResultField.value = results
await client.connect()
results += '\nConnected, finding wallets.\n'
standbyResultField.value = results
```
Use the `split` function to parse the values from the **Seeds** field.
```
```javascript
var lines = seeds.value.split('\n');
```
Derive the accounts from the seed values.
```
```javascript
const standby_wallet = xrpl.Wallet.fromSeed(lines[0])
const operational_wallet = xrpl.Wallet.fromSeed(lines[1])
const broker_wallet = xrpl.Wallet.fromSeed(lines[2])
@@ -464,7 +478,7 @@ Derive the accounts from the seed values.
Get the XRP balances for the accounts.
```
```javascript
const standby_balance = (await client.getXrpBalance(standby_wallet.address))
const operational_balance = (await client.getXrpBalance(operational_wallet.address))
const broker_balance = (await client.getXrpBalance(broker_wallet.address))
@@ -472,38 +486,35 @@ Get the XRP balances for the accounts.
Populate the form fields based on the account values.
```
document.getElementById('standbyAccountField').value = standby_wallet.address
document.getElementById('standbyPubKeyField').value = standby_wallet.publicKey
document.getElementById('standbyPrivKeyField').value = standby_wallet.privateKey
document.getElementById('standbySeedField').value = standby_wallet.seed
document.getElementById('standbyBalanceField').value =
(await client.getXrpBalance(standby_wallet.address))
```javascript
standbyAccountField.value = standby_wallet.address
standbyPubKeyField.value = standby_wallet.publicKey
standbyPrivKeyField.value = standby_wallet.privateKey
standbySeedField.value = standby_wallet.seed
standbyBalanceField.value = (await client.getXrpBalance(standby_wallet.address))
document.getElementById('operationalAccountField').value = operational_wallet.address
document.getElementById('operationalPubKeyField').value = operational_wallet.publicKey
document.getElementById('operationalPrivKeyField').value = operational_wallet.privateKey
document.getElementById('operationalSeedField').value = operational_wallet.seed
document.getElementById('operationalBalanceField').value =
(await client.getXrpBalance(operational_wallet.address))
operationalAccountField.value = operational_wallet.address
operationalPubKeyField.value = operational_wallet.publicKey
operationalPrivKeyField.value = operational_wallet.privateKey
operationalSeedField.value = operational_wallet.seed
operationalBalanceField.value = (await client.getXrpBalance(operational_wallet.address))
document.getElementById('brokerAccountField').value = broker_wallet.address
document.getElementById('brokerPubKeyField').value = broker_wallet.publicKey
document.getElementById('brokerPrivKeyField').value = broker_wallet.privateKey
document.getElementById('brokerSeedField').value = broker_wallet.seed
document.getElementById('brokerBalanceField').value =
(await client.getXrpBalance(broker_wallet.address))
brokerAccountField.value = broker_wallet.address
brokerPubKeyField.value = broker_wallet.publicKey
brokerPrivKeyField.value = broker_wallet.privateKey
brokerSeedField.value = broker_wallet.seed
brokerBalanceField.value = (await client.getXrpBalance(broker_wallet.address))
```
Disconnect from the ledger.
```
```javascript
client.disconnect()
```
Use the `getBalances()` function to get the current balances of fiat currency.
```
```javascript
getBalances()
} // End of getAccountsFromSeeds()
@@ -513,13 +524,17 @@ Use the `getBalances()` function to get the current balances of fiat currency.
Override the `getBalances()` function to include the broker balance.
```
```javascript
// *******************************************************
// ****************** Get Balances ***********************
// *******************************************************
async function getBalances() {
```
Connect with the ledger.
```
```javascript
let net = getNet()
const client = new xrpl.Client(net)
results = 'Connecting to ' + getNet() + '....'
@@ -533,7 +548,7 @@ Connect with the ledger.
Derive each of the three accounts.
```
```javascript
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
const broker_wallet = xrpl.Wallet.fromSeed(brokerSeedField.value)
@@ -541,8 +556,8 @@ Derive each of the three accounts.
Get and report the Standby account balances.
```
results= "\nGetting standby account balances...\n"
```javascript
results = "\nGetting standby account balances...\n"
const standby_balances = await client.request({
command: "gateway_balances",
account: standby_wallet.address,
@@ -550,12 +565,12 @@ Get and report the Standby account balances.
hotwallet: [operational_wallet.address]
})
results += JSON.stringify(standby_balances.result, null, 2)
document.getElementById('standbyResultField').value = results
standbyResultField.value = results
```
Get and report the Operational account balances.
```
```javascript
results= "\nGetting operational account balances...\n"
const operational_balances = await client.request({
command: "account_lines",
@@ -563,12 +578,12 @@ Get and report the Operational account balances.
ledger_index: "validated"
})
results += JSON.stringify(operational_balances.result, null, 2)
document.getElementById('operationalResultField').value = results
operationalResultField.value = results
```
Get and report the Broker account balances.
```
```javascript
results= "\nGetting broker account balances...\n"
const broker_balances = await client.request({
command: "account_lines",
@@ -576,35 +591,41 @@ Get and report the Broker account balances.
ledger_index: "validated"
})
results += JSON.stringify(broker_balances.result, null, 2)
document.getElementById('brokerResultField').value = results
brokerResultField.value = results
```
Update the XRP balances for the three accounts.
```
document.getElementById('operationalBalanceField').value =
(await client.getXrpBalance(operational_wallet.address))
document.getElementById('standbyBalanceField').value =
(await client.getXrpBalance(standby_wallet.address))
document.getElementById('brokerBalanceField').value =
(await client.getXrpBalance(broker_wallet.address))
```javascript
operationalBalanceField.value = (await client.getXrpBalance(operational_wallet.address))
standbyBalanceField.value = (await client.getXrpBalance(standby_wallet.address))
brokerBalanceField.value = (await client.getXrpBalance(broker_wallet.address))
```
Disconnect from the ledger.
```
```javascript
client.disconnect()
} // end of getBalances()
```
## 5.broker-nfts.html
Revise the HTML form to add a new Broker section at the top.
```
```html
<html>
<head>
<title>Token Test Harness</title>
<script src='https://unpkg.com/xrpl@2.2.3'></script>
<link href='https://fonts.googleapis.com/css?family=Work Sans' rel='stylesheet'>
<style>
body{font-family: "Work Sans", sans-serif;padding: 20px;background: #fafafa;}
h1{font-weight: bold;}
input, button {padding: 6px;margin-bottom: 8px;}
button{font-weight: bold;font-family: "Work Sans", sans-serif;}
td{vertical-align: middle;}
</style>
<script src='https://unpkg.com/xrpl@2.7.0/build/xrpl-latest-min.js'></script>
<script src='ripplex1-send-xrp.js'></script>
<script src='ripplex2-send-currency.js'></script>
<script src='ripplex3-mint-nfts.js'></script>
@@ -623,7 +644,7 @@ Revise the HTML form to add a new Broker section at the top.
<body>
<h1>Token Test Harness</h1>
<form id="theForm">
Choose your ledger instance:
Choose your ledger instance:
&nbsp;&nbsp;
<input type="radio" id="tn" name="server"
value="wss://s.altnet.rippletest.net:51233" checked>
@@ -1039,10 +1060,5 @@ Revise the HTML form to add a new Broker section at the top.
</table>
</form>
</body>
</html>
</html>
```
| Previous | Next |
| :--- | ---: |
| [← 4. Transfer NFTokens >](transfer-nftokens.html) | [Authorize Minter → >](authorize-minter.html)|

View File

@@ -12,26 +12,22 @@ labels:
This example shows how to:
1. Create accounts on the Testnet, funded with 10000 test XRP with no actual value.
1. Create accounts on the Testnet, funded with 1000 test XRP with no actual value.
2. Retrieve the accounts from seed values.
3. Transfer XRP between accounts.
When you create an account, you receive a public/private key pair offline. It does not appear on the ledger until it is funded with XRP. This example shows how to create accounts for Testnet, but not how to create an account that you can use on Mainnet.
![Token Test Harness](img/quickstart2.png)
When you create an account, you receive a public/private key pair offline. Your account does not appear on the ledger until it is funded with XRP. This example shows how to create accounts for Testnet, but not how to create an account that you can use on Mainnet.
[![Token Test Harness](img/quickstart2.png)](img/quickstart2.png)
## Prerequisites
To get started, create a new folder on your local disk and install the JavaScript library using `npm`.
```
npm install xrpl
```
Download and expand the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/quickstart/js/quickstart.zip){.github-code-download} archive.
**Note:** Without the Quickstart Samples, you will not be able to try the examples that follow.
@@ -40,45 +36,38 @@ Download and expand the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-p
To get test accounts:
1. Open `1.get-accounts-send-xrp.html` in a browser
2. Choose **Testnet** or **Devnet**.
3. Click **Get New Standby Account**.
4. Click **Get New Operational Account.**
5. Copy and paste the **Seeds** field in a persistent location, such as a Notepad, so that you can reuse the accounts after reloading the form.
![Standby and Operational Accounts](img/quickstart3.png)
[![Standby and Operational Accounts](img/quickstart3.png)](img/quickstart3.png)
You can transfer XRP between your new accounts. Each account has its own fields and buttons.
To transfer XRP between accounts:
To transfer XRP from the Standby account to the Operational account:
1. On the Standby (left) side of the form, enter the **Amount** of XRP to send.
2. Copy and paste the **Operational Account** field to the Standby **Destination** field.
3. Click **Send XRP>** to transfer XRP from the standby account to the operational account
To transfer XRP from the Operational account to the Standby account:
1. Enter the **Amount** of XRP to send.
2. Enter the **Destination** account (for example, copy and paste the Operational **Account Field** to the Standby **Destination** field).
3. Click **Send XRP>** to transfer XRP from the standby account to the operational account, or **&lt;Send XRP** to transfer XRP from the operational account to the standby account.
![Transferred XRP](img/quickstart4.png)
1. On the Operational (right) side of the form, enter the **Amount** of XRP to send.
2. Copy and paste the **Standby Account** field to the Standby **Destination** field.
3. Click **&lt;Send XRP** to transfer XRP from the Operational account to the Standby account.
[![Transferred XRP](img/quickstart4.png)](img/quickstart4.png)
# Code Walkthrough
You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/quickstart/js/quickstart.zip){.github-code-download} in the source repository for this website.
## ripplex-1-send-xrp.js
This example can be used with any XRP Ledger network, _Testnet_, or _Devnet_. You can update the code to choose different or additional XRP Ledger networks.
### getNet()
<!-- SPELLING_IGNORE: getnet -->
@@ -90,433 +79,327 @@ This example can be used with any XRP Ledger network, _Testnet_, or _Devnet_. Yo
function getNet() {
```
This function uses brute force `if` statements to discover the selected network instance and return the URI.
```javascript
let net
if (document.getElementById("tn").checked) net = "wss://s.altnet.rippletest.net:51233"
if (document.getElementById("dn").checked) net = "wss://s.devnet.rippletest.net:51233"
return net
} // End of getNet()
let net
if (document.getElementById("tn").checked) net = "wss://s.altnet.rippletest.net:51233"
if (document.getElementById("dn").checked) net = "wss://s.devnet.rippletest.net:51233"
return net
} // End of getNet()
```
### getAccount(type)
<!-- SPELLING_IGNORE: getaccount -->
```javascript
// *******************************************************
// ************* Get Account *****************************
// *******************************************************
async function getAccount(type) {
async function getAccount(type) {
```
Get the selected ledger.
```javascript
let net = getNet()
let net = getNet()
```
Instantiate a client.
```javascript
const client = new xrpl.Client(net)
const client = new xrpl.Client(net)
```
Use the _results_ variable to capture progress information.
```javascript
results = 'Connecting to ' + net + '....'
results = 'Connecting to ' + net + '....'
```
Use the default faucet using a _null_ value.
```javascript
let faucetHost = null
let faucetHost = null
```
Report progress in the appropriate results field.
```javascript
if (type == 'standby') {
document.getElementById('standbyResultField').value = results
} else {
document.getElementById('operationalResultField').value = results
}
if (type == 'standby') {
standbyResultField.value = results
} else {
operationalResultField.value = results
}
```
Connect to the server.
```javascript
await client.connect()
await client.connect()
results += '\nConnected, funding wallet.'
if (type == 'standby') {
standbyResultField.value = results
} else {
operationalResultField.value = results
}
results += '\nConnected, funding wallet.'
if (type == 'standby') {
document.getElementById('standbyResultField').value = results
} else {
document.getElementById('operationalResultField').value = results
}
```
Create and fund a test account.
```javascript
const my_wallet = (await client.fundWallet(null, { faucetHost: walletServer})).wallet
const my_wallet = (await client.fundWallet(null, { faucetHost })).wallet
results += '\nGot a wallet.'
if (type == 'standby') {
standbyResultField.value = results
} else {
operationalResultField.value = results
}
```
Get the current XRP balance for the account.
```javascript
const my_balance = (await client.getXrpBalance(my_wallet.address))
const my_balance = (await client.getXrpBalance(my_wallet.address))
```
If this is a standby account, populate the standby account fields.
```javascript
if (type == 'standby') {
document.getElementById('standbyAccountField').value = my_wallet.address
document.getElementById('standbyPubKeyField').value = my_wallet.publicKey
document.getElementById('standbyPrivKeyField').value = my_wallet.privateKey
document.getElementById('standbyBalanceField').value =
(await client.getXrpBalance(my_wallet.address))
document.getElementById('standbySeedField').value = my_wallet.seed
results += '\nStandby account created.'
document.getElementById('standbyResultField').value = results
if (type == 'standby') {
standbyAccountField.value = my_wallet.address
standbyPubKeyField.value = my_wallet.publicKey
standbyPrivKeyField.value = my_wallet.privateKey
standbyBalanceField.value = (await client.getXrpBalance(my_wallet.address))
standbySeedField.value = my_wallet.seed
results += '\nStandby account created.'
standbyResultField.value = results
```
Otherwise, populate the operational account fields.
```javascript
} else {
document.getElementById('operationalAccountField').value = my_wallet.address
document.getElementById('operationalPubKeyField').value = my_wallet.publicKey
document.getElementById('operationalPrivKeyField').value = my_wallet.privateKey
document.getElementById('operationalSeedField').value = my_wallet.seed
document.getElementById('operationalBalanceField').value =
(await client.getXrpBalance(my_wallet.address))
results += '\nOperational account created.'
document.getElementById('operationalResultField').value = results
}
} else {
operationalAccountField.value = my_wallet.address
operationalPubKeyField.value = my_wallet.publicKey
operationalPrivKeyField.value = my_wallet.privateKey
operationalSeedField.value = my_wallet.seed
operationalBalanceField.value = (await client.getXrpBalance(my_wallet.address))
results += '\nOperational account created.'
operationalResultField.value = results
}
```
Insert the seed values for both accounts as they are created to the **Seeds** field as a convenience. You can copy the values and store them offline. When you reload this form or another in this tutorial, copy and paste them into the **Seeds** field to retrieve the accounts with the `getAccountsFromSeeds()` function.
```javascript
document.getElementById('seeds').value = standbySeedField.value + '\n' + operationalSeedField.value
seeds.value = standbySeedField.value + '\n' + operationalSeedField.value
```
Disconnect from the XRP ledger.
```javascript
client.disconnect()
} // End of getAccount()
```
client.disconnect()
} // End of getAccount()
```
### Get Accounts from Seeds
```javascript
// *******************************************************
// ********** Get Accounts from Seeds ********************
// *******************************************************
async function getAccountsFromSeeds() {
async function getAccountsFromSeeds() {
```
Connect to the selected network.
```javascript
let net = getNet()
const client = new xrpl.Client(net)
results = 'Connecting to ' + getNet() + '....'
standbyResultField.value = results
await client.connect()
results += '\nConnected, finding wallets.\n'
standbyResultField.value = results
```
let net = getNet()
const client = new xrpl.Client(net)
results = 'Connecting to ' + getNet() + '....'
document.getElementById('standbyResultField').value = results
await client.connect()
results += '\nConnected, finding wallets.\n'
document.getElementById('standbyResultField').value = results
```
Parse the **Seeds** field.
```javascript
var lines = seeds.value.split('\n')
```
var lines = seeds.value.split('\n');
```
Get the `standby_wallet` based on the seed in the first line. Get the `operational_wallet` based on the seed in the second line.
```javascript
const standby_wallet = xrpl.Wallet.fromSeed(lines[0])
const operational_wallet = xrpl.Wallet.fromSeed(lines[1])
```
const standby_wallet = xrpl.Wallet.fromSeed(lines[0])
const operational_wallet = xrpl.Wallet.fromSeed(lines[1])
```
Get the current XRP balances for the accounts.
```javascript
const standby_balance = (await client.getXrpBalance(standby_wallet.address))
const operational_balance = (await client.getXrpBalance(operational_wallet.address))
```
const standby_balance = (await client.getXrpBalance(standby_wallet.address))
const operational_balance = (await client.getXrpBalance(operational_wallet.address))
```
Populate the fields for the standby and operational accounts.
```javascript
standbyAccountField.value = standby_wallet.address
standbyPubKeyField.value = standby_wallet.publicKey
standbyPrivKeyField.value = standby_wallet.privateKey
standbySeedField.value = standby_wallet.seed
standbyBalanceField.value = (await client.getXrpBalance(standby_wallet.address))
operationalAccountField.value = operational_wallet.address
operationalPubKeyField.value = operational_wallet.publicKey
operationalPrivKeyField.value = operational_wallet.privateKey
operationalSeedField.value = operational_wallet.seed
operationalBalanceField.value = (await client.getXrpBalance(operational_wallet.address))
```
document.getElementById('standbyAccountField').value = standby_wallet.address
document.getElementById('standbyPubKeyField').value = standby_wallet.publicKey
document.getElementById('standbyPrivKeyField').value = standby_wallet.privateKey
document.getElementById('standbySeedField').value = standby_wallet.seed
document.getElementById('standbyBalanceField').value =
(await client.getXrpBalance(standby_wallet.address))
document.getElementById('operationalAccountField').value = operational_wallet.address
document.getElementById('operationalPubKeyField').value = operational_wallet.publicKey
document.getElementById('operationalPrivKeyField').value = operational_wallet.privateKey
document.getElementById('operationalSeedField').value = operational_wallet.seed
document.getElementById('operationalBalanceField').value =
(await client.getXrpBalance(operational_wallet.address))
```
Disconnect from the XRP Ledger.
```javascript
client.disconnect()
} // End of getAccountsFromSeeds()
```
client.disconnect()
} // End of getAccountsFromSeeds()
```
### Send XRP
```
```javascript
// *******************************************************
// ******************** Send XRP *************************
// *******************************************************
async function sendXRP() {
async function sendXRP() {
```
Connect to your selected ledger.
```
results = "Connecting to the selected ledger.\n"
document.getElementById('standbyResultField').value = results
let net = getNet()
results = 'Connecting to ' + getNet() + '....'
const client = new xrpl.Client(net)
await client.connect()
results += "\nConnected. Sending XRP.\n"
document.getElementById('standbyResultField').value = results
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
const sendAmount = standbyAmountField.value
results += "\nstandby_wallet.address: = " + standby_wallet.address
document.getElementById('standbyResultField').value = results
```javascript
results = "Connecting to the selected ledger.\n"
standbyResultField.value = results
let net = getNet()
results = 'Connecting to ' + getNet() + '....'
const client = new xrpl.Client(net)
await client.connect()
results += "\nConnected. Sending XRP.\n"
standbyResultField.value = results
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
const sendAmount = standbyAmountField.value
results += "\nstandby_wallet.address: = " + standby_wallet.address
standbyResultField.value = results
```
Prepare the transaction. This is a Payment transaction from the standby address to the operational address.
The _Payment_ transaction expects the XRP to be expressed in drops, or 1/millionth of an XRP. You can use the `xrpToDrops()` method to convert the send amount for you (which beats having to type an extra 6 zeroes to send 1 XRP).
```javascript
const prepared = await client.autofill({
"TransactionType": "Payment",
"Account": standby_wallet.address,
"Amount": xrpl.xrpToDrops(sendAmount),
"Destination": standbyDestinationField.value
})
```
const prepared = await client.autofill({
"TransactionType": "Payment",
"Account": standby_wallet.address,
"Amount": xrpl.xrpToDrops(sendAmount),
"Destination": standbyDestinationField.value
})
```
Sign the prepared transaction.
```
const signed = standby_wallet.sign(prepared)
const signed = standby_wallet.sign(prepared)
```
Submit the transaction and wait for the results.
```
const tx = await client.submitAndWait(signed.tx_blob)
const tx = await client.submitAndWait(signed.tx_blob)
```
Request the balance changes caused by the transaction and report the results.
```
results += "\nBalance changes: " +
JSON.stringify(xrpl.getBalanceChanges(tx.result.meta), null, 2)
standbyResultField.value = results
results += "\nBalance changes: " +
JSON.stringify(xrpl.getBalanceChanges(tx.result.meta), null, 2)
document.getElementById('standbyResultField').value = results
document.getElementById('standbyBalanceField').value =
(await client.getXrpBalance(standby_wallet.address))
document.getElementById('operationalBalanceField').value =
(await client.getXrpBalance(operational_wallet.address))
client.disconnect()
} // End of sendXRP()
standbyBalanceField.value = (await client.getXrpBalance(standby_wallet.address))
operationalBalanceField.value = (await client.getXrpBalance(operational_wallet.address))
client.disconnect()
} // End of sendXRP()
```
### Reciprocal Transactions
For each of the transactions, there is an accompanying reciprocal transaction, with the prefix _oP,_ for the operational account. See the corresponding function for the standby account for code commentary.
```
```javascript
// **********************************************************************
// ****** Reciprocal Transactions ****************************************
// ****** Reciprocal Transactions ***************************************
// **********************************************************************
// *******************************************************
// ********* Send XRP from Operational account ***********
// *******************************************************
async function oPsendXRP() {
results = "Connecting to the selected ledger.\n"
operationalResultField.value = results
let net = getNet()
results = 'Connecting to ' + getNet() + '....'
const client = new xrpl.Client(net)
await client.connect()
results += "\nConnected. Sending XRP.\n"
operationalResultField.value = results
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
const sendAmount = operationalAmountField.value
results += "\noperational_wallet.address: = " + operational_wallet.address
operationalResultField.value = results
// ---------------------------------------------------------- Prepare transaction
const prepared = await client.autofill({
"TransactionType": "Payment",
"Account": operational_wallet.address,
"Amount": xrpl.xrpToDrops(operationalAmountField.value),
"Destination": operationalDestinationField.value
})
async function oPsendXRP() {
// ---------------------------------------------------- Sign prepared instructions
const signed = operational_wallet.sign(prepared)
results = "Connecting to testnet.\n"
document.getElementById('operationalResultField').value = results
let net = getNet()
results = 'Connecting to ' + getNet() + '....'
const client = new xrpl.Client(net)
await client.connect()
results += "\nConnected. Sending XRP.\n"
document.getElementById('operationalResultField').value = results
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
const sendAmount = operationalAmountField.value
results += "\noperational_wallet.address: = " + operational_wallet.address
document.getElementById('operationalResultField').value = results
// ---------------------------------- Prepare transaction
// Note that the destination is hard coded.
const prepared = await client.autofill({
"TransactionType": "Payment",
"Account": operational_wallet.address,
"Amount": xrpl.xrpToDrops(operationalAmountField.value),
"Destination": operationalDestinationField.value
})
// ---------------------------- Sign prepared instructions
const signed = operational_wallet.sign(prepared)
// ------------------------------------ Submit signed blob
const tx = await client.submitAndWait(signed.tx_blob)
results += "\nBalance changes: " +
JSON.stringify(xrpl.getBalanceChanges(tx.result.meta), null, 2)
document.getElementById('operationalResultField').value = results
document.getElementById('standbyBalanceField').value =
(await client.getXrpBalance(standby_wallet.address))
document.getElementById('operationalBalanceField').value =
(await client.getXrpBalance(operational_wallet.address))
client.disconnect()
} // End of oPsendXRP()
// ------------------------------------------------------------ Submit signed blob
const tx = await client.submitAndWait(signed.tx_blob)
results += "\nBalance changes: " +
JSON.stringify(xrpl.getBalanceChanges(tx.result.meta), null, 2)
operationalResultField.value = results
standbyBalanceField.value = (await client.getXrpBalance(standby_wallet.address))
operationalBalanceField.value = (await client.getXrpBalance(operational_wallet.address))
client.disconnect()
} // End of oPsendXRP()
```
## 1.get-accounts-send-xrp.html
Create a standard HTML form to send transactions and requests, then display the results.
```html
<html>
<head>
@@ -529,7 +412,7 @@ Create a standard HTML form to send transactions and requests, then display the
button{font-weight: bold;font-family: "Work Sans", sans-serif;}
td{vertical-align: middle;}
</style>
<script src='https://unpkg.com/xrpl@2.2.3'></script>
<script src='https://unpkg.com/xrpl@2.7.0/build/xrpl-latest-min.js'></script>
<script src='ripplex1-send-xrp.js'></script>
<script>
if (typeof module !== "undefined") {
@@ -747,7 +630,3 @@ Create a standard HTML form to send transactions and requests, then display the
</body>
</html>
```
| Previous | Next |
| :--- | ---: |
| [← XRPL Quickstart >](xrpl-quickstart.html) | [2. Create Trust Line and Send Currency → >](create-trustline-send-currency.html) |

View File

@@ -14,29 +14,22 @@ labels:
This example shows how to:
1. Configure accounts to allow transfer of funds to third party accounts.
2. Set a currency type for transactions.
3. Create a trust line between the standby account and the operational account.
4. Send issued currency between accounts.
5. Display account balances for all currencies.
![Test harness with currency transfer](img/quickstart5.png)
[![Test harness with currency transfer](img/quickstart5.png)](img/quickstart5.png)
You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/quickstart/js/quickstart.zip){.github-code-download} archive to try each of the samples in your own browser.
**Note:** Without the Quickstart Samples, you will not be able to try the examples that follow.
## Usage
Open the Token Test Harness and get accounts:
1. Open `2.create-trustline-send-currency.html` in a browser.
2. Get test accounts.
1. If you have existing account seeds
@@ -46,40 +39,27 @@ Open the Token Test Harness and get accounts:
1. Click **Get New Standby Account**.
2. Click **Get New Operational Account**.
## Create Trust Line
To create a trust line between accounts:
1. Enter a [currency code](https://www.iban.com/currency-codes) in the **Currency** field.
2. Enter the maximum transfer limit in the **Amount** field.
3. Enter the destination account value in the **Destination** field.
4. Click **Create Trustline**. <!-- SPELLING_IGNORE: trustline --><!--{# TODO: update the test harness to spell trust line as two words #}-->
3. Enter a [currency code](https://www.iban.com/currency-codes) in the **Currency** field.
4. Enter the maximum transfer limit in the **Amount** field.
5. Enter the destination account value in the **Destination** field.
6. Click **Create Trustline**. <!-- SPELLING_IGNORE: trustline --><!--{# TODO: update the test harness to spell trust line as two words #}-->
![Trust line results](img/quickstart6.png)
[![Trust line results](img/quickstart6.png)](img/quickstart6.png)
## Send an Issued Currency Token
To transfer an issued currency token, once you have created a trust line:
1. Enter the **Amount**.
2. Enter the **Destination**.
3. Enter the **Currency** type.
4. Click **Send Currency**.
![Currency transfer](img/quickstart7.png)
[![Currency transfer](img/quickstart7.png)](img/quickstart7.png)
# Code Walkthrough
@@ -92,318 +72,275 @@ You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-port
When transferring fiat currency, the actual transfer of funds is not simultaneous, as it is with XRP. If currency is transferred to a third party for a different currency, there can be a devaluation of the currency that impacts the originating account. To avoid this situation, this up and down valuation of currency, known as _rippling_, is not allowed by default. Currency transferred from one account can only be transferred back to the same account. To enable currency transfer to third parties, you need to set the `rippleDefault` value to true. The Token Test Harness provides a checkbox to enable or disable rippling.
```
```javascript
// *******************************************************
// **************** Configure Account ********************
// *******************************************************
async function configureAccount(type, defaultRippleSetting) {
```
Connect to the ledger
```javascript
let net = getNet()
let resultField = 'standbyResultField'
const client = new xrpl.Client(net)
results = 'Connecting to ' + getNet() + '....'
await client.connect()
results += '\nConnected, finding wallet.'
```
async function configureAccount(type, rippleDefault) {
let net = getNet()
const client = new xrpl.Client(net)
results = 'Connecting to ' + getNet() + '....'
document.getElementById('standbyResultField').value = results
await client.connect()
results += '\nConnected, finding wallet.'
document.getElementById('standbyResultField').value = results
```
Get the account wallets.
```
if (type=='standby') {
my_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
} else {
my_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
}
results += '\Ripple Default Setting: ' + rippleDefault
document.getElementById('standbyResultField').value = results
if (type=='standby') {
my_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
} else {
my_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
resultField = 'operationalResultField'
}
results += '\nRipple Default Setting: ' + defaultRippleSetting
resultField.value = results
```
Prepare the transaction. If the `rippleDefault` argument is true, set the `asfDefaultRipple` flag. If it is false, clear the `asfDefaultRipple` flag.
```javascript
let settings_tx = {}
if (defaultRippleSetting) {
settings_tx = {
"TransactionType": "AccountSet",
"Account": my_wallet.address,
"SetFlag": xrpl.AccountSetAsfFlags.asfDefaultRipple
}
results += '\n Set Default Ripple flag.'
} else {
settings_tx = {
"TransactionType": "AccountSet",
"Account": my_wallet.address,
"ClearFlag": xrpl.AccountSetAsfFlags.asfDefaultRipple
}
results += '\n Clear Default Ripple flag.'
}
results += '\nSending account setting.'
resultField.value = results
```
let settings_tx = {}
if (rippleDefault) {
settings_tx = {
"TransactionType": "AccountSet",
"Account": my_wallet.address,
"SetFlag": xrpl.AccountSetAsfFlags.asfDefaultRipple
}
results += '\n Set Default Ripple flag.'
} else {
settings_tx = {
"TransactionType": "AccountSet",
"Account": my_wallet.address,
"ClearFlag": xrpl.AccountSetAsfFlags.asfDefaultRipple
}
results += '\n Clear Default Ripple flag.'
}
results += '\nSending account setting.'
document.getElementById('standbyResultField').value = results
```
Auto-fill the default values for the transaction.
```javascript
const prepared = await client.autofill(settings_tx)
```
const cst_prepared = await client.autofill(settings_tx)
```
Sign the transaction.
```javascript
const signed = my_wallet.sign(prepared)
```
const cst_signed = my_wallet.sign(cst_prepared)
```
Submit the transaction and wait for the result.
```javascript
const result = await client.submitAndWait(signed.tx_blob)
```
const cst_result = await client.submitAndWait(cst_signed.tx_blob)
```
Report the result.
```javascript
if (result.result.meta.TransactionResult == "tesSUCCESS") {
results += '\nAccount setting succeeded.'
document.getElementById(resultField).value = results
} else {
throw 'Error sending transaction: ${result}'
results += '\nAccount setting failed.'
resultField.value = results
}
client.disconnect()
} // End of configureAccount()
```
if (cst_result.result.meta.TransactionResult == "tesSUCCESS") {
results += '\nAccount setting succeeded.'
document.getElementById('standbyResultField').value = results
} else {
throw 'Error sending transaction: ${cst_result}'
results += '\nAccount setting failed.'
document.getElementById('standbyResultField').value = results
}
client.disconnect()
} // End of configureAccount()
```
### Create Trust Line
A trust line enables two accounts to trade a defined currency up to a set limit. This gives the participants assurance that any exchanges are between known entities at agreed upon maximum amounts.
```
```javascript
// *******************************************************
// ***************** Create TrustLine ********************
// *******************************************************
async function createTrustline() {
let net = getNet()
const client = new xrpl.Client(net)
results = 'Connecting to ' + getNet() + '....'
standbyResultField.value = results
async function createTrustline(type) {
let net = getNet()
const client = new xrpl.Client(net)
results = 'Connecting to ' + getNet() + '....'
document.getElementById('standbyResultField').value = results
await client.connect()
results += '\nConnected.'
document.getElementById('standbyResultField').value = results
await client.connect()
results += '\nConnected.'
standbyResultField.value = results
```
Get the standby and operational wallets.
```javascript
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
```
```
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
```
Capture the currency code from the standby currency field.
```javascript
const currency_code = standbyCurrencyField.value
```
const currency_code = standbyCurrencyField.value
```
Define the transaction, capturing the currency code and (limit) amount from the form fields.
```javascript
const trustSet_tx = {
"TransactionType": "TrustSet",
"Account": standbyDestinationField.value,
"LimitAmount": {
"currency": standbyCurrencyField.value,
"issuer": standby_wallet.address,
"value": standbyAmountField.value
}
}
```
const trustSet_tx = {
"TransactionType": "TrustSet",
"Account": standbyDestinationField.value,
"LimitAmount": {
"currency": standbyCurrencyField.value,
"issuer": standby_wallet.address,
"value": standbyAmountField.value
}
}
```
Prepare the transaction by automatically filling the default parameters.
```
const ts_prepared = await client.autofill(trustSet_tx)
```javascript
const ts_prepared = await client.autofill(trustSet_tx)
```
Sign the transaction.
```
const ts_signed = operational_wallet.sign(ts_prepared)
results += '\nCreating trust line from operational account to standby account...'
document.getElementById('standbyResultField').value = results
```javascript
const ts_signed = operational_wallet.sign(ts_prepared)
results += '\nCreating trust line from operational account to standby account...'
standbyResultField.value = results
```
Submit the transaction and wait for the results.
```
const ts_result = await client.submitAndWait(ts_signed.tx_blob)
```javascript
const ts_result = await client.submitAndWait(ts_signed.tx_blob)
```
Report the results.
```
if (ts_result.result.meta.TransactionResult == "tesSUCCESS") {
results += '\nTrustline established between account \n' + operational_wallet.address + ' \n and account\n' + standby_wallet.address + '.'
document.getElementById('standbyResultField').value = results
} else {
results += '\nTrustLine failed. See JavaScript console for details.'
document.getElementById('standbyResultField').value = results
throw 'Error sending transaction: ${ts_result.result.meta.TransactionResult}'
}
} //End of createTrustline()
```
```javascript
if (ts_result.result.meta.TransactionResult == "tesSUCCESS") {
results += '\nTrustline established between account \n' +
standbyDestinationField.value + ' \n and account\n' + standby_wallet.address + '.'
standbyResultField.value = results
} else {
results += '\nTrustLine failed. See JavaScript console for details.'
document.getElementById('standbyResultField').value = results
throw 'Error sending transaction: ${ts_result.result.meta.TransactionResult}'
}
} //End of createTrustline()
```
### Send Issued Currency
Once you have created a trust line from an account to your own, you can send issued currency tokens to that account, up to the established limit.
```
```javascript
// *******************************************************
// *************** Send Issued Currency ******************
// *******************************************************
async function sendCurrency() {
async function sendCurrency() {
```
Connect to the ledger.
```javascript
let net = getNet()
const client = new xrpl.Client(net)
results = 'Connecting to ' + getNet() + '....'
document.getElementById('standbyResultField').value = results
await client.connect()
results += '\nConnected.'
standbyResultField.value = results
```
let net = getNet()
const client = new xrpl.Client(net)
results = 'Connecting to ' + getNet() + '....'
document.getElementById('standbyResultField').value = results
await client.connect()
results += '\nConnected.'
document.getElementById('standbyResultField').value = results
```
Get the account wallets.
```
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
const currency_code = standbyCurrencyField.value
const issue_quantity = standbyAmountField.value
const send_token_tx = {
"TransactionType": "Payment",
"Account": standby_wallet.address,
"Amount": {
"currency": currency_code,
"value": issue_quantity,
"issuer": standby_wallet.address
},
"Destination": standbyDestinationField.value
}
```javascript
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
const currency_code = standbyCurrencyField.value
const issue_quantity = standbyAmountField.value
const send_token_tx = {
"TransactionType": "Payment",
"Account": standby_wallet.address,
"Amount": {
"currency": standbyCurrencyField.value,
"value": standbyAmountField.value,
"issuer": standby_wallet.address
},
"Destination": standbyDestinationField.value
}
```
Prepare the transaction by automatically filling default values.
```
const pay_prepared = await client.autofill(send_token_tx)
```javascript
const pay_prepared = await client.autofill(send_token_tx)
```
Sign the transaction.
```
const pay_signed = standby_wallet.sign(pay_prepared)
results += 'Sending ${issue_quantity} ${currency_code} to ' + standbyDestinationField.value + '...'
document.getElementById('standbyResultField').value = results
```javascript
const pay_signed = standby_wallet.sign(pay_prepared)
results += 'Sending ${issue_quantity} ${currency_code} to ' +
standbyDestinationField.value + '...'
standbyResultField.value = results
```
Submit the transaction and wait for the results.
```
const pay_result = await client.submitAndWait(pay_signed.tx_blob)
```javascript
const pay_result = await client.submitAndWait(pay_signed.tx_blob)
```
Report the results.
```
if (pay_result.result.meta.TransactionResult == "tesSUCCESS") {
results += 'Transaction succeeded: https://testnet.xrpl.org/transactions/${pay_signed.hash}'
document.getElementById('standbyResultField').value = results
} else {
results += 'Transaction failed: See JavaScript console for details.'
document.getElementById('standbyResultField').value = results
throw 'Error sending transaction: ${pay_result.result.meta.TransactionResult}'
}
document.getElementById('standbyBalanceField').value =
(await client.getXrpBalance(standby_wallet.address))
document.getElementById('operationalBalanceField').value =
(await client.getXrpBalance(operational_wallet.address))
client.disconnect()
getBalances()
} // end of sendCurrency()
```javascript
if (pay_result.result.meta.TransactionResult == "tesSUCCESS") {
results += 'Transaction succeeded: https://testnet.xrpl.org/transactions/${pay_signed.hash}'
standbyResultField.value = results
} else {
results += 'Transaction failed: See JavaScript console for details.'
standbyResultField.value = results
throw 'Error sending transaction: ${pay_result.result.meta.TransactionResult}'
}
standbyBalanceField.value = (await client.getXrpBalance(standby_wallet.address))
operationalBalanceField.value = (await client.getXrpBalance(operational_wallet.address))
getBalances()
client.disconnect()
} // end of sendCurrency()
```
@@ -411,228 +348,200 @@ Report the results.
### Get Balances
```
```javascript
// *******************************************************
// ****************** Get Balances ***********************
// *******************************************************
async function getBalances() {
```
async function getBalances() {
```
Connect to the ledger.
```javascript
let net = getNet()
const client = new xrpl.Client(net)
results = 'Connecting to ' + getNet() + '....'
standbyResultField.value = results
await client.connect()
results += '\nConnected.'
standbyResultField.value = results
```
let net = getNet()
const client = new xrpl.Client(net)
results = 'Connecting to ' + getNet() + '....'
document.getElementById('standbyResultField').value = results
await client.connect()
results += '\nConnected.'
document.getElementById('standbyResultField').value = results
```
Get the account wallets.
```javascript
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
results = "\nGetting standby account balances...\n"
```
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
results= "\nGetting standby account balances...\n"
```
Define and send the request for the standby account, then wait for the results.
```javascript
const standby_balances = await client.request({
command: "gateway_balances",
account: standby_wallet.address,
ledger_index: "validated",
hotwallet: [operational_wallet.address]
})
```
const standby_balances = await client.request({
command: "gateway_balances",
account: standby_wallet.address,
ledger_index: "validated",
hotwallet: [operational_wallet.address]
})
```
Report the results.
```javascript
results += JSON.stringify(standby_balances.result, null, 2)
standbyResultField.value = results
```
results += JSON.stringify(standby_balances.result, null, 2)
document.getElementById('standbyResultField').value = results
```
Define and send the request for the operational account, then wait for the results.
```javascript
results += "\nGetting operational account balances...\n"
const operational_balances = await client.request({
command: "gateway_balances",
account: operational_wallet.address,
ledger_index: "validated"
})
```
results= "\nGetting operational account balances...\n"
const operational_balances = await client.request({
command: "account_lines",
account: operational_wallet.address,
ledger_index: "validated"
})
```
Report the results.
```javascript
results += JSON.stringify(operational_balances.result, null, 2)
operationalResultField.value = results
```
results += JSON.stringify(operational_balances.result, null, 2)
document.getElementById('operationalResultField').value = results
```
Update the form with current XRP balances.
```javascript
operationalBalanceField.value = (await client.getXrpBalance(operational_wallet.address))
standbyResultField.value = results
standbyBalanceField.value = (await client.getXrpBalance(standby_wallet.address))
```
document.getElementById('operationalBalanceField').value =
(await client.getXrpBalance(operational_wallet.address))
document.getElementById('standbyBalanceField').value =
(await client.getXrpBalance(standby_wallet.address))
```
Disconnect from the ledger.
```javascript
client.disconnect()
} // End of getBalances()
```
client.disconnect()
} // End of getBalances()
```
### Reciprocal Transactions
For each of the transactions, there is an accompanying reciprocal transaction, with the prefix _oP,_ for the operational account. See the corresponding function for the standby account for code commentary. The `getBalances()` request does not have a reciprocal transaction, because it reports balances for both accounts.
```
```javascript
// *******************************************************
// ************ Create Operational TrustLine *************
// *******************************************************
async function oPcreateTrustline() {
let net = getNet()
const client = new xrpl.Client(net)
results = 'Connecting to ' + getNet() + '....'
document.getElementById('operationalResultField').value = results
await client.connect()
results += '\nConnected.'
document.getElementById('operationalResultField').value = results
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
const trustSet_tx = {
"TransactionType": "TrustSet",
"Account": operationalDestinationField.value,
"LimitAmount": {
"currency": operationalCurrencyField.value,
"issuer": operational_wallet.address,
"value": operationalAmountField.value
}
}
const ts_prepared = await client.autofill(trustSet_tx)
const ts_signed = standby_wallet.sign(ts_prepared)
results += '\nCreating trust line from operational account to ' + operationalDestinationField.value + ' account...'
document.getElementById('operationalResultField').value = results
const ts_result = await client.submitAndWait(ts_signed.tx_blob)
if (ts_result.result.meta.TransactionResult == "tesSUCCESS") {
results += '\nTrustline established between account \n' + standby_wallet.address + ' \n and account\n' +
operationalDestinationField.value + '.'
document.getElementById('operationalResultField').value = results
} else {
results += '\nTrustLine failed. See JavaScript console for details.'
document.getElementById('operationalResultField').value = results
throw 'Error sending transaction: ${ts_result.result.meta.TransactionResult}'
}
} //End of oPcreateTrustline
async function oPcreateTrustline() {
let net = getNet()
const client = new xrpl.Client(net)
results = 'Connecting to ' + getNet() + '....'
operationalResultField.value = results
await client.connect()
results += '\nConnected.'
operationalResultField.value = results
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
const trustSet_tx = {
"TransactionType": "TrustSet",
"Account": operationalDestinationField.value,
"LimitAmount": {
"currency": operationalCurrencyField.value,
"issuer": operational_wallet.address,
"value": operationalAmountField.value
}
}
const ts_prepared = await client.autofill(trustSet_tx)
const ts_signed = standby_wallet.sign(ts_prepared)
results += '\nCreating trust line from operational account to ' +
operationalDestinationField.value + ' account...'
operationalResultField.value = results
const ts_result = await client.submitAndWait(ts_signed.tx_blob)
if (ts_result.result.meta.TransactionResult == "tesSUCCESS") {
results += '\nTrustline established between account \n' + operational_wallet.address +
' \n and account\n' + operationalDestinationField.value + '.'
operationalResultField.value = results
} else {
results += '\nTrustLine failed. See JavaScript console for details.'
operationalResultField.value = results
throw 'Error sending transaction: ${ts_result.result.meta.TransactionResult}'
}
} //End of oPcreateTrustline
// *******************************************************
// ************* Operational Send Issued Currency ********
// *******************************************************
async function oPsendCurrency() {
let net = getNet()
const client = new xrpl.Client(net)
results = 'Connecting to ' + getNet() + '....'
document.getElementById('operationalResultField').value = results
await client.connect()
results += '\nConnected.'
document.getElementById('operationalResultField').value = results
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
const currency_code = operationalCurrencyField.value
const issue_quantity = operationalAmountField.value
const send_token_tx = {
"TransactionType": "Payment",
"Account": operational_wallet.address,
"Amount": {
"currency": currency_code,
"value": issue_quantity,
"issuer": operational_wallet.address
},
"Destination": operationalDestinationField.value
}
const pay_prepared = await client.autofill(send_token_tx)
const pay_signed = operational_wallet.sign(pay_prepared)
results += 'Sending ${issue_quantity} ${currency_code} to ' + operationalDestinationField.value + '...'
document.getElementById('operationalResultField').value = results
const pay_result = await client.submitAndWait(pay_signed.tx_blob)
if (pay_result.result.meta.TransactionResult == "tesSUCCESS") {
results += 'Transaction succeeded: https://testnet.xrpl.org/transactions/${pay_signed.hash}'
document.getElementById('operationalResultField').value = results
} else {
results += 'Transaction failed: See JavaScript console for details.'
document.getElementById('operationalResultField').value = results
throw 'Error sending transaction: ${pay_result.result.meta.TransactionResult}'
}
document.getElementById('standbyBalanceField').value =
(await client.getXrpBalance(standby_wallet.address))
document.getElementById('operationalBalanceField').value =
(await client.getXrpBalance(operational_wallet.address))
getBalances()
client.disconnect()
} // end of oPsendCurrency()
async function oPsendCurrency() {
let net = getNet()
const client = new xrpl.Client(net)
results = 'Connecting to ' + getNet() + '....'
operationalResultField.value = results
await client.connect()
results += '\nConnected.'
operationalResultField.value = results
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
const currency_code = operationalCurrencyField.value
const issue_quantity = operationalAmountField.value
const send_token_tx = {
"TransactionType": "Payment",
"Account": operational_wallet.address,
"Amount": {
"currency": currency_code,
"value": issue_quantity,
"issuer": operational_wallet.address
},
"Destination": operationalDestinationField.value
}
const pay_prepared = await client.autofill(send_token_tx)
const pay_signed = operational_wallet.sign(pay_prepared)
results += 'Sending ${issue_quantity} ${currency_code} to ' +
operationalDestinationField.value + '...'
operationalResultField.value = results
const pay_result = await client.submitAndWait(pay_signed.tx_blob)
if (pay_result.result.meta.TransactionResult == "tesSUCCESS") {
results += 'Transaction succeeded: https://testnet.xrpl.org/transactions/${pay_signed.hash}'
operationalResultField.value = results
} else {
results += 'Transaction failed: See JavaScript console for details.'
operationalResultField.value = results
throw 'Error sending transaction: ${pay_result.result.meta.TransactionResult}'
}
standbyBalanceField.value = (await client.getXrpBalance(standby_wallet.address))
operationalBalanceField.value = (await client.getXrpBalance(operational_wallet.address))
getBalances()
client.disconnect()
} // end of oPsendCurrency()
```
## 2.create-trustline-send-currency.html
Update the form to support the new functions.
```
```html
<html>
<head>
<title>Token Test Harness</title>
<script src='https://unpkg.com/xrpl@2.2.3'></script>
<link href='https://fonts.googleapis.com/css?family=Work Sans' rel='stylesheet'>
<style>
body{font-family: "Work Sans", sans-serif;padding: 20px;background: #fafafa;}
h1{font-weight: bold;}
input, button {padding: 6px;margin-bottom: 8px;}
button{font-weight: bold;font-family: "Work Sans", sans-serif;}
td{vertical-align: middle;}
</style>
<script src='https://unpkg.com/xrpl@2.7.0/build/xrpl-latest-min.js'></script>
<script src='ripplex1-send-xrp.js'></script>
<script src='ripplex2-send-currency.js'></script>
<script>
@@ -731,7 +640,7 @@ Update the form to support the new functions.
Destination
</td>
<td>
<input type="text" id="standbyDestinationField" size="40"></input>
<input type="text" id="standbyDestinationField" size="40"></input>
<br>
</td>
</tr>
@@ -845,7 +754,7 @@ Update the form to support the new functions.
Amount
</td>
<td>
<input type="text" id="operationalAmountField" size="40"></input>
<input type="text" id="operationalAmountField" size="40"></input>
<br>
</td>
</tr>
@@ -894,11 +803,4 @@ Update the form to support the new functions.
</form>
</body>
</html>
```
---
| Previous | Next |
| :--- | ---: |
| [← 1. Create Accounts and Send XRP >](create-accounts-send-xrp.html) | [3. Mint and Burn NFTokens → >](mint-and-burn-nftokens.html) |
```

View File

@@ -12,15 +12,11 @@ labels:
This example shows how to:
1. Mint new Non-fungible Tokens (NFTokens).
2. Get a list of existing NFTokens.
3. Delete (Burn) a NFToken.
![Test harness with mint NFToken fields](img/quickstart8.png)
[![Test harness with mint NFToken fields](img/quickstart8.png)](img/quickstart8.png)
# Usage
@@ -28,8 +24,6 @@ You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-port
## Get Accounts
1. Open `3.mint-nfts.html` in a browser.
2. Get test accounts.
1. If you have existing Testnet account seeds:
@@ -39,11 +33,7 @@ You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-port
1. Click **Get New Standby Account**.
2. Click **Get New Operational Account**.
![Get accounts](img/quickstart9.png)
[![Get accounts](img/quickstart9.png)](img/quickstart9.png)
## Mint a NFToken
@@ -52,40 +42,27 @@ To mint a non-fungible token object:
1. Set the **Flags** field. For testing purposes, we recommend setting the value to _8_. This sets the _tsTransferable_ flag, meaning that the NFToken object can be transferred to another account. Otherwise, the NFToken object can only be transferred back to the issuing account. See [NFToken Mint](https://xrpl.org/nftokenmint.html#:~:text=Example%20NFTokenMint%20JSON-,NFTokenMint%20Fields,-NFTokenMint%20Flags) for information about all of the available flags for minting NFTokens.
2. Enter the **Token URL**. This is a URI that points to the data or metadata associated with the NFToken object. You can use the sample URI provided if you do not have one of your own.
3. Enter the **Transfer Fee**, a percentage of the proceeds from future sales of the NFToken that will be returned to the original creator. This is a value of 0-50000 inclusive, allowing transfer rates between 0.000% and 50.000% in increments of 0.001%. If you do not set the **Flags** field to allow the NFToken to be transferrable, set this field to 0.
4. Click **Mint Token**.
4. Click **Mint NFToken**.
![Mint NFToken fields](img/quickstart10.png)
[![Mint NFToken fields](img/quickstart10.png)](img/quickstart10.png)
## Get Tokens
Click **Get Tokens** to get a list of NFTokens owned by the account.
![Get NFTokens](img/quickstart11.png)
Click **Get NFTokens** to get a list of NFTokens owned by the account.
[![Get NFTokens](img/quickstart11.png)](img/quickstart11.png)
## Burn a Token
The current owner of a NFToken can always destroy (or _burn)_ a NFToken object.
The current owner of a NFToken can always destroy (or _burn_) a NFToken object.
To permanently destroy a NFToken:
1. Enter the **Token ID**.
2. Click **Burn Token**.
![Burn NFTokens](img/quickstart12.png)
2. Click **Burn NFToken**.
[![Burn NFTokens](img/quickstart12.png)](img/quickstart12.png)
# Code Walkthrough
@@ -96,123 +73,99 @@ You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-port
### Mint Token
```
```javascript
// *******************************************************
// ********************** Mint Token *********************
// *******************************************************
async function mintToken() {
```
Connect to the ledger and get the account wallets.
```
```javascript
results = 'Connecting to ' + getNet() + '....'
document.getElementById('standbyResultField').value = results
standbyResultField.value = results
let net = getNet()
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
const client = new xrpl.Client(net)
await client.connect()
results += '\nConnected. Minting NFToken.'
document.getElementById('standbyResultField').value = results
standbyResultField.value = results
```
Define the transaction.
```javascript
```
const transactionBlob = {
const transactionJson = {
"TransactionType": "NFTokenMint",
"Account": standby_wallet.classicAddress,
```
Note that the URI field expects a hexadecimal value rather than the literal URI string. You can use the `convertStringToHex` utility to transform the URI in real time.
```
```javascript
"URI": xrpl.convertStringToHex(standbyTokenUrlField.value),
```
If you want the NFToken to be transferable to third parties, set the **Flags** field to _8_.
```
```javascript
"Flags": parseInt(standbyFlagsField.value),
```
The Transfer Fee is a value 0 to 50000, used to set a royalty of 0.000% to 50.000% in increments of 0.001.
```
```javascript
"TransferFee": parseInt(standbyTransferFeeField.value),
```
The `TokenTaxon` is a required value. It is an arbitrary value defined by the issuer. If you do not have a use for the field, you can set it to _0_.
```
```javascript
"NFTokenTaxon": 0 //Required, but if you have no use for it, set to zero.
}
```
Send the transaction and wait for the response.
```javascript
const tx = await client.submitAndWait(transactionJson, { wallet: standby_wallet} )
```
const tx = await client.submitAndWait(transactionBlob, { wallet: standby_wallet} )
```
Request a list of NFTs owned by the account.
```
```javascript
const nfts = await client.request({
method: "account_nfts",
account: standby_wallet.classicAddress
account: standby_wallet.classicAddress
})
```
Report the results.
```
```javascript
results += '\n\nTransaction result: '+ tx.result.meta.TransactionResult
results += '\n\nnfts: ' + JSON.stringify(nfts, null, 2)
document.getElementById('standbyBalanceField').value =
(await client.getXrpBalance(standby_wallet.address))
document.getElementById('operationalBalanceField').value = results
standbyBalanceField.value = (await client.getXrpBalance(standby_wallet.address))
standbyResultField.value = results
```
Disconnect from the ledger.
```
```javascript
client.disconnect()
} //End of mintToken()
```
### Get Tokens
```
```javascript
// *******************************************************
// ******************* Get Tokens ************************
// *******************************************************
@@ -220,29 +173,87 @@ Disconnect from the ledger.
async function getTokens() {
```
Connect to the ledger and get the account.
```
```javascript
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
let net = getNet()
const client = new xrpl.Client(net)
results = 'Connecting to ' + net + '...'
document.getElementById('standbyResultField').value = results
standbyResultField.value = results
await client.connect()
results += '\nConnected. Getting NFTokens...'
document.getElementById('standbyResultField').value = results
standbyResultField.value = results
```
Request a list of NFTs owned by the account.
```
const nfts = await client.request({
```javascript
const nfts = await client.request({
method: "account_nfts",
account: standby_wallet.classicAddress
account: standby_wallet.classicAddress
})
```
Report the results.
```javascript
results += '\nNFTs:\n ' + JSON.stringify(nfts,null,2)
standbyResultField.value = results
```
Disconnect from the ledger.
```javascript
client.disconnect()
} //End of getTokens()
```
### Burn Token
```javascript
// *******************************************************
// ********************* Burn Token **********************
// *******************************************************
async function burnToken() {
```
Connect to the ledger and get the account wallets.
```javascript
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
let net = getNet()
const client = new xrpl.Client(net)
results = 'Connecting to ' + net + '...'
standbyResultField.value = results
await client.connect()
results += '\nConnected. Burning NFToken...'
standbyResultField.value = results
```
Define the transaction.
```javascript
const transactionBlob = {
"TransactionType": "NFTokenBurn",
"Account": standby_wallet.classicAddress,
"NFTokenID": standbyTokenIdField.value
}
```
Submit the transaction and wait for the results.
```javascript
const tx = await client.submitAndWait(transactionBlob,{wallet: standby_wallet})
```
Request a list of NFTokens owned by the client.
```javascript
const nfts = await client.request({
method: "account_nfts",
account: standby_wallet.classicAddress
})
```
@@ -250,115 +261,36 @@ Request a list of NFTs owned by the account.
Report the results.
```
results += '\nNFTs:\n ' + JSON.stringify(nfts,null,2)
document.getElementById('standbyResultField').value = results
```
Disconnect from the ledger.
```
```javascript
results += '\nTransaction result: '+ tx.result.meta.TransactionResult
results += '\nBalance changes: ' +
JSON.stringify(xrpl.getBalanceChanges(tx.result.meta), null, 2)
standbyResultField.value = results
standbyBalanceField.value = (await client.getXrpBalance(standby_wallet.address))
results += '\nNFTs: \n' + JSON.stringify(nfts,null,2)
standbyResultField.value = results
client.disconnect()
} //End of getTokens()
}// End of burnToken()
```
### Burn Token
```
// *******************************************************
// ********************* Burn Token **********************
// *******************************************************
```
Connect to the ledger and get the account wallets.
```
async function burnToken() {
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
let net = getNet()
const client = new xrpl.Client(net)
results = 'Connecting to ' + net + '...'
document.getElementById('standbyResultField').value = results
await client.connect()
results += '\nConnected. Burning NFToken...'
document.getElementById('standbyResultField').value = results
```
Define the transaction.
```
const transactionBlob = {
"TransactionType": "NFTokenBurn",
"Account": standby_wallet.classicAddress,
"TokenID": standbyTokenIdField.value
}
```
Submit the transaction and wait for the results.
```
const tx = await client.submitAndWait(transactionBlob,{wallet: standby_wallet})
```
Request a list of NFTokens owned by the client.
```
const nfts = await client.request({
method: "account_nfts",
account: standby_wallet.classicAddress
})
```
Report the results.
```
results += '\nTransaction result: '+ tx.result.meta.TransactionResult
results += '\nBalance changes: ' +
JSON.stringify(xrpl.getBalanceChanges(tx.result.meta), null, 2)
document.getElementById('standbyResultField').value = results
document.getElementById('standbyBalanceField').value =
(await client.getXrpBalance(standby_wallet.address))
results += '\nNFTs: \n' + JSON.stringify(nfts,null,2)
document.getElementById('standbyResultField').value = results
client.disconnect()
}
// End of burnToken()
```
### Reciprocal Transactions
These transactions are the same as the Standby account transactions, but for the Operational account.
```
```javascript
// *******************************************************
// ************** Operational Mint Token *****************
// *******************************************************
async function oPmintToken() {
results = 'Connecting to ' + getNet() + '....'
document.getElementById('operationalResultField').value = results
operationalResultField.value = results
let net = getNet()
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
const client = new xrpl.Client(net)
await client.connect()
results += '\nConnected. Minting NFToken.'
document.getElementById('operationalResultField').value = results
operationalResultField.value = results
// Note that you must convert the token URL to a hexadecimal
// value for this transaction.
@@ -376,40 +308,38 @@ async function oPmintToken() {
const tx = await client.submitAndWait(transactionBlob, { wallet: operational_wallet} )
const nfts = await client.request({
method: "account_nfts",
account: operational_wallet.classicAddress
account: operational_wallet.classicAddress
})
// ------------------------------------------------------- Report results
results += '\n\nTransaction result: '+ tx.result.meta.TransactionResult
results += '\n\nnfts: ' + JSON.stringify(nfts, null, 2)
document.getElementById('operationalBalanceField').value =
(await client.getXrpBalance(operational_wallet.address))
document.getElementById('operationalResultField').value = results
operationalBalanceField.value = (await client.getXrpBalance(operational_wallet.address))
operationalResultField.value = results
client.disconnect()
} //End of oPmintToken
// *******************************************************
// ************** Operational Get Tokens *****************
// *******************************************************
async function oPgetTokens() {
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
let net = getNet()
const client = new xrpl.Client(net)
results = 'Connecting to ' + getNet() + '...'
document.getElementById('operationalResultField').value = results
await client.connect()
results += '\nConnected. Getting NFTokens...'
document.getElementById('operationalResultField').value = results
const nfts = await client.request({
method: "account_nfts",
account: operational_wallet.classicAddress
})
results += '\nNFTs:\n ' + JSON.stringify(nfts,null,2)
document.getElementById('operationalResultField').value = results
client.disconnect()
} //End of oPgetTokens
async function oPgetTokens() {
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
let net = getNet()
const client = new xrpl.Client(net)
results = 'Connecting to ' + getNet() + '...'
operationalResultField.value = results
await client.connect()
results += '\nConnected. Getting NFTokens...'
operationalResultField.value = results
const nfts = await client.request({
method: "account_nfts",
account: operational_wallet.classicAddress
})
results += '\nNFTs:\n ' + JSON.stringify(nfts,null,2)
operationalResultField.value = results
client.disconnect()
} //End of oPgetTokens
// *******************************************************
// ************* Operational Burn Token ******************
@@ -420,10 +350,10 @@ async function oPburnToken() {
let net = getNet()
const client = new xrpl.Client(net)
results = 'Connecting to ' + getNet() + '...'
document.getElementById('operationalResultField').value = results
operationalResultField.value = results
await client.connect()
results += '\nConnected. Burning NFToken...'
document.getElementById('operationalResultField').value = results
operationalResultField.value = results
// ------------------------------------------------------- Prepare transaction
const transactionBlob = {
@@ -436,35 +366,36 @@ async function oPburnToken() {
const tx = await client.submitAndWait(transactionBlob,{wallet: operational_wallet})
const nfts = await client.request({
method: "account_nfts",
account: operational_wallet.classicAddress
account: operational_wallet.classicAddress
})
results += '\nTransaction result: '+ tx.result.meta.TransactionResult
results += '\nBalance changes: ' +
JSON.stringify(xrpl.getBalanceChanges(tx.result.meta), null, 2)
document.getElementById('operationalResultField').value = results
document.getElementById('operationalBalanceField').value =
(await client.getXrpBalance(operational_wallet.address))
document.getElementById('operationalBalanceField').value =
(await client.getXrpBalance(operational_wallet.address))
operationalResultField.value = results
operationalBalanceField.value = (await client.getXrpBalance(operational_wallet.address))
operationalBalanceField.value = (await client.getXrpBalance(operational_wallet.address))
results += '\nNFTs: \n' + JSON.stringify(nfts,null,2)
document.getElementById('operationalResultField').value = results
operationalResultField.value = results
client.disconnect()
}
// End of oPburnToken()
```
## 3.mint-nfts.html
Bold text in the following indicates changes to the form that support the new functions.
```
```html
<html>
<head>
<title>Token Test Harness</title>
<script src='https://unpkg.com/xrpl@2.2.3'></script>
<link href='https://fonts.googleapis.com/css?family=Work Sans' rel='stylesheet'>
<style>
body{font-family: "Work Sans", sans-serif;padding: 20px;background: #fafafa;}
h1{font-weight: bold;}
input, button {padding: 6px;margin-bottom: 8px;}
button{font-weight: bold;font-family: "Work Sans", sans-serif;}
td{vertical-align: middle;}
</style>
<script src='https://unpkg.com/xrpl@2.7.0/build/xrpl-latest-min.js'></script>
<script src='ripplex1-send-xrp.js'></script>
<script src='ripplex2-send-currency.js'></script>
<script src='ripplex3-mint-nfts.js'></script>
@@ -482,7 +413,8 @@ Bold text in the following indicates changes to the form that support the new fu
<body>
<h1>Token Test Harness</h1>
<form id="theForm">
Choose your ledger instance:&nbsp;&nbsp;
Choose your ledger instance:
&nbsp;&nbsp;
<input type="radio" id="tn" name="server"
value="wss://s.altnet.rippletest.net:51233" checked>
<label for="testnet">Testnet</label>
@@ -772,16 +704,4 @@ Bold text in the following indicates changes to the form that support the new fu
</form>
</body>
</html>
```
---
| Previous | Next |
| :--- | ---: |
| [← 2. Create Trust Line and Send Currency >](create-trustline-send-currency.html) | [4. Transfer NFTokens → >](transfer-nftokens.html) |
<!--{# common link defs #}-->
{% include '_snippets/rippled-api-links.md' %}
{% include '_snippets/tx-type-links.md' %}
{% include '_snippets/rippled_versions.md' %}
```

File diff suppressed because it is too large Load Diff

View File

@@ -54,10 +54,4 @@ To get started, create a new folder on your local disk and install the JavaScrip
Download and expand the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/quickstart/js/quickstart.zip){.github-code-download} archive.
**Note:** Without the Quickstart Samples, you will not be able to try the examples that follow.
---
| Previous | Next |
| :--- | ---: |
| | [1. Create Accounts and Send XRP → >](create-accounts-send-xrp.html) |
**Note:** Without the Quickstart Samples, you will not be able to try the examples that follow.