diff --git a/content/_code-samples/quickstart/js/quickstart.zip b/content/_code-samples/quickstart/js/quickstart.zip index 79cc27ac3f..f6c0a5311e 100644 Binary files a/content/_code-samples/quickstart/js/quickstart.zip and b/content/_code-samples/quickstart/js/quickstart.zip differ diff --git a/content/tutorials/quickstart/authorize-minter.md b/content/tutorials/quickstart/authorize-minter.md new file mode 100644 index 0000000000..2653ad9432 --- /dev/null +++ b/content/tutorials/quickstart/authorize-minter.md @@ -0,0 +1,762 @@ +--- +html: authorize-minter.html +parent: xrpl-quickstart.html +blurb: Authorize another account to mint tokens on your behalf. +labels: + - Accounts + - Quickstart + - NFTokens + - XRP +--- + +# Assign an Authorized Minter + +You can assign another account permission to mint NFTokens for you. + +This example shows how to: + +1. Authorize an account to create NFTokens for your account. +2. Mint a NFToken for another account, when authorized. + +[![Token Test Harness](img/quickstart28.png)](img/quickstart28.png) + +# Usage + +You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/quickstart/js/quickstart.zip) archive to try the sample in your own browser. + +## Get Accounts + +1. Open `6.authorized-minter.html` in a browser. +2. Get test accounts. + 1. If you have existing NFT-Devnet account seeds: + 1. Paste the account seeds in the **Seeds** field. + 2. Click **Get Accounts from Seeds**. + 2. If you do not have existing NFT-Devnet accounts: + 1. Click **Get New Standby Account**. + 2. Click **Get New Operational Account**. + +## Authorize an Account to Create NFTokens + +To authorize another account to create NFTokens for your account: + +1. Copy the **Operational Account** value. +2. Paste the **Operational Account** value in the **Authorized Minter** field. +3. Click **Set Minter**. + +[![Authorized Minter](img/quickstart29.png)](img/quickstart29.png) + +## Mint a NFToken for Another Account + +This example uses the Operational account, which was authorized in the previous step, to mint a token on behalf of the Standby account. + +To mint a non-fungible token for another account: + +1. Set the **Flags** field. For testing purposes, we recommend setting the value to _8_. +2. Enter the **NFToken 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. Copy the **Standby Account** value. +5. Paste the **Standby Account** value in the Operational account **Issuer** field. +6. Click the Operational account **Mint Other** button. +[![Minted NFToken for Another Account](img/quickstart30.png)](img/quickstart30.png) + +Once the item is minted, the authorized minter can sell the NFToken normally. The proceeds go to the authorized minter, less the transfer fee. The minter and the issuer can settle up on a division of the purchase price separately. + +## Create a Sell Offer + +To create a NFToken sell offer: + +1. On the Operational account side, enter the **Amount** of the sell offer in drops (millionths of an XRP), for example 100000000 (100 XRP +2. Set the **Flags** field to _1_. +3. Enter the **NFToken ID** of the minted NFToken you want to sell. +4. Optionally, enter a number of days until **Expiration**. +5. Click **Create Sell Offer**. + +The important piece of information in the response is the Token Offer Index, labeled as _nft_offer_index,_ which is used to accept the sell offer. + +[![NFToken Sell Offer](img/quickstart31.png)](img/quickstart31.png) + +## Accept Sell Offer + +Once a sell offer is available, you can create a new account to accept the offer and purchase the NFToken. + +To accept an available sell offer: + +1. Click **Get New Standby Account**. +1. Enter the **NFToken Offer Index** (labeled as _nft_offer_index_ in the token offer results. This is not the same as the _nft_id_). +2. Click **Accept Sell Offer**. + +When you examine the results field, you'll find that the Issuer account is credited 25 XRP. The Buyer account is debited the 100 XRP purchase price plus 12 drops as the transaction fee. The Seller (Authorized Minter) account is credited 75 XRP. the Issuer and the Seller can divide the proceeds per their agreement in a separate transaction. +[![Transaction Results](img/quickstart32.png)](img/quickstart32.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) archive to try each of the samples in your own browser. + +## Set Minter + +This function sets the authorized minter for an account. Each account can have 0 or 1 authorized minter that can mint NFTokens in its stead. + +```javascript +// ******************************************************* +// **************** Set Minter ************************* +// ******************************************************* + +async function setMinter(type) { +``` + +Connect to the ledger and get the account wallet. + +```javascript + 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 + my_wallet = xrpl.Wallet.fromSeed(standbySeedField.value) + document.getElementById('standbyResultField').value = results +``` + +Define the AccountSet transaction, setting the `NFTokenMinter` account and the `asfAuthorizedNFTokenMinter` flag. + +```javascript + tx_json = { + "TransactionType": "AccountSet", + "Account": my_wallet.address, +``` + +Set `NFTokenMinter` to the account number of the authorized minter. + +```javascript + "NFTokenMinter": standbyMinterField.value, +``` + +Set the `asfAuthorizedNFTokenMinter` flag (the numeric value is _10_). + +```javascript + "SetFlag": xrpl.AccountSetAsfFlags.asfAuthorizedNFTokenMinter + } +``` + +Report progress. + +```javascript + results += '\n Set Minter.' + document.getElementById('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) +``` + +If the transaction succeeds, stringify the results and report. If not, report that the transaction failed. + +```javascript + if (result.result.meta.TransactionResult == "tesSUCCESS") { + results += '\nAccount setting succeeded.' + results += JSON.stringify(result,null,2) + document.getElementById('standbyResultField').value = results + } else { + throw 'Error sending transaction: ${result}' + results += '\nAccount setting failed.' + document.getElementById('standbyResultField').value = results + } +``` + +Disconnect from the XRP Ledger. + +```javascript + client.disconnect() +} // End of configureAccount() +``` + +## Mint Other + +This revised mint function allows one account to mint for another issuer. + +```javascript + +// ******************************************************* +// **************** Mint Other ************************* +// ******************************************************* + +async function mintOther() { +``` + +Connect to the ledger and get the account wallet. + +```javascript + results = 'Connecting to ' + getNet() + '....' + document.getElementById('standbyResultField').value = results + let net = getNet() + const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value) + const client = new xrpl.Client(net) + await client.connect() +``` +Report success + +```javascript + results += '\nConnected. Minting NFToken.' + document.getElementById('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 = { + "TransactionType": "NFTokenMint", + "Account": standby_wallet.classicAddress, +``` + +The URI is a link to a data file represented by the NFToken. + +```javascript + "URI": xrpl.convertStringToHex(standbyTokenUrlField.value), +``` + +At a minimum, we recommend that you set the `tfTransferable` flag (8) to enable accounts to sell and resell the NFToken for testing purposes. + +```javascript + "Flags": parseInt(standbyFlagsField.value), +``` + +Transfer fee is a value 0-50000 representing .001% of the purchase price for a resale to be returned to the original issuer. For example, _25000_ translates to 25% of the purchase price to be sent to the issuer on resale. +```javascript + "TransferFee": parseInt(standbyTransferFeeField.value), +``` + +The **Issuer** is the original creator of the object represented by the NFToken. + +```javascript + "Issuer": standbyIssuerField.value, +``` + +The NFTokenTaxon is an optional number field the issuer can use for their own purposes. The same taxon can be used for multiple tokens. Set it to 0 if you have no use for it. + +```javascript + "NFTokenTaxon": 0 //Required, but if you have no use for it, set to zero. + } +``` + +Submit the transaction and wait for the results. + +```javascript + const tx = await client.submitAndWait(transactionBlob, { wallet: standby_wallet} ) + const nfts = await client.request({ + method: "account_nfts", + 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('standbyResultField').value = results + +``` + +Disconnect from the XRP Ledger. + +```javascript + client.disconnect() +} //End of mintOther() +``` + +## Reciprocal Transactions + +These functions duplicate the functions of the standby account for the operational account. See the corresponding standby account function for walkthrough information. + +```javascript +// ******************************************************* +// *********** Operational Set Minter ******************* +// ******************************************************* + +async function oPsetMinter(type) { + let net = getNet() + const client = new xrpl.Client(net) + results = 'Connecting to ' + getNet() + '....' + document.getElementById('operationalResultField').value = results + await client.connect() + results += '\nConnected, finding wallet.' + document.getElementById('operationalResultField').value = results + my_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value) + document.getElementById('operationalResultField').value = results + + tx_json = { + "TransactionType": "AccountSet", + "Account": my_wallet.address, + "NFTokenMinter": operationalMinterField.value, + "SetFlag": xrpl.AccountSetAsfFlags.asfAuthorizedNFTokenMinter + } + results += '\n Set Minter.' + document.getElementById('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.' + results += JSON.stringify(result,null,2) + document.getElementById('operationalResultField').value = results + } else { + throw 'Error sending transaction: ${result}' + results += '\nAccount setting failed.' + document.getElementById('operationalResultField').value = results + } + + client.disconnect() +} // End of configureAccount() + +// ******************************************************* +// ************** Operational Mint Other ***************** +// ******************************************************* + +async function oPmintOther() { + results = 'Connecting to ' + getNet() + '....' + document.getElementById('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 + + // This version adds the "Issuer" field. + // ------------------------------------------------------------------------ + const transactionBlob = { + "TransactionType": 'NFTokenMint', + "Account": operational_wallet.classicAddress, + "URI": xrpl.convertStringToHex(operationalTokenUrlField.value), + "Flags": parseInt(operationalFlagsField.value), + "Issuer": operationalIssuerField.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) + document.getElementById('operationalBalanceField').value = + (await client.getXrpBalance(operational_wallet.address)) + document.getElementById('operationalResultField').value = results + + client.disconnect() +} //End of oPmintToken +``` + +## 6.authorized-minter.html + +Update the form with fields and buttons to support the new functions. + +```html + + + Token Test Harness + + + + + + + + + + + + + + + + +

