add authorized minter

This commit is contained in:
Dennis Dawson
2025-05-23 17:06:30 -07:00
parent cc10aa0f94
commit 471c2e48df
8 changed files with 521 additions and 646 deletions

View File

@@ -270,6 +270,16 @@
<input type="text" id="authorizedMinterField" size="40"></input>
</td>
</tr>
<tr>
<td align="right">
<span class="tooltip" tooltip-data="Account that is the original issuer of the NFT.">
<label for="nftIssuerField">NFT Issuer</label>
</span>
</td>
<td>
<input type="text" id="nftIssuerField" size="40"></input>
</td>
</tr>
<tr>
<td colspan="2">
<p align="left">

View File

@@ -51,7 +51,6 @@ async function mintOther() {
results += '\nConnected. Minting NFT.'
resultField.value = results
// This version adds the "Issuer" field.
// ------------------------------------------------------------------------
const tx_json = {
"TransactionType": "NFTokenMint",
@@ -59,23 +58,30 @@ async function mintOther() {
"URI": xrpl.convertStringToHex(nftURLfield.value),
"Flags": parseInt(flagsField.value),
"TransferFee": parseInt(transferFeeField.value),
"Issuer": issuerField.value,
"NFTokenTaxon": 0 //Required, but if you have no use for it, set to zero.
"Issuer": nftIssuerField.value,
"NFTokenTaxon": nftTaxonField.value //Required, but if you have no use for it, set to zero.
}
if (amountField.value) {
tx_json.Amount = configureAmount(amountField.value);
}
if (expirationField.value) {
tx_json.Expiration = configureExpiration(expirationField.value);
}
if (destinationField.value) {
tx_json.Destination = destinationField.value;
}
// ----------------------------------------------------- Submit transaction
const tx = await client.submitAndWait(tx_json, { wallet: wallet })
const nfts = await client.request({
method: "account_nfts",
account: wallet.classicAddress
})
// ------------------------------------------------------- Report results
results += '\n\n=== Transaction result: ' + tx.result.meta.TransactionResult
results += '\n\n=== NFTs: ' + JSON.stringify(nfts, null, 2)
resultField.value = results + (await client.getXrpBalance(wallet.address))
// The line below seems redundant if the previous line already updates resultField.value
// resultField.value = results
} catch (error) {
results += '\n\nAn error occurred: ' + error.message
console.error(error) // Log the error for debugging

View File

@@ -278,7 +278,7 @@ async function acceptSellOffer() {
results += '\n=== Balance changes:'
results += JSON.stringify(xrpl.getBalanceChanges(tx.result.meta), null, 2)
results += JSON.stringify(nfts, null, 2)
resultField.value = results
resultField.value += results
} catch (error) {
console.error('Error accepting sell offer:', error)
resultField.value = `Error: ${error.message || error}`
@@ -292,35 +292,48 @@ async function acceptSellOffer() {
// *******************************************************
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
const wallet = xrpl.Wallet.fromSeed(accountSeedField.value);
let net = getNet();
const client = new xrpl.Client(net);
let results = '\n=== Connected. Accepting buy offer. ==='; // Declare results locally
// Prepare transaction -------------------------------------------------------
const transactionJson = {
"TransactionType": "NFTokenAcceptOffer",
"Account": wallet.classicAddress,
"NFTokenBuyOffer": nftOfferIdField.value
try {
await client.connect();
resultField.value = results; // Update UI after connection
// 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;
} catch (error) {
console.error('Error in acceptBuyOffer:', error); // Log the full error
results = `\n=== Error accepting buy offer: ${error.message || 'Unknown error'} ===`;
resultField.value = results;
} finally {
if (client && client.isConnected()) {
client.disconnect();
}
}
// 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()
} // End of acceptBuyOffer()

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 376 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 372 KiB

File diff suppressed because it is too large Load Diff

View File

@@ -44,7 +44,10 @@ To mint a non-fungible token object:
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. 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**.
5. Optionally, you can set an expected prices for the NFT. To set a price in XRP, enter the amount in drops in the **Amount** field. To use an issued currency, enter the **Currency**, **Issuer**, and **Amount**.
6. Optionally, you can enter a **Destination** address that will be the only account authorized to purchase the NFT.
7. Optionally, you can enter an **Expiration** value in days, after which the offer will no longer be available.
8. Click **Mint NFT**.
[![Mint NFT fields](../../../img/mt-mint-token-3-mint-token.png)](../../../img/mt-mint-token-3-mint-token.png)