+
+
+
+
+
\ No newline at end of file
diff --git a/_code-samples/nft-modular-tutorials/transfer-nfts.js b/_code-samples/nft-modular-tutorials/transfer-nfts.js
new file mode 100644
index 0000000000..0ad7993186
--- /dev/null
+++ b/_code-samples/nft-modular-tutorials/transfer-nfts.js
@@ -0,0 +1,324 @@
+
+// *********************************************************
+// *************** Create Sell Offer ***********************
+// *********************************************************
+
+async function createSellOffer() {
+ const wallet = xrpl.Wallet.fromSeed(accountSeedField.value);
+ let results = '\nCreating sell offer...';
+ resultField.value = results;
+
+ try {
+ const client = new xrpl.Client(getNet());
+ await client.connect();
+ try {
+ const destination = destinationField.value || undefined;
+ const expiration = expirationField.value ? configureExpiration() : undefined;
+
+ const transactionJson = {
+ TransactionType: "NFTokenCreateOffer",
+ Account: wallet.classicAddress,
+ NFTokenID: nftIdField.value,
+ Flags: 1,
+ };
+
+ const amount = configureAmount();
+ if (amount) { // Only add Amount if it's defined
+ transactionJson.Amount = amount;
+ } else {
+ console.warn("Amount is undefined. Sell offer might be invalid.");
+ results += "\nWarning: Amount is undefined. Sell offer might be invalid, unless you plan to give away the NFT.";
+ resultField.value = results;
+ }
+
+ if (expiration) {
+ transactionJson.Expiration = expiration;
+ }
+ if (destination) {
+ transactionJson.Destination = destination;
+ }
+
+ console.log("Creating Sell Offer Transaction:", JSON.stringify(transactionJson, null, 2));
+
+ const tx = await client.submitAndWait(transactionJson, { wallet });
+ results += `\nSell offer created successfully!\nTransaction Hash: ${tx.result.hash}\nEngine Result: ${tx.result.engine_result}`;
+ resultField.value = results;
+
+ } finally {
+ client.disconnect();
+ }
+ } catch (error) {
+ console.error("Error creating sell offer:", error);
+ results = `\nError: ${error.message || error}`;
+ resultField.value = results;
+ }
+}// End of createSellOffer()
+
+// *******************************************************
+// ***************** Create Buy Offer ********************
+// *******************************************************
+
+async function createBuyOffer() {
+ const wallet = xrpl.Wallet.fromSeed(accountSeedField.value);
+ let net = getNet();
+ const client = new xrpl.Client(net);
+ await client.connect();
+ let results = '\n=== Connected. Creating buy offer. ===';
+ resultField.value = results;
+
+ try {
+ // Use the external configureAmount() function
+ let amount = configureAmount();
+console.log("Amount:", amount);
+ // Use the external configureExpiration() function
+ let expiration = configureExpiration(); // This will return a number or an empty string from the original logic
+
+ let transactionJson = {
+ "TransactionType": "NFTokenCreateOffer",
+ "Account": wallet.classicAddress,
+ "Owner": nftOwnerField.value,
+ "NFTokenID": nftIdField.value,
+ "Flags": 0, // Ensure no tfSellNFToken flag for a buy offer
+ };
+
+ // Only add Amount if it's defined (not undefined or an empty string)
+ if (amount !== undefined && amount !== '') {
+ transactionJson.Amount = amount;
+ } else {
+ results += "\nError: Amount field is required for a buy offer.";
+ resultField.value = results;
+ client.disconnect();
+ return;
+ }
+
+ if (destinationField.value !== '') {
+ transactionJson.Destination = destinationField.value;
+ }
+
+ // Only add Expiration if it's not an empty string
+ if (expiration > 0) {
+ transactionJson.Expiration = expiration;
+ }
+
+ console.log("Buy Offer Transaction JSON:\n" + JSON.stringify(transactionJson, null, 2));
+
+ const tx = await client.submitAndWait(transactionJson, { wallet: wallet });
+
+ results += "\n\n=== Sell Offers ===\n";
+ let nftSellOffers;
+ try {
+ nftSellOffers = await client.request({
+ method: "nft_sell_offers",
+ nft_id: nftIdField.value
+ });
+ } catch (err) {
+ nftSellOffers = "=== No sell offers. ===";
+ }
+ results += JSON.stringify(nftSellOffers, null, 2);
+ results += "\n\n=== Buy Offers ===\n";
+ let nftBuyOffers;
+ try {
+ nftBuyOffers = await client.request({
+ method: "nft_buy_offers",
+ nft_id: nftIdField.value
+ });
+ results += JSON.stringify(nftBuyOffers, null, 2);
+ } catch (err) {
+ results += "=== No buy offers. ===";
+ }
+
+ // Check transaction results -------------------------------------------------
+ results += "\n\n=== Transaction result:\n" +
+ JSON.stringify(tx.result.meta.TransactionResult, null, 2);
+ results += "\n\n=== Balance changes:\n" +
+ JSON.stringify(xrpl.getBalanceChanges(tx.result.meta), null, 2);
+ resultField.value = results;
+
+ } catch (error) {
+ console.error('Error creating buy offer:', error);
+ results += "\n\n=== Error: " + error;
+ resultField.value = results;
+ } finally {
+ client.disconnect();
+ }
+}// End of createBuyOffer()
+
+// *******************************************************
+// ******************** Cancel Offer *********************
+// *******************************************************
+
+async function cancelOffer() {
+ const wallet = xrpl.Wallet.fromSeed(accountSeedField.value)
+ let net = getNet()
+ const client = new xrpl.Client(net)
+ await client.connect()
+ let results = "\n=== Connected. Cancelling offer. ==="
+ resultField.value = results
+
+ const tokenOfferIDs = [nftOfferIdField.value]
+
+ // Prepare transaction -------------------------------------------------------
+ const transactionJson = {
+ "TransactionType": "NFTokenCancelOffer",
+ "Account": wallet.classicAddress,
+ "NFTokenOffers": tokenOfferIDs
+ }
+ // Submit transaction --------------------------------------------------------
+ const tx = await client.submitAndWait(transactionJson, { wallet })
+
+ results += "\n\n=== Sell Offers===\n"
+ let nftSellOffers
+ try {
+ nftSellOffers = await client.request({
+ method: "nft_sell_offers",
+ nft_id: nftIdField.value
+ })
+ } catch (err) {
+ nftSellOffers = "=== No sell offers. ==="
+ }
+ results += JSON.stringify(nftSellOffers, null, 2)
+ results += "\n\n=== Buy Offers ===\n"
+ let nftBuyOffers
+ try {
+ nftBuyOffers = await client.request({
+ method: "nft_buy_offers",
+ nft_id: nftIdField.value
+ })
+ results += JSON.stringify(nftBuyOffers, null, 2)
+ } catch (err) {
+ nftBuyOffers = '=== No buy offers. ==='
+ }
+
+ // Check transaction results -------------------------------------------------
+
+ results += "\n=== Transaction result:\n" +
+ JSON.stringify(tx.result.meta.TransactionResult, null, 2)
+ results += "\n=== Balance changes:\n" +
+ JSON.stringify(xrpl.getBalanceChanges(tx.result.meta), null, 2)
+ resultField.value = results
+
+ client.disconnect() // End of cancelOffer()
+}
+
+// *******************************************************
+// ******************** Get Offers ***********************
+// *******************************************************
+
+async function getOffers() {
+ const wallet = xrpl.Wallet.fromSeed(accountSeedField.value)
+ let net = getNet()
+ const client = new xrpl.Client(net)
+ await client.connect()
+
+ let results = '\nConnected. Getting offers...'
+ resultField.value = results
+
+ // --- Sell Offers ---
+ results += '\n\n=== Sell Offers ===\n'
+ let nftSellOffers
+ try {
+ nftSellOffers = await client.request({
+ method: "nft_sell_offers",
+ nft_id: nftIdField.value
+ })
+ } catch (err) {
+ nftSellOffers = 'No sell offers found for this NFT ID.'
+ }
+ results += JSON.stringify(nftSellOffers, null, 2)
+ resultField.value = results
+
+ // --- Buy Offers ---
+ results += '\n\n=== Buy Offers ===\n'
+ let nftBuyOffers
+ try {
+ nftBuyOffers = await client.request({
+ method: "nft_buy_offers",
+ nft_id: nftIdField.value
+ })
+ } catch (err) {
+ // Log the actual error for debugging
+ nftBuyOffers = 'No buy offers found for this NFT ID.' // More descriptive
+ }
+ results += JSON.stringify(nftBuyOffers, null, 2) // Append the JSON string
+ resultField.value = results // Update the display with buy offers
+
+ client.disconnect()
+}// End of getOffers()
+
+// *******************************************************
+// ****************** Accept Sell Offer ******************
+// *******************************************************
+
+async function acceptSellOffer() {
+ const wallet = xrpl.Wallet.fromSeed(accountSeedField.value)
+ let net = getNet()
+ const client = new xrpl.Client(net)
+ await client.connect()
+ let results = '\n=== Connected. Accepting sell offer. ===\n\n'
+ resultField.value = results
+
+ // Prepare transaction -------------------------------------------------------
+ const transactionJson = {
+ "TransactionType": "NFTokenAcceptOffer",
+ "Account": wallet.classicAddress,
+ "NFTokenSellOffer": nftOfferIdField.value,
+ }
+ // Submit transaction --------------------------------------------------------
+ const tx = await client.submitAndWait(transactionJson, { wallet: wallet })
+ const nfts = await client.request({
+ method: "account_nfts",
+ account: wallet.classicAddress
+ })
+
+ // Check transaction results -------------------------------------------------
+
+ xrpBalanceField.value = (await client.getXrpBalance(wallet.address))
+
+
+ results += '=== Transaction result:\n'
+ results += JSON.stringify(tx.result.meta.TransactionResult, null, 2)
+ results += '\n=== Balance changes:'
+ results += JSON.stringify(xrpl.getBalanceChanges(tx.result.meta), null, 2)
+ results += JSON.stringify(nfts, null, 2)
+ resultField.value = results
+
+ client.disconnect()
+}// End of acceptSellOffer()
+
+// *******************************************************
+// ******************* Accept Buy Offer ******************
+// *******************************************************
+
+async function acceptBuyOffer() {
+ const wallet = xrpl.Wallet.fromSeed(accountSeedField.value)
+ let net = getNet()
+ const client = new xrpl.Client(net)
+ await client.connect()
+ let results = '\n=== Connected. Accepting buy offer. ==='
+ resultField.value = results
+
+ // Prepare transaction -------------------------------------------------------
+ const transactionJson = {
+ "TransactionType": "NFTokenAcceptOffer",
+ "Account": wallet.classicAddress,
+ "NFTokenBuyOffer": nftOfferIdField.value
+ }
+ // Submit transaction --------------------------------------------------------
+ const tx = await client.submitAndWait(transactionJson, { wallet: wallet })
+ const nfts = await client.request({
+ method: "account_nfts",
+ account: wallet.classicAddress
+ })
+ results += JSON.stringify(nfts, null, 2)
+ resultField.value = results
+
+ // Check transaction 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)
+ xrpBalanceField.value =
+ (await client.getXrpBalance(wallet.address))
+ resultField.value = results
+ client.disconnect()
+}// End of acceptBuyOffer()
diff --git a/docs/img/mt-mint-token-1-empty-form.png b/docs/img/mt-mint-token-1-empty-form.png
new file mode 100644
index 0000000000..fcbfd6374b
Binary files /dev/null and b/docs/img/mt-mint-token-1-empty-form.png differ
diff --git a/docs/img/mt-mint-token-2-accounts.png b/docs/img/mt-mint-token-2-accounts.png
new file mode 100644
index 0000000000..82277489e9
Binary files /dev/null and b/docs/img/mt-mint-token-2-accounts.png differ
diff --git a/docs/img/mt-mint-token-3-mint-token.png b/docs/img/mt-mint-token-3-mint-token.png
new file mode 100644
index 0000000000..ec1ad1849d
Binary files /dev/null and b/docs/img/mt-mint-token-3-mint-token.png differ
diff --git a/docs/img/mt-mint-token-4-get-tokens.png b/docs/img/mt-mint-token-4-get-tokens.png
new file mode 100644
index 0000000000..c687b691bf
Binary files /dev/null and b/docs/img/mt-mint-token-4-get-tokens.png differ
diff --git a/docs/img/mt-mint-token-5-burn-token.png b/docs/img/mt-mint-token-5-burn-token.png
new file mode 100644
index 0000000000..08139f4dcc
Binary files /dev/null and b/docs/img/mt-mint-token-5-burn-token.png differ
diff --git a/docs/img/mt-transfer-nft-1-empty-form.png b/docs/img/mt-transfer-nft-1-empty-form.png
new file mode 100644
index 0000000000..81fee658a4
Binary files /dev/null and b/docs/img/mt-transfer-nft-1-empty-form.png differ
diff --git a/docs/img/mt-transfer-nft-2-accounts-loaded.png b/docs/img/mt-transfer-nft-2-accounts-loaded.png
new file mode 100644
index 0000000000..73a7bbe120
Binary files /dev/null and b/docs/img/mt-transfer-nft-2-accounts-loaded.png differ
diff --git a/docs/img/mt-transfer-nfts-3-create-sell-offer.png b/docs/img/mt-transfer-nfts-3-create-sell-offer.png
new file mode 100644
index 0000000000..211c7c431a
Binary files /dev/null and b/docs/img/mt-transfer-nfts-3-create-sell-offer.png differ
diff --git a/docs/img/mt-transfer-nfts-4-get-offers.png b/docs/img/mt-transfer-nfts-4-get-offers.png
new file mode 100644
index 0000000000..6481ed0c2a
Binary files /dev/null and b/docs/img/mt-transfer-nfts-4-get-offers.png differ
diff --git a/docs/img/mt-transfer-nfts-5-accept-sell-offer.png b/docs/img/mt-transfer-nfts-5-accept-sell-offer.png
new file mode 100644
index 0000000000..ee507db92b
Binary files /dev/null and b/docs/img/mt-transfer-nfts-5-accept-sell-offer.png differ
diff --git a/docs/tutorials/javascript/nfts/mint-and-burn-nfts.md b/docs/tutorials/javascript/nfts/mint-and-burn-nfts.md
index 3272bacd09..7a3d9baf08 100644
--- a/docs/tutorials/javascript/nfts/mint-and-burn-nfts.md
+++ b/docs/tutorials/javascript/nfts/mint-and-burn-nfts.md
@@ -1,10 +1,7 @@
---
-html: mint-and-burn-nfts-using-javascript.html
-parent: nfts-using-javascript.html
seo:
description: Mint and burn NFTs.
labels:
- - Quickstart
- Tokens
- Non-fungible tokens, NFTs
---
@@ -16,46 +13,47 @@ This example shows how to:
2. Get a list of existing NFTs.
3. Delete (Burn) an NFT.
-[](/docs/img/quickstart8.png)
+[](../../../img/mt-mint-token-1-empty-form.png)
# Usage
-You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/_code-samples/quickstart/js/) archive to try the sample in your own browser.
+You can download the [NFT Modular Tutorials](../../../../_code-samples/nft-modular-tutorials/nft-modular-tutorials.zip) archive to try the sample in your own browser.
## Get Accounts
-1. Open `3.mint-nfts.html` in a browser.
-2. Get test accounts.
- 1. If you have existing Testnet account seeds:
- 1. Paste the account seeds in the **Seeds** field.
- 2. Click **Get Accounts from Seeds**.
- 2. If you do not have existing Testnet accounts:
- 1. Click **Get New Standby Account**.
- 2. Click **Get New Operational Account**.
+1. Open `mint-nfts.html` in a browser.
+2. Choose your preferred test network (**Devnet** or **Testnet**).
+3. Get test accounts.
+ 1. If you copied the gathered information from another tutorial:
+ 1. Paste the gathered information to the **Result** field.
+ 2. Click **Distribute Account Info**.
+ 2. If you have an existing account seed:
+ 1. Paste the account seed to the **Account 1 Seed** or **Account 2 Seed** field.
+ 2. Click **Get Account 1 from Seed** or **Get Account 2 from Seed**.
+ 2. If you do not have existing accounts:
+ 1. Click **Get New Account 1**.
+ 2. Click **Get New Account 2**.
-[](/docs/img/quickstart9.png)
+[](../../../img/mt-mint-token-2-accounts.png)
## Mint an NFT
-
-
-
-
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 NFT object can be transferred to another account. Otherwise, the NFT object can only be transferred back to the issuing account.
-2. Enter the **Token URL**. This is a URI that points to the data or metadata associated with the NFT object. You can use the sample URI provided if you do not have one of your own.
+2. Enter the **NFT URL**. This is a URI that points to the data or metadata associated with the NFT 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 NFT 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 NFT to be transferrable, set this field to 0. If you impose a transfer fee, your NFT can only be traded for tokens for which your account has a trust line. See [Trust Lines](../../../concepts/tokens/fungible-tokens/index.md#trust-lines).
-4. Click **Mint NFT**.
+4. Optionally enter an **NFT Taxon**. This is a required value, but if you are not using the field to create an integer-based taxon entry, you can set the value to 0.
+5. Click **Mint NFT**.
-[](/docs/img/quickstart10.png)
+[](../../../img/mt-mint-token-3-mint-token.png)
## Get Tokens
Click **Get NFTs** to get a list of NFTs owned by the account.
-[](/docs/img/quickstart11.png)
+[](../../../img/mt-mint-token-4-get-tokens.png)
## Burn a Token
@@ -63,649 +61,549 @@ The current owner of an NFT can always destroy (or _burn_) an NFT object.
To permanently destroy an NFT:
-1. Enter the **Token ID**.
+1. Enter or select the account that owns the NFT.
+2. Enter the **NFT ID**.
2. Click **Burn NFT**.
-[](/docs/img/quickstart12.png)
+[](../../../img/mt-mint-token-5-burn-token.png)
# Code Walkthrough
-You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/_code-samples/quickstart/js/) archive to examine the code samples.
+You can download the [NFT Modular Tutorials](../../../../_code-samples/nft-modular-tutorials/nft-modular-tutorials.zip) archive to examine the code samples.
-## ripplex3-mint-nfts.js
+## mint-nfts.js
-### Mint Token
+### Mint NFT
+Get the account wallet and connect to the XRP Ledger.
```javascript
-// *******************************************************
-// ********************** Mint Token *********************
-// *******************************************************
-
-async function mintToken() {
+async function mintNFT() {
+ const wallet = xrpl.Wallet.fromSeed(accountSeedField.value);
+ const net = getNet();
+ const client = new xrpl.Client(net);
+ let results = `\n=== Connected. Minting NFT ===`;
+ resultField.value = results;
+
+ try {
+ await client.connect();
```
-Connect to the ledger and get the account wallets.
+Prepare the transaction parameters.
```javascript
- results = 'Connecting to ' + getNet() + '....'
- 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 NFT.'
- standbyResultField.value = results
+ const transactionParams = {
+ TransactionType: "NFTokenMint",
+ Account: wallet.classicAddress,
+ URI: xrpl.convertStringToHex(nftURLfield.value),
+ Flags: parseInt(flagsField.value, 10), // Parse to integer
+ TransferFee: parseInt(transferFeeField.value, 10), // Parse to integer
+ NFTokenTaxon: parseInt(nftTaxonField.value, 10), // Parse to integer
+ };
```
-Define the transaction.
+Add optional fields.
```javascript
+ // Add optional fields
+ if (amountField.value) {
+ transactionParams.Amount = configureAmount(amountField.value);
+ }
- const transactionJson = {
- "TransactionType": "NFTokenMint",
- "Account": standby_wallet.classicAddress,
+ if (expirationField.value) {
+ transactionParams.Expiration = configureExpiration(expirationField.value);
+ }
+
+ if (destinationField.value) {
+ transactionParams.Destination = destinationField.value;
+ }
```
-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.
+Log the transaction parameters before submission.
```javascript
- "URI": xrpl.convertStringToHex(standbyTokenUrlField.value),
+ console.log("Mint NFT Transaction Parameters:", transactionParams);
```
-If you want the NFT to be transferable to third parties, set the **Flags** field to _8_.
-
+Submit the transaction.
```javascript
- "Flags": parseInt(standbyFlagsField.value),
+
+ const tx = await client.submitAndWait(transactionParams, { wallet });
```
-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.
+Get the current list of NFTs owned by the account.
```javascript
- "TransferFee": parseInt(standbyTransferFeeField.value),
+ const nfts = await client.request({
+ method: "account_nfts",
+ account: wallet.classicAddress,
+ });
```
-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_.
-
+Report the results of the transaction.
```javascript
- "NFTokenTaxon": 0 //Required, but if you have no use for it, set to zero.
+ results = `\n\n=== Transaction result: ${tx.result.meta.TransactionResult} ===`;
+ results += `\n\n=== NFTs: ${JSON.stringify(nfts, null, 2)} ===`;
+ results += `\n\n=== XRP Balance: ${await client.getXrpBalance(wallet.address)} ===`; // Await here
+ resultField.value = results;
+```
+
+Catch and report any errors.
+
+```javascript
+ } catch (error) {
+ console.error("Error minting NFT:", error);
+ results += `\n\n=== Error minting NFT: ${error.message} ===`; // Use error.message
+ resultField.value = results;
+```
+
+Disconnect from the XRP Ledger.
+
+```javascript
+ } finally {
+ if (client && client.isConnected()) { // Check if connected before disconnecting
+ await client.disconnect();
+ }
}
+} // End of mintToken()
```
+### Get NFTs
-Send the transaction and wait for the response.
+Get the wallet and connect to the XRP Ledger.
```javascript
- const tx = await client.submitAndWait(transactionJson, { wallet: standby_wallet} )
+async function getNFTs() {
+ const wallet = xrpl.Wallet.fromSeed(accountSeedField.value);
+ const net = getNet();
+ const client = new xrpl.Client(net);
+ let results = '\n=== Connected. Getting NFTs. ===';
+ resultField.value = results;
+ try {
+ await client.connect();
```
-Request a list of NFTs owned by the account.
+Prepare and send the `account_nfts` request.
```javascript
- const nfts = await client.request({
- method: "account_nfts",
- account: standby_wallet.classicAddress
- })
+
+ const nfts = await client.request({
+ method: "account_nfts",
+ account: wallet.classicAddress,
+ });
```
Report the results.
```javascript
- results += '\n\nTransaction result: '+ tx.result.meta.TransactionResult
- results += '\n\nnfts: ' + JSON.stringify(nfts, null, 2)
- standbyBalanceField.value = (await client.getXrpBalance(standby_wallet.address))
- standbyResultField.value = results
+ results = '\n=== NFTs:\n ' + JSON.stringify(nfts, null, 2) + ' ===';
+ resultField.value = results;
```
-Disconnect from the ledger.
+Catch and report any errors.
```javascript
- client.disconnect()
-} //End of mintToken()
+ } catch (error) {
+ console.error("Error getting NFTs:", error);
+ results += `\n\n=== Error getting NFTs: ${error.message} ===`;
+ resultField.value = results;
```
-
-### Get Tokens
+Disconnect from the XRP Ledger.
```javascript
-// *******************************************************
-// ******************* Get Tokens ************************
-// *******************************************************
-
-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 + '...'
- standbyResultField.value = results
- await client.connect()
- results += '\nConnected. Getting NFTs...'
- standbyResultField.value = results
-```
-
-Request a list of NFTs owned by the account.
-
-```javascript
- const nfts = await client.request({
- method: "account_nfts",
- 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 NFT...'
- standbyResultField.value = results
-```
-
-Define the transaction.
-
-```javascript
- const transactionBlob = {
- "TransactionType": "NFTokenBurn",
- "Account": standby_wallet.classicAddress,
- "NFTokenID": standbyTokenIdField.value
+ } finally {
+ if (client && client.isConnected()) {
+ await client.disconnect();
+ }
}
+} // End of getNFTs()
+```
+
+### Burn NFT
+
+Get the account wallet and connect to the XRP Ledger.
+
+```javascript
+sync function burnNFT() {
+ const wallet = xrpl.Wallet.fromSeed(accountSeedField.value);
+ const net = getNet();
+ const client = new xrpl.Client(net);
+ let results = '\n=== Connected. Burning NFT. ===';
+ resultField.value = results;
+ try {
+ await client.connect();
+```
+
+Prepare the `NFTokenBurn` transaction.
+
+```javascript
+ const transactionBlob = {
+ TransactionType: "NFTokenBurn",
+ Account: wallet.classicAddress,
+ NFTokenID: nftIdField.value,
+ };
+
+ console.log("Burn NFT Transaction Parameters:", transactionBlob); // Log before submit
```
Submit the transaction and wait for the results.
```javascript
- const tx = await client.submitAndWait(transactionBlob,{wallet: standby_wallet})
+ const tx = await client.submitAndWait(transactionBlob, { wallet });
+ const nfts = await client.request({ // Get nfts after burning.
+ method: "account_nfts",
+ account: wallet.classicAddress,
+ });
```
-Request a list of NFTs owned by the client.
-
-```javascript
- const nfts = await client.request({
- method: "account_nfts",
- account: standby_wallet.classicAddress
- })
-```
-
-
Report the results.
-
```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 burnToken()
+ results = `\n=== Transaction result: ${tx.result.meta.TransactionResult} ===`;
+ results += '\n\n=== Balance changes: ' +
+ JSON.stringify(xrpl.getBalanceChanges(tx.result.meta), null, 2) + ' ===';
+ results += '\n\n=== NFTs: \n' + JSON.stringify(nfts, null, 2) + ' ===';
+ resultField.value = results;
+ xrpBalanceField.value = (await client.getXrpBalance(wallet.address)); // Await
```
-### Reciprocal Transactions
-
-These transactions are the same as the Standby account transactions, but for the Operational account.
+Catch and report any errors.
```javascript
-// *******************************************************
-// ************** Operational Mint Token *****************
-// *******************************************************
-
-async function oPmintToken() {
- results = 'Connecting to ' + getNet() + '....'
- 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 NFT.'
- operationalResultField.value = results
+ } catch (error) {
+ console.error("Error burning NFT:", error);
+ results = `\n\n=== Error burning NFT: ${error.message} ===`; // User friendly
+ resultField.value = results;
+```
- // Note that you must convert the token URL to a hexadecimal
- // value for this transaction.
- // ------------------------------------------------------------------------
- const transactionBlob = {
- "TransactionType": 'NFTokenMint',
- "Account": operational_wallet.classicAddress,
- "URI": xrpl.convertStringToHex(operationalTokenUrlField.value),
- "Flags": parseInt(operationalFlagsField.value),
- "TransferFee": parseInt(operationalTransferFeeField.value),
- "NFTokenTaxon": 0 //Required, but if you have no use for it, set to zero.
- }
-
- // ----------------------------------------------------- Submit signed blob
- const tx = await client.submitAndWait(transactionBlob, { wallet: operational_wallet} )
- const nfts = await client.request({
- method: "account_nfts",
- account: operational_wallet.classicAddress
- })
-
- // ------------------------------------------------------- Report results
- results += '\n\nTransaction result: '+ tx.result.meta.TransactionResult
- results += '\n\nnfts: ' + JSON.stringify(nfts, null, 2)
- operationalBalanceField.value = (await client.getXrpBalance(operational_wallet.address))
- operationalResultField.value = results
- client.disconnect()
-} //End of oPmintToken
-
-// *******************************************************
-// ************** Operational Get Tokens *****************
-// *******************************************************
+Disconnect from the XRP Ledger.
-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 NFTs...'
- 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 ******************
-// *******************************************************
-
-async function oPburnToken() {
- 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. Burning NFT...'
- operationalResultField.value = results
-
- // ------------------------------------------------------- Prepare transaction
- const transactionBlob = {
- "TransactionType": "NFTokenBurn",
- "Account": operational_wallet.classicAddress,
- "NFTokenID": operationalTokenIdField.value
+```javascript
+ } finally {
+ if (client && client.isConnected()) {
+ await client.disconnect();
+ }
}
-
- //-------------------------------------------------------- Submit signed blob
- const tx = await client.submitAndWait(transactionBlob,{wallet: operational_wallet})
- const nfts = await client.request({
- method: "account_nfts",
- account: operational_wallet.classicAddress
- })
- results += '\nTransaction result: '+ tx.result.meta.TransactionResult
- results += '\nBalance changes: ' +
- JSON.stringify(xrpl.getBalanceChanges(tx.result.meta), null, 2)
- 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)
- operationalResultField.value = results
- client.disconnect()
}
-// End of oPburnToken()
```
-## 3.mint-nfts.html
+## mint-nfts.html
```html
-
- Token Test Harness
+
+ Mint NFTs
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Token Test Harness
+
+
+
+
+
+
+
+
Mint NFTs
-
+
+
```
diff --git a/docs/tutorials/javascript/nfts/transfer-nfts.md b/docs/tutorials/javascript/nfts/transfer-nfts.md
index 702803e18f..366bb4be79 100644
--- a/docs/tutorials/javascript/nfts/transfer-nfts.md
+++ b/docs/tutorials/javascript/nfts/transfer-nfts.md
@@ -1,10 +1,7 @@
---
-html: transfer-nfts-using-javascript.html
-parent: nfts-using-javascript.html
seo:
description: Use a JavaScript test harness to send XRP, trade currencies, and mint and trade NFTs.
labels:
- - Quickstart
- Tokens
- Non-fungible Tokens, NFTs
---
@@ -19,43 +16,52 @@ This example shows how to:
5. Get a list of offers for a particular NFT.
6. Cancel an offer.
-[](/docs/img/quickstart13.png)
+[](../../../img/mt-transfer-nft-1-empty-form.png)
-You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/_code-samples/quickstart/js/) archive to try each of the samples in your own browser.
+You can download the [NFT Modular Tutorials](../../../../_code-samples/nft-modular-tutorials/nft-modular-tutorials.zip) archive to try each of the samples in your own browser.
# Usage
## Get Accounts
-1. Open `4.transfer-nfts.html` in a browser.
-2. Choose your ledger instance (**Testnet** or **Devnet**).
+1. Open `transfer-nfts.html` in a browser.
+2. Choose your preferred test network (**Devnet** or **Testnet**).
3. Get test accounts.
- 1. If you have existing test account seeds
- 1. Paste account seeds in the **Seeds** field.
- 2. Click **Get Accounts from Seeds**.
- 2. If you do not have test account seeds:
- 1. Click **Get New Standby Account**.
- 2. Click **Get New Operational Account**.
+ 1. If you copied the gathered information from another tutorial:
+ 1. Paste the gathered information to the **Result** field.
+ 2. Click **Distribute Account Info**.
+ 2. If you have an existing account seed:
+ 1. Paste the account seed to the **Account 1 Seed** or **Account 2 Seed** field.
+ 2. Click **Get Account 1 from Seed** or **Get Account 2 from Seed**.
+ 2. If you do not have existing accounts:
+ 1. Click **Get New Account 1**.
+ 2. Click **Get New Account 2**.
-[](/docs/img/quickstart14.png)
+[](../../../img/mt-transfer-nft-2-accounts-loaded.png)
## Create a Sell Offer
-
-
-
+To create an NFT sell offer:
-To create a NFT sell offer:
-
-1. Enter the **Amount** of the sell offer in drops (millionths of an XRP).
-2. Set the **Flags** field to _1_.
-3. Enter the **NFT ID** of the NFT you want to sell.
-4. Optionally, enter a number of days until **Expiration**.
+1. Enter the **Amount** of the sell offer.
+ 1. If using _XRP_, enter the **Amount** in drops (millionths of an XRP; for example, 20000000).
+ 2. If using issued currency, enter the **Currency** code, **Issuer** account address, and the **Amount**.
+2. Optionally, include a **Destination** account address. If present, only that account will have permission to accept the sell offer.
+3. Optionally, enter a number of days until **Expiration** of the offer.
+4. Enter the **NFT ID** of the NFT you want to sell.
5. Click **Create Sell Offer**.
-The important piece of information in the response is the NFT Offer Index, labeled as `nft_offer_index`, which you use to accept the sell offer.
+[](../../../img/mt-transfer-nfts-3-create-sell-offer.png)
-[](/docs/img/quickstart15.png)
+## Get Offers
+
+To list the buy and sell offers associated with an NFT:
+1. Enter the **NFT ID**.
+2. Click **Get Offers**.
+
+The key piece of information is the NFT Offer ID (labeled as `nft_offer_index`), which you use to accept a sell or buy offer.
+
+[](../../../img/mt-transfer-nfts-4-get-offers.png)
## Accept Sell Offer
@@ -66,39 +72,33 @@ To accept an available sell offer:
1. Enter the **NFT Offer Index** (labeled as `nft_offer_index` in the token offer results. This is different from the `NFTokenID`.)
2. Click **Accept Sell Offer**.
-[](/docs/img/quickstart16.png)
+[](../../../img/mt-transfer-nfts-5-accept-sell-offer.png)
## Create a Buy Offer
-You can offer to buy a NFT from another account.
+You can offer to buy an NFT from another account.
-To create an offer to buy a NFT:
+To create an offer to buy an NFT:
1. Enter the **Amount** of your offer.
-2. Enter the **NFT ID**.
-3. Enter the owner’s account string in the **Owner** field.
-4. Optionally enter the number of days until **Expiration**.
+ 1. If paying XRP, enter the **Amount** of XRP in drops (1000000 equals 1 XRP).
+ 2. If paying an issued currency, enter the **Currency**, **Issuer**, and **Amount**.
+2. Optionally enter the number of days until **Expiration**.
+3. Enter the **NFT ID**.
+4. Enter the owner’s account address in the **NFT Owner Address** field.
5. Click **Create Buy Offer**.
[](/docs/img/quickstart17.png)
## Accept a Buy Offer
-To accept an offer to buy a NFT:
+To accept an offer to buy an NFT:
1. Enter the **NFT Offer Index** (the `nft_offer_index` of the NFT buy offer).
3. Click **Accept Buy Offer**.
[](/docs/img/quickstart18.png)
-## Get Offers
-
-To list the buy and sell offers associated with a NFT:
-1. Enter the **NFT ID**.
-2. Click **Get Offers**.
-
-[](/docs/img/quickstart19.png)
-
## Cancel Offer
To cancel a buy or sell offer that you have created:
diff --git a/docs/tutorials/javascript/send-payments/create-offers.md b/docs/tutorials/javascript/send-payments/create-offers.md
index 9c9073fd2f..e6c97beb82 100644
--- a/docs/tutorials/javascript/send-payments/create-offers.md
+++ b/docs/tutorials/javascript/send-payments/create-offers.md
@@ -28,7 +28,8 @@ Download and expand the [Modular Tutorials](../../../../_code-samples/modular-tu
To get test accounts:
1. Open `create-offers.html` in a browser.
-2. Get test accounts.
+2. Choose your preferred test network (**Devnet** or **Testnet**).
+3. Get test accounts.
1. If you copied the gathered information from another tutorial:
1. Paste the gathered information to the **Result** field.
2. Click **Distribute Account Info**.