Token Test Harness

+
+ Choose your ledger instance: + + +    + + +    + + +

+ +
+ +

+ + + + + +
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Standby Account + + +
+
+ Public Key + + +
+
+ Private Key + + +
+
+ Seed + + +
+
+ XRP Balance + + +
+
+ Amount + + +
+
+ + +
+ Currency + + +
NFToken URL +
Flags
NFToken ID
NFToken Offer Index
Owner
Authorized Minter
Issuer
Destination
Expiration
Transfer Fee
+

+ +

+
+ + + + + + +
+ +

+ +
+ +
+ +

+ +
+ +
+ +

+ +
+ +

+ +
+ +
+ +
+ +
+ +
+ +
+
+
+ + + + +
+ + + + + + + + + +
+ +

+ +
+ +
+ +

+ +
+ +
+ +

+ +
+ +

+ +
+ +
+ +
+ +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Operational Account + + +
+
+ Public Key + + +
+
+ Private Key + + +
+
+ Seed + + +
+
+ XRP Balance + + +
+
+ Amount + + +
+
+ + + +
+ Currency + + +
NFToken URL +
Flags
NFToken ID
NFToken Offer Index
Owner
Authorized Minter
Issuer
Destination
Expiration
Transfer Fee
+

+ +

+
+
+
+
+ + +``` + +| Previous | Next | +| :--- | ---: | +| [← Broker a NFToken Sale >](broker-sale.html) | | + diff --git a/content/tutorials/quickstart/broker-sale.md b/content/tutorials/quickstart/broker-sale.md index 77ef67c364..efb1d6081e 100644 --- a/content/tutorials/quickstart/broker-sale.md +++ b/content/tutorials/quickstart/broker-sale.md @@ -1043,11 +1043,10 @@ Revise the HTML form to add a new Broker section at the top. - + ``` ---- | Previous | Next | | :--- | ---: | -| [← 4. Transfer NFTokens >](transfer-nftokens.html) | | +| [← 4. Transfer NFTokens >](transfer-nftokens.html) | [Authorize Minter → >](authorize-minter.html)|| diff --git a/content/tutorials/quickstart/xrpl-quickstart.md b/content/tutorials/quickstart/xrpl-quickstart.md index 0b78cb8562..cb31dde6c6 100644 --- a/content/tutorials/quickstart/xrpl-quickstart.md +++ b/content/tutorials/quickstart/xrpl-quickstart.md @@ -41,7 +41,7 @@ In this quickstart, you can: 3. [Mint and Burn NFTokens](mint-and-burn-nftokens.html). 4. [Transfer NFTokens](transfer-nftokens.html). -There is also an expanded lesson demonstrating how to [Broker a NFToken Sale](broker-sale.html). +There are also expanded lessons demonstrating how to [Broker a NFToken Sale](broker-sale.html) and [Assign an Authorized Minter](authorize-minter.html). ## Prerequisites diff --git a/dactyl-config.yml b/dactyl-config.yml index 724d2f7502..12ba779552 100644 --- a/dactyl-config.yml +++ b/dactyl-config.yml @@ -1135,6 +1135,10 @@ pages: targets: - en - ja + - md: tutorials/quickstart/authorize-minter.md + targets: + - en + - ja - md: tutorials/get-started/get-started.md targets: diff --git a/img/quickstart28.png b/img/quickstart28.png new file mode 100644 index 0000000000..9e855c06ed Binary files /dev/null and b/img/quickstart28.png differ diff --git a/img/quickstart29.png b/img/quickstart29.png new file mode 100644 index 0000000000..5be484f996 Binary files /dev/null and b/img/quickstart29.png differ diff --git a/img/quickstart30.png b/img/quickstart30.png new file mode 100644 index 0000000000..8ca4aca11c Binary files /dev/null and b/img/quickstart30.png differ diff --git a/img/quickstart31.png b/img/quickstart31.png new file mode 100644 index 0000000000..a6725f1d6a Binary files /dev/null and b/img/quickstart31.png differ diff --git a/img/quickstart32.png b/img/quickstart32.png new file mode 100644 index 0000000000..93d39ed278 Binary files /dev/null and b/img/quickstart32.png differ