Update to add transfer fee

This commit is contained in:
Dennis Dawson
2022-05-25 14:08:46 -07:00
committed by GitHub
parent fb90528b43
commit 62c815cb40

View File

@@ -5,7 +5,8 @@ blurb: Quickstart step 3, mint and burn NFTokens.
labels: labels:
- Quickstart - Quickstart
- Tokens - Tokens
- Non-fungible tokens, NFTs - Non-fungible tokens
- NFTs
--- ---
# 3. Mint and Burn NFTokens # 3. Mint and Burn NFTokens
@@ -34,20 +35,12 @@ You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-port
1. Open `3.mint-nfts.html` in a browser. 1. Open `3.mint-nfts.html` in a browser.
2. Get test accounts. 2. Get test accounts.
1. If you have existing NFT-Devnet account seeds 1. If you have existing NFT-Devnet account seeds:
1. Paste account seeds in the **Seeds** field. 1. Paste the account seeds in the **Seeds** field.
2. Click **Get Accounts from Seeds**. 2. Click **Get Accounts from Seeds**.
2. If you do not have NFT-Devnet account seeds: 2. If you do not have existing NFT-Devnet accounts:
1. Visit the [XRP Testnet Faucet](https://xrpl.org/xrp-testnet-faucet.html) page. 1. Click **Get New Standby Account**.
2. Click **Generate NFT-Devnet credentials**. 2. Click **Get New Operational Account**.
3. Copy the account **Secret**.
4. Paste the secret in a persistent location, such as a notepad, and press return.
5. Click **Generate NFT-Devnet credentials** to create a second account.
6. Copy the account **Secret**.
7. Paste the secret in the persistent location.
8. Copy both secrets, separated by a return.
9. Paste them in the **Account** **Seeds** field.
10. Click **Get Accounts from Seeds**.
@@ -63,7 +56,8 @@ 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. 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. 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. Click **Mint Token**. 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 1.
4. Click **Mint Token**.
@@ -126,13 +120,13 @@ Connect to the ledger and get the account wallets.
document.getElementById('standbyResultField').value = results document.getElementById('standbyResultField').value = results
let net = getNet() let net = getNet()
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value) const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
const client = new xrpl.Client(net) const client = new xrpl.Client(net)
await client.connect() await client.connect()
results += '\nConnected. Minting NFToken.' results += '\nConnected. Minting NFToken.'
document.getElementById('standbyResultField').value = results document.getElementById('standbyResultField').value = results
``` ```
@@ -141,8 +135,8 @@ Define the transaction.
``` ```
const transactionBlob = { const transactionBlob = {
TransactionType: "NFTokenMint", "TransactionType": "NFTokenMint",
Account: standby_wallet.classicAddress, "Account": standby_wallet.classicAddress,
``` ```
@@ -150,16 +144,27 @@ Note that the URI field expects a hexadecimal value rather than the literal URI
``` ```
URI: xrpl.convertStringToHex(standbyTokenUrlField.value), "URI": xrpl.convertStringToHex(standbyTokenUrlField.value),
Flags: parseInt(standbyFlagsField.value),
``` ```
If you want the NFToken to be transferable to third parties, set the **Flags** field to _8_.
```
"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.
```
"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_. 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_.
``` ```
TokenTaxon: 0 //Required, but if you have no use for it, set to zero. "NFTokenTaxon": 0 //Required, but if you have no use for it, set to zero.
} }
@@ -203,8 +208,6 @@ Disconnect from the ledger.
``` ```
client.disconnect() client.disconnect()
} //End of mintToken() } //End of mintToken()
``` ```
@@ -230,7 +233,7 @@ Connect to the ledger and get the account wallet.
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value) const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
let net = getNet() let net = getNet()
const client = new xrpl.Client(net) const client = new xrpl.Client(net)
results = 'Connecting to ' + getNet() + '...' results = 'Connecting to ' + net + '...'
document.getElementById('standbyResultField').value = results document.getElementById('standbyResultField').value = results
await client.connect() await client.connect()
results += '\nConnected. Getting NFTokens...' results += '\nConnected. Getting NFTokens...'
@@ -284,10 +287,9 @@ Connect to the ledger and get the account wallets.
``` ```
async function burnToken() { async function burnToken() {
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value) const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
let net = getNet() let net = getNet()
const client = new xrpl.Client(net) const client = new xrpl.Client(net)
results = 'Connecting to ' + getNet() + '...' results = 'Connecting to ' + net + '...'
document.getElementById('standbyResultField').value = results document.getElementById('standbyResultField').value = results
await client.connect() await client.connect()
results += '\nConnected. Burning NFToken...' results += '\nConnected. Burning NFToken...'
@@ -353,39 +355,35 @@ Report the results.
// ************** Operational Mint Token ***************** // ************** Operational Mint Token *****************
// ******************************************************* // *******************************************************
async function oPmintToken() { async function oPmintToken() {
results = 'Connecting to ' + getNet() + '....' results = 'Connecting to ' + getNet() + '....'
document.getElementById('operationalResultField').value = results document.getElementById('operationalResultField').value = results
let net = getNet() let net = getNet()
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value) const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
const client = new xrpl.Client(net) const client = new xrpl.Client(net)
await client.connect() await client.connect()
results += '\nConnected. Minting NFToken.' results += '\nConnected. Minting NFToken.'
document.getElementById('operationalResultField').value = results document.getElementById('operationalResultField').value = results
// Note that you must convert the token URL to a hexadecimal // Note that you must convert the token URL to a hexadecimal
// value for this transaction. // value for this transaction.
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
const transactionBlob = { const transactionBlob = {
TransactionType: "NFTokenMint", "TransactionType": 'NFTokenMint',
Account: operational_wallet.classicAddress, "Account": operational_wallet.classicAddress,
URI: xrpl.convertStringToHex(operationalTokenUrlField.value), "URI": xrpl.convertStringToHex(operationalTokenUrlField.value),
Flags: parseInt(operationalFlagsField.value), "Flags": parseInt(operationalFlagsField.value),
TokenTaxon: 0 //Required, but if you have no use for it, set to zero. "TransferFee": parseInt(operationalTransferFeeField.value),
"NFTokenTaxon": 0 //Required, but if you have no use for it, set to zero.
} }
// ----------------------------------------------------- Submit signed blob
// ------------------- Submit transaction and wait for results
const tx = await client.submitAndWait(transactionBlob, { wallet: operational_wallet} ) const tx = await client.submitAndWait(transactionBlob, { wallet: operational_wallet} )
const nfts = await client.request({ const nfts = await client.request({
method: "account_nfts", method: "account_nfts",
account: operational_wallet.classicAddress account: operational_wallet.classicAddress
}) })
// ------------------------------------------------------- Report results // ------------------------------------------------------- Report results
results += '\n\nTransaction result: '+ tx.result.meta.TransactionResult results += '\n\nTransaction result: '+ tx.result.meta.TransactionResult
results += '\n\nnfts: ' + JSON.stringify(nfts, null, 2) results += '\n\nnfts: ' + JSON.stringify(nfts, null, 2)
@@ -393,16 +391,13 @@ Report the results.
(await client.getXrpBalance(operational_wallet.address)) (await client.getXrpBalance(operational_wallet.address))
document.getElementById('operationalResultField').value = results document.getElementById('operationalResultField').value = results
client.disconnect() client.disconnect()
} //End of oPmintToken } //End of oPmintToken
// ******************************************************* // *******************************************************
// ************** Operational Get Tokens ***************** // ************** Operational Get Tokens *****************
// ******************************************************* // *******************************************************
async function oPgetTokens() { async function oPgetTokens() {
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value) const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
let net = getNet() let net = getNet()
@@ -421,14 +416,11 @@ Report the results.
client.disconnect() client.disconnect()
} //End of oPgetTokens } //End of oPgetTokens
// ******************************************************* // *******************************************************
// ************* Operational Burn Token ****************** // ************* Operational Burn Token ******************
// ******************************************************* // *******************************************************
async function oPburnToken() { async function oPburnToken() {
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value) const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
let net = getNet() let net = getNet()
const client = new xrpl.Client(net) const client = new xrpl.Client(net)
@@ -438,15 +430,13 @@ Report the results.
results += '\nConnected. Burning NFToken...' results += '\nConnected. Burning NFToken...'
document.getElementById('operationalResultField').value = results document.getElementById('operationalResultField').value = results
// ------------------------------------------------------- Prepare transaction // ------------------------------------------------------- Prepare transaction
const transactionBlob = { const transactionBlob = {
"TransactionType": "NFTokenBurn", "TransactionType": "NFTokenBurn",
"Account": operational_wallet.classicAddress, "Account": operational_wallet.classicAddress,
"TokenID": operationalTokenIdField.value "NFTokenID": operationalTokenIdField.value
} }
//-------------------------------------------------------- Submit signed blob //-------------------------------------------------------- Submit signed blob
const tx = await client.submitAndWait(transactionBlob,{wallet: operational_wallet}) const tx = await client.submitAndWait(transactionBlob,{wallet: operational_wallet})
const nfts = await client.request({ const nfts = await client.request({
@@ -457,6 +447,8 @@ Report the results.
results += '\nBalance changes: ' + results += '\nBalance changes: ' +
JSON.stringify(xrpl.getBalanceChanges(tx.result.meta), null, 2) JSON.stringify(xrpl.getBalanceChanges(tx.result.meta), null, 2)
document.getElementById('operationalResultField').value = results document.getElementById('operationalResultField').value = results
document.getElementById('operationalBalanceField').value =
(await client.getXrpBalance(operational_wallet.address))
document.getElementById('operationalBalanceField').value = document.getElementById('operationalBalanceField').value =
(await client.getXrpBalance(operational_wallet.address)) (await client.getXrpBalance(operational_wallet.address))
results += '\nNFTs: \n' + JSON.stringify(nfts,null,2) results += '\nNFTs: \n' + JSON.stringify(nfts,null,2)
@@ -464,10 +456,6 @@ Report the results.
client.disconnect() client.disconnect()
} }
// End of oPburnToken() // End of oPburnToken()
</script>
</head>
``` ```
@@ -481,7 +469,7 @@ Bold text in the following indicates changes to the form that support the new fu
<html> <html>
<head> <head>
<title>Token Test Harness</title> <title>Token Test Harness</title>
<script src='https://unpkg.com/xrpl@2.1.1'></script> <script src='https://unpkg.com/xrpl@2.2.3'></script>
<script src='ripplex1-send-xrp.js'></script> <script src='ripplex1-send-xrp.js'></script>
<script src='ripplex2-send-currency.js'></script> <script src='ripplex2-send-currency.js'></script>
<script src='ripplex3-mint-nfts.js'></script> <script src='ripplex3-mint-nfts.js'></script>
@@ -492,7 +480,6 @@ Bold text in the following indicates changes to the form that support the new fu
</script> </script>
</head> </head>
<!-- ************************************************************** --> <!-- ************************************************************** -->
<!-- ********************** The Form ****************************** --> <!-- ********************** The Form ****************************** -->
<!-- ************************************************************** --> <!-- ************************************************************** -->
@@ -580,6 +567,15 @@ Bold text in the following indicates changes to the form that support the new fu
<br> <br>
</td> </td>
</tr> </tr>
<tr>
<td align="right">
Destination
</td>
<td>
<input type="text" id="standbyDestinationField" size="40"></input>
<br>
</td>
</tr>
<tr valign="top"> <tr valign="top">
<td><button type="button" onClick="configureAccount('standby',document.querySelector('#standbyDefault').checked)">Configure Account</button></td> <td><button type="button" onClick="configureAccount('standby',document.querySelector('#standbyDefault').checked)">Configure Account</button></td>
<td> <td>
@@ -596,7 +592,7 @@ Bold text in the following indicates changes to the form that support the new fu
</td> </td>
</tr> </tr>
<tr> <tr>
<td align="right">Token URL</td> <td align="right">NFToken URL</td>
<td><input type="text" id="standbyTokenUrlField" <td><input type="text" id="standbyTokenUrlField"
value = "ipfs://bafybeigdyrzt5sfp7udm7hu76uh7y26nf4dfuylqabf3oclgtqy55fbzdi" size="80"/> value = "ipfs://bafybeigdyrzt5sfp7udm7hu76uh7y26nf4dfuylqabf3oclgtqy55fbzdi" size="80"/>
</td> </td>
@@ -606,9 +602,13 @@ Bold text in the following indicates changes to the form that support the new fu
<td><input type="text" id="standbyFlagsField" value="1" size="10"/></td> <td><input type="text" id="standbyFlagsField" value="1" size="10"/></td>
</tr> </tr>
<tr> <tr>
<td align="right">Token ID</td> <td align="right">NFToken ID</td>
<td><input type="text" id="standbyTokenIdField" value="" size="80"/></td> <td><input type="text" id="standbyTokenIdField" value="" size="80"/></td>
</tr> </tr>
<tr>
<td align="right">Transfer Fee</td>
<td><input type="text" id="standbyTransferFeeField" value="" size="80"/></td>
</tr>
</table> </table>
<p align="left"> <p align="left">
<textarea id="standbyResultField" cols="80" rows="20" ></textarea> <textarea id="standbyResultField" cols="80" rows="20" ></textarea>
@@ -719,11 +719,19 @@ Bold text in the following indicates changes to the form that support the new fu
<br> <br>
</td> </td>
</tr> </tr>
<tr>
<td align="right">
Destination
</td>
<td>
<input type="text" id="operationalDestinationField" size="40"></input>
<br>
</td>
</tr>
<tr> <tr>
<td> <td>
</td> </td>
<td align="right"> <td align="right"> <input type="checkbox" id="operationalDefault" checked="true"/>
<input type="checkbox" id="operationalDefault" checked="true"/>
<label for="operationalDefault">Allow Rippling</label> <label for="operationalDefault">Allow Rippling</label>
<button type="button" onClick="configureAccount('operational',document.querySelector('#operationalDefault').checked)">Configure Account</button> <button type="button" onClick="configureAccount('operational',document.querySelector('#operationalDefault').checked)">Configure Account</button>
</td> </td>
@@ -737,7 +745,7 @@ Bold text in the following indicates changes to the form that support the new fu
</td> </td>
</tr> </tr>
<tr> <tr>
<td align="right">Token URL</td> <td align="right">NFToken URL</td>
<td><input type="text" id="operationalTokenUrlField" <td><input type="text" id="operationalTokenUrlField"
value = "ipfs://bafybeigdyrzt5sfp7udm7hu76uh7y26nf4dfuylqabf3oclgtqy55fbzdi" size="80"/> value = "ipfs://bafybeigdyrzt5sfp7udm7hu76uh7y26nf4dfuylqabf3oclgtqy55fbzdi" size="80"/>
</td> </td>
@@ -747,8 +755,12 @@ Bold text in the following indicates changes to the form that support the new fu
<td><input type="text" id="operationalFlagsField" value="1" size="10"/></td> <td><input type="text" id="operationalFlagsField" value="1" size="10"/></td>
</tr> </tr>
<tr> <tr>
<td align="right">Token ID</td> <td align="right">NFToken ID</td>
<td><input type="text" id="operationalTokenIdField" value="" size="80"/></td> <td><input type="text" id="operationalTokenIdField" value="" size="80"/></td>
</tr>
<tr>
<td align="right">Transfer Fee</td>
<td><input type="text" id="operationalTransferFeeField" value="" size="80"/></td>
</tr> </tr>
</table> </table>
<p align="right"> <p align="right">