Merge pull request #2997 from XRPLF/add_mpt_uc_1
MPT use case with MPT generator, Send MPT Tutorial
150
_code-samples/mpt-generator/modular-tutorials.css
Normal file
@@ -0,0 +1,150 @@
|
||||
body {
|
||||
font-family: "Inter", sans-serif;
|
||||
padding: 20px;
|
||||
background: #abe2ff;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
td {
|
||||
padding-left: 25px;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
input,
|
||||
button {
|
||||
padding: 6px;
|
||||
margin-bottom: 8px;
|
||||
border: none
|
||||
}
|
||||
|
||||
input:read-only {
|
||||
background-color:rgb(11, 96, 132);
|
||||
color:white;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
button {
|
||||
font-weight: bold;
|
||||
font-family: "Work Sans", sans-serif;
|
||||
background-color: #006aff;
|
||||
-webkit-text-fill-color: white;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
background-color: #0555c5;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
td {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
/* The switch - the box around the slider */
|
||||
.switch {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
width: 30px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
/* Hide default HTML checkbox */
|
||||
.switch input {
|
||||
opacity: 0;
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
/* The slider */
|
||||
.slider {
|
||||
position: absolute;
|
||||
cursor: pointer;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: #ccc;
|
||||
-webkit-transition: .4s;
|
||||
transition: .4s;
|
||||
}
|
||||
|
||||
.slider:before {
|
||||
position: absolute;
|
||||
content: "";
|
||||
height: 13px;
|
||||
width: 13px;
|
||||
left: 4px;
|
||||
bottom: 2px;
|
||||
background-color: white;
|
||||
-webkit-transition: .4s;
|
||||
transition: .4s;
|
||||
}
|
||||
|
||||
input:checked+.slider {
|
||||
background-color: #2196F3;
|
||||
}
|
||||
|
||||
input:focus+.slider {
|
||||
box-shadow: 0 0 1px #2196F3;
|
||||
}
|
||||
|
||||
input:checked+.slider:before {
|
||||
-webkit-transform: translateX(13px);
|
||||
-ms-transform: translateX(13px);
|
||||
transform: translateX(13px);
|
||||
}
|
||||
|
||||
/* Rounded sliders */
|
||||
.slider.round {
|
||||
border-radius: 17px;
|
||||
}
|
||||
|
||||
.slider.round:before {
|
||||
border-radius: 50%;
|
||||
}
|
||||
.tooltip {
|
||||
position: relative;
|
||||
border-bottom: 1px dotted black;
|
||||
}
|
||||
|
||||
.tooltip:before {
|
||||
content: attr(tooltip-data);
|
||||
position: absolute;
|
||||
width: 250px;
|
||||
background-color: #006aff;
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
padding: 15px;
|
||||
line-height: 1.1;
|
||||
border-radius: 5px;
|
||||
z-index: 1;
|
||||
opacity: 0;
|
||||
transition: opacity .5s;
|
||||
bottom: 125%;
|
||||
left: 50%;
|
||||
margin-left: -60px;
|
||||
font-size: 0.70em;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.tooltip:after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
bottom: 75%;
|
||||
left: 50%;
|
||||
margin-left: -5px;
|
||||
border-width: 5px;
|
||||
border-style: solid;
|
||||
opacity: 0;
|
||||
transition: opacity .5s;
|
||||
border-color: #000 transparent transparent transparent;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.tooltip:hover:before,
|
||||
.tooltip:hover:after {
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
}
|
||||
232
_code-samples/mpt-generator/mpt-generator.htm
Normal file
@@ -0,0 +1,232 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>MPT Generator</title>
|
||||
<link href='https://fonts.googleapis.com/css?family=Work Sans' rel='stylesheet'>
|
||||
<link href="modular-tutorials.css" rel="stylesheet">
|
||||
<script src='https://unpkg.com/xrpl@4.1.0/build/xrpl-latest.js'></script>
|
||||
|
||||
<script src='mpt-generator.js'></script>
|
||||
<script>
|
||||
if (typeof module !== "undefined") {
|
||||
const xrpl = require("xrpl")
|
||||
}
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>MPT Generator</h1>
|
||||
<form>
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td colspan="3">
|
||||
<span class="tooltip" tooltip-data="Choose the XRPL host server for your account.">
|
||||
Choose your ledger instance:
|
||||
</span>
|
||||
|
||||
<input type="radio" id="dn" name="server"
|
||||
value="wss://s.devnet.rippletest.net:51233" checked>
|
||||
<label for="devnet">Devnet</label>
|
||||
|
||||
<input type="radio" id="tn" name="server"
|
||||
value="wss://s.altnet.rippletest.net:51233" >
|
||||
<label for="testnet">Testnet</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
<span class="tooltip" tooltip-data="Arbitrary human-readable name for the account.">
|
||||
<label for="accountNameField">Account Name</label>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="accountNameField" size="40"></input>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
<div class="container">
|
||||
<span class="tooltip" tooltip-data="The issuing account address.">Account
|
||||
</span>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
|
||||
<input type="text" id="accountField" size="40"></input>
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" onClick="getAccount()">Get New
|
||||
Account</button>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
<span class="tooltip" tooltip-data="The issuing account seed.">Seed
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
|
||||
<input type="text" id="seedField" size="40"></input>
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" onClick="getAccountFromSeed()">Get Account
|
||||
From Seed</button>
|
||||
</td>
|
||||
</tr>
|
||||
<table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="tooltip" tooltip-data="An asset scale is the difference, in orders of magnitude, between a standard unit and a corresponding fractional unit.">
|
||||
Asset Scale
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" size="10" id="assetScaleField" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="tooltip" tooltip-data="The maximum number of tokens to be issued.">
|
||||
Maximum Tokens
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" size="10" id="maximumAmountField" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="tooltip" tooltip-data="Fee collected when MPT is transferred.">
|
||||
Transfer Fee
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" size="5" id="transferFeeField" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="tooltip" tooltip-data="Issuer can claw back value from holders.">
|
||||
Clawback
|
||||
</span>
|
||||
</td>
|
||||
<td align="middle">
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="clawbackSlider">
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="tooltip" tooltip-data="MPT can be locked individually and globally.">
|
||||
Lock
|
||||
</span>
|
||||
</td>
|
||||
<td align="middle">
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="lockSlider" name="lockSlider">
|
||||
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="tooltip" tooltip-data="Individual holders must be authorized.">
|
||||
Require Authorization
|
||||
</span>
|
||||
</td>
|
||||
<td align="middle">
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="authTokensSlider">
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="tooltip" tooltip-data="MPTs can be transferred to other accounts.">
|
||||
Can Transfer
|
||||
</span>
|
||||
</td>
|
||||
<td align="middle">
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="txrSlider">
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="tooltip" tooltip-data="MPT can be traded.">
|
||||
Can Trade
|
||||
</span>
|
||||
</td>
|
||||
<td align="middle">
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="tradeSlider">
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="tooltip" tooltip-data="MPT can be used in an escrow.">
|
||||
Can Escrow
|
||||
</span>
|
||||
</td>
|
||||
<td align="middle">
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="escrowSlider">
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<b>Token Metadata</b>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
<textarea id="metadataTextArea" rows="25" cols="75"></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td>
|
||||
<h2>MPToken Create Transaction</h2>
|
||||
<p><button type="button" onclick="generateCode()">Generate Transaction</button>
|
||||
|
||||
<button type = "button" onclick="sendTransaction()">Send Transaction</button>
|
||||
|
||||
<button type = "button" onclick="gatherMptInfo()">Gather MPT Information</button>
|
||||
</p>
|
||||
<span class="tooltip" tooltip-data="The MPT Issuance ID of your generated MPT.">
|
||||
MPT Issuance ID
|
||||
</span>
|
||||
<p><input type="text" id="mptIssuanceIdField" size="50"></p>
|
||||
<textarea id="resultField" rows="25" cols="75"></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
111
_code-samples/mpt-generator/mpt-generator.js
Normal file
@@ -0,0 +1,111 @@
|
||||
function generateCode() {
|
||||
let v_flags = 0
|
||||
if (clawbackSlider.checked) {v_flags+=64}
|
||||
if (lockSlider.checked) {v_flags+=2}
|
||||
if (authTokensSlider.checked) {v_flags +=4}
|
||||
if (txrSlider.checked) {v_flags += 32}
|
||||
if (tradeSlider.checked) {v_flags += 16}
|
||||
if (escrowSlider.checked) {v_flags+=8}
|
||||
const mptHexString = xrpl.convertStringToHex(metadataTextArea.value)
|
||||
let v_codeBlock = "{\n \"TransactionType\": \"MPTokenIssuanceCreate\",\n \"Account\": \"" + accountField.value +
|
||||
"\",\n \"AssetScale\": " + parseInt(assetScaleField.value) + ", \n \"MaximumAmount\": \"" + maximumAmountField.value +
|
||||
"\",\n \"TransferFee\": " + transferFeeField.value +
|
||||
",\n \"Flags\": " + v_flags + ",\n \"MPTokenMetadata\": \"" + mptHexString + "\"\n}"
|
||||
resultField.value = v_codeBlock
|
||||
} //End of generateCode()
|
||||
// ******************************************************
|
||||
// ************* Get the Preferred Network **************
|
||||
// ******************************************************
|
||||
function 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()
|
||||
|
||||
// *******************************************************
|
||||
// ************* Get Account *****************************
|
||||
// *******************************************************
|
||||
|
||||
async function getAccount() {
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
accountField.value = "Getting new account...."
|
||||
let faucetHost = null
|
||||
await client.connect()
|
||||
let results = '\nConnected, funding wallet.'
|
||||
resultField.value = results
|
||||
// ----------------------------------------Create and fund a test account wallet.
|
||||
const my_wallet = (await client.fundWallet(null, { faucetHost })).wallet
|
||||
results += '\nGot a wallet.'
|
||||
// ------------------------------------------------------Get the current balance.
|
||||
const my_balance = (await client.getXrpBalance(my_wallet.address))
|
||||
accountField.value = my_wallet.address
|
||||
seedField.value = my_wallet.seed
|
||||
results += '\nAccount created.'
|
||||
resultField.value = results
|
||||
client.disconnect()
|
||||
} // End of getAccount()
|
||||
|
||||
// *******************************************************
|
||||
// ************ Get Account from Seed ********************
|
||||
// *******************************************************
|
||||
|
||||
async function getAccountFromSeed() {
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
results = 'Connecting to ' + getNet() + '....'
|
||||
await client.connect()
|
||||
results += '\nConnected, finding wallets.\n'
|
||||
resultField.value = results
|
||||
// --------------------------------------------------Find the account wallet.
|
||||
const my_wallet = xrpl.Wallet.fromSeed(seedField.value)
|
||||
accountField.value = my_wallet.address
|
||||
seedField.value = my_wallet.seed
|
||||
client.disconnect()
|
||||
} // End of getAccountFromSeed()
|
||||
|
||||
// *******************************************************
|
||||
// *************** Send Transaction **********************
|
||||
// *******************************************************
|
||||
|
||||
async function sendTransaction() {
|
||||
let v_flags = 0
|
||||
if (clawbackSlider.checked) {v_flags+=64}
|
||||
if (lockSlider.checked) {v_flags+=2}
|
||||
if (authTokensSlider.checked) {v_flags +=4}
|
||||
if (txrSlider.checked) {v_flags += 32}
|
||||
if (tradeSlider.checked) {v_flags += 16}
|
||||
if (escrowSlider.checked) {v_flags+=8}
|
||||
results = 'Connecting to ' + getNet() + '....'
|
||||
mptIssuanceIdField.value = results
|
||||
let net = getNet()
|
||||
const my_wallet = xrpl.Wallet.fromSeed(seedField.value)
|
||||
const client = new xrpl.Client(net)
|
||||
await client.connect()
|
||||
const metadataHexString = xrpl.convertStringToHex(metadataTextArea.value)
|
||||
const transactionJson = {
|
||||
"TransactionType": "MPTokenIssuanceCreate",
|
||||
"Account": accountField.value,
|
||||
"AssetScale": parseInt(assetScaleField.value),
|
||||
"MaximumAmount": maximumAmountField.value,
|
||||
"TransferFee": parseInt(transferFeeField.value),
|
||||
"Flags": v_flags,
|
||||
"MPTokenMetadata": metadataHexString
|
||||
}
|
||||
const tx = await client.submitAndWait(transactionJson, { wallet: my_wallet} )
|
||||
if (document.getElementById("tn").checked) {
|
||||
resultField.value += "\n Success! Ledger Index: " + tx.result.ledger_index + "\nSee https://testnet.xrpl.org/ledgers/" + tx.result.ledger_index
|
||||
} else {
|
||||
resultField.value += "\n Success! Ledger Index: " + tx.result.ledger_index + "\nSee https://devnet.xrpl.org/ledgers/" + tx.result.ledger_index
|
||||
}
|
||||
mptIssuanceIdField.value = JSON.stringify(tx.result.meta.mpt_issuance_id)
|
||||
}
|
||||
// *****************************************************
|
||||
// ************ Gather MPT Info ********************
|
||||
// *****************************************************
|
||||
|
||||
function gatherMptInfo() {
|
||||
let mptInfo = accountNameField.value + "\n" + accountField.value + "\n" + seedField.value + "\n" + mptIssuanceIdField.value
|
||||
resultField.value = mptInfo
|
||||
}
|
||||
BIN
_code-samples/mpt-generator/mpt-generator.zip
Normal file
101
_code-samples/mpt-sender/account-support.js
Normal file
@@ -0,0 +1,101 @@
|
||||
// ******************************************************
|
||||
// ************* Get the Preferred Network **************
|
||||
// ******************************************************
|
||||
|
||||
function 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()
|
||||
|
||||
// *******************************************************
|
||||
// ************* Get Account *****************************
|
||||
// *******************************************************
|
||||
|
||||
async function getAccount() {
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
await client.connect()
|
||||
let faucetHost = null
|
||||
const my_wallet = (await client.fundWallet(null, { faucetHost})).wallet
|
||||
const newAccount = [my_wallet.address, my_wallet.seed]
|
||||
return (newAccount)
|
||||
client.disconnect()
|
||||
} // End of getAccount()
|
||||
|
||||
async function getNewAccount1() {
|
||||
account1address.value = "Getting new account."
|
||||
const accountInfo= await getAccount()
|
||||
account1address.value = accountInfo[0]
|
||||
account1seed.value = accountInfo[1]
|
||||
}
|
||||
|
||||
async function getNewAccount2() {
|
||||
account2address.value = "Getting new account."
|
||||
const accountInfo= await getAccount()
|
||||
account2address.value = accountInfo[0]
|
||||
account2seed.value = accountInfo[1]
|
||||
}
|
||||
|
||||
// *****************************************************
|
||||
// ********** Get Account from Seed ********************
|
||||
// *****************************************************
|
||||
|
||||
async function getAccountFromSeed(my_seed) {
|
||||
const net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
await client.connect()
|
||||
let results = '\nConnected, finding wallet.\n'
|
||||
resultField.value = results
|
||||
const wallet = xrpl.Wallet.fromSeed(my_seed)
|
||||
// ----------------------Populate the fields for left and right accounts.
|
||||
const address = wallet.address
|
||||
client.disconnect()
|
||||
return (address)
|
||||
} // End of getAccountFromSeed()
|
||||
|
||||
async function getAccountFromSeed1() {
|
||||
account1address.value = await getAccountFromSeed(account1seed.value)
|
||||
}
|
||||
|
||||
async function getAccountFromSeed2() {
|
||||
account2address.value = await getAccountFromSeed(account2seed.value)
|
||||
}
|
||||
|
||||
function gatherAccountInfo() {
|
||||
let accountData = account1name.value + "\n" + account1address.value + "\n" + account1seed.value + "\n"
|
||||
accountData += account2name.value + "\n" + account2address.value + "\n" + account2seed.value
|
||||
resultField.value = accountData
|
||||
}
|
||||
|
||||
function distributeAccountInfo() {
|
||||
let accountInfo = resultField.value.split("\n")
|
||||
account1name.value = accountInfo[0]
|
||||
account1address.value = accountInfo[1]
|
||||
account1seed.value = accountInfo[2]
|
||||
account2name.value = accountInfo[3]
|
||||
account2address.value = accountInfo[4]
|
||||
account2seed.value = accountInfo[5]
|
||||
}
|
||||
|
||||
async function getBalance() {
|
||||
const net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
await client.connect()
|
||||
xrpBalanceField.value = await client.getXrpBalance(accountAddressField.value)
|
||||
}
|
||||
|
||||
function populate1() {
|
||||
accountNameField.value = account1name.value
|
||||
accountAddressField.value = account1address.value
|
||||
accountSeedField.value = account1seed.value
|
||||
getBalance()
|
||||
}
|
||||
|
||||
function populate2() {
|
||||
accountNameField.value = account2name.value
|
||||
accountAddressField.value = account2address.value
|
||||
accountSeedField.value = account2seed.value
|
||||
getBalance()
|
||||
}
|
||||
150
_code-samples/mpt-sender/modular-tutorials.css
Normal file
@@ -0,0 +1,150 @@
|
||||
body {
|
||||
font-family: "Inter", sans-serif;
|
||||
padding: 20px;
|
||||
background: #abe2ff;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
td {
|
||||
padding-left: 25px;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
input,
|
||||
button {
|
||||
padding: 6px;
|
||||
margin-bottom: 8px;
|
||||
border: none
|
||||
}
|
||||
|
||||
input:read-only {
|
||||
background-color:rgb(11, 96, 132);
|
||||
color:white;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
button {
|
||||
font-weight: bold;
|
||||
font-family: "Work Sans", sans-serif;
|
||||
background-color: #006aff;
|
||||
-webkit-text-fill-color: white;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
background-color: #0555c5;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
td {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
/* The switch - the box around the slider */
|
||||
.switch {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
width: 30px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
/* Hide default HTML checkbox */
|
||||
.switch input {
|
||||
opacity: 0;
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
/* The slider */
|
||||
.slider {
|
||||
position: absolute;
|
||||
cursor: pointer;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: #ccc;
|
||||
-webkit-transition: .4s;
|
||||
transition: .4s;
|
||||
}
|
||||
|
||||
.slider:before {
|
||||
position: absolute;
|
||||
content: "";
|
||||
height: 13px;
|
||||
width: 13px;
|
||||
left: 4px;
|
||||
bottom: 2px;
|
||||
background-color: white;
|
||||
-webkit-transition: .4s;
|
||||
transition: .4s;
|
||||
}
|
||||
|
||||
input:checked+.slider {
|
||||
background-color: #2196F3;
|
||||
}
|
||||
|
||||
input:focus+.slider {
|
||||
box-shadow: 0 0 1px #2196F3;
|
||||
}
|
||||
|
||||
input:checked+.slider:before {
|
||||
-webkit-transform: translateX(13px);
|
||||
-ms-transform: translateX(13px);
|
||||
transform: translateX(13px);
|
||||
}
|
||||
|
||||
/* Rounded sliders */
|
||||
.slider.round {
|
||||
border-radius: 17px;
|
||||
}
|
||||
|
||||
.slider.round:before {
|
||||
border-radius: 50%;
|
||||
}
|
||||
.tooltip {
|
||||
position: relative;
|
||||
border-bottom: 1px dotted black;
|
||||
}
|
||||
|
||||
.tooltip:before {
|
||||
content: attr(tooltip-data);
|
||||
position: absolute;
|
||||
width: 250px;
|
||||
background-color: #006aff;
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
padding: 15px;
|
||||
line-height: 1.1;
|
||||
border-radius: 5px;
|
||||
z-index: 1;
|
||||
opacity: 0;
|
||||
transition: opacity .5s;
|
||||
bottom: 125%;
|
||||
left: 50%;
|
||||
margin-left: -60px;
|
||||
font-size: 0.70em;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.tooltip:after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
bottom: 75%;
|
||||
left: 50%;
|
||||
margin-left: -5px;
|
||||
border-width: 5px;
|
||||
border-style: solid;
|
||||
opacity: 0;
|
||||
transition: opacity .5s;
|
||||
border-color: #000 transparent transparent transparent;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.tooltip:hover:before,
|
||||
.tooltip:hover:after {
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
}
|
||||
218
_code-samples/mpt-sender/send-mpt.html
Normal file
@@ -0,0 +1,218 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Send MPT</title>
|
||||
<link href='https://fonts.googleapis.com/css?family=Work Sans' rel='stylesheet'>
|
||||
<link href="modular-tutorials.css" rel="stylesheet">
|
||||
<script src='https://unpkg.com/xrpl@4.1.0/build/xrpl-latest.js'></script>
|
||||
<script src="account-support.js"></script>
|
||||
<script src='send-mpt.js'></script>
|
||||
<script>
|
||||
if (typeof module !== "undefined") {
|
||||
const xrpl = require('xrpl')
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<!-- ************************************************************** -->
|
||||
<!-- ********************** The Form ****************************** -->
|
||||
<!-- ************************************************************** -->
|
||||
|
||||
<body>
|
||||
<h1>Send MPT</h1>
|
||||
<form id="theForm">
|
||||
<span class="tooltip" tooltip-data="Choose the XRPL host server for your account.">
|
||||
Choose your ledger instance:
|
||||
</span>
|
||||
|
||||
<input type="radio" id="dn" name="server" value="wss://s.devnet.rippletest.net:51233" checked>
|
||||
<label for="dn">Devnet</label>
|
||||
|
||||
<input type="radio" id="tn" name="server" value="wss://s.altnet.rippletest.net:51233">
|
||||
<label for="tn">Testnet</label>
|
||||
<br /><br />
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<button type="button" onClick="getNewAccount1()">Get New Account 1</button>
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" onClick="getAccountFromSeed1()">Get Account 1 From Seed</button>
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" onClick="getNewAccount2()">Get New Account 2</button>
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" onClick="getAccountFromSeed2()">Get Account 2 From Seed</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="tooltip" tooltip-data="Arbitrary human-readable name for the account."><label for="account1name">Account 1 Name</label>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="account1name" size="40"></input>
|
||||
</td>
|
||||
<td>
|
||||
<span class="tooltip" tooltip-data="Arbitrary human-readable name for the account.">
|
||||
<label for="account2name">Account 2 Name</label>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="account2name" size="40"></input>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="tooltip" tooltip-data="Identifying address for the account.">
|
||||
<label for="account1address">Account 1 Address</label>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="account1address" size="40"></input>
|
||||
</td>
|
||||
<td>
|
||||
<span class="tooltip" tooltip-data="Identifying address for the account.">
|
||||
<label for="account2address">Account 2 Address</label>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="account2address" size="40"></input>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="tooltip" tooltip-data="Seed for deriving public and private keys for the account.">
|
||||
<label for="account1seed">Account 1 Seed</label>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="account1seed" size="40"></input>
|
||||
</td>
|
||||
<td>
|
||||
<span class="tooltip" tooltip-data="Seed for deriving public and private keys for the account.">
|
||||
<label for="account2seed">Account 2 Seed</label>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="account2seed" size="40"></input>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<hr />
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td align="right">
|
||||
<span class="tooltip" tooltip-data="Name of the currently selected account.">
|
||||
<label for="accountNameField">Account Name</label>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="accountNameField" size="40" readonly></input>
|
||||
<input type="radio" id="account1" name="accounts" value="account1">
|
||||
<label for="account1">Account 1</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right">
|
||||
<span class="tooltip" tooltip-data="Address of the currently selected account.">
|
||||
<label for="accountAddressField">Account Address</label>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="accountAddressField" size="40" readonly></input>
|
||||
<input type="radio" id="account2" name="accounts" value="account2">
|
||||
<label for="account2">Account 2</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right">
|
||||
<span class="tooltip" tooltip-data="Seed of the currently selected account.">
|
||||
<label for="accountSeedField">Account Seed</label>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="accountSeedField" size="40" readonly></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
<span class="tooltip" tooltip-data="XRP balance for the currently selected account.">
|
||||
<label for="xrpBalanceField">XRP Balance</label>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="xrpBalanceField" size="40" readonly></input>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
<span class="tooltip" tooltip-data="Issuance ID of the MPT you want to trade.">
|
||||
<lable for="mptIdField">MPT Issuance ID</lable>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="mptIdField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" onClick="authorizeMPT()">Authorize MPT</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
<span class="tooltip" tooltip-data="Number of MPTs to send.">
|
||||
<label for="amountField">Amount</label>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="amountField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" onClick="sendMPT()">Send MPT</button>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
<span class="tooltip" tooltip-data="Destination account address for MPT transfer.">
|
||||
<lable for="destinationField">Destination</lable>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="destinationField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
<td align="left" valign="top">
|
||||
<button type="button" onClick="getMPTs()">Get MPTs</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<p align="right">
|
||||
<textarea id="resultField" cols="80" rows="20"></textarea>
|
||||
</p>
|
||||
</td>
|
||||
<td align="left" valign="top">
|
||||
<button type="button" onClick="gatherAccountInfo()">Gather Account Info</button><br/>
|
||||
<button type="button" onClick="distributeAccountInfo()">Distribute Account Info</button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</body>
|
||||
<script>
|
||||
let radioButtons = document.querySelectorAll('input[type="radio"]');
|
||||
radioButtons.forEach(radio => {
|
||||
radio.addEventListener('change', function() {
|
||||
if (this.value === 'account1') {
|
||||
populate1()
|
||||
} else if (this.value === 'account2') {
|
||||
populate2()
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</html>
|
||||
101
_code-samples/mpt-sender/send-mpt.js
Normal file
@@ -0,0 +1,101 @@
|
||||
// *******************************************************
|
||||
// ********************* Send MPT ************************
|
||||
// *******************************************************
|
||||
|
||||
async function sendMPT() {
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
await client.connect()
|
||||
let results = `Connected to ${net}....`
|
||||
resultField.value = results
|
||||
const wallet = xrpl.Wallet.fromSeed(accountSeedField.value)
|
||||
const mpt_issuance_id = mptIdField.value
|
||||
const mpt_quantity = amountField.value
|
||||
const send_mpt_tx = {
|
||||
"TransactionType": "Payment",
|
||||
"Account": wallet.address,
|
||||
"Amount": {
|
||||
"mpt_issuance_id": mpt_issuance_id,
|
||||
"value": mpt_quantity,
|
||||
},
|
||||
"Destination": destinationField.value,
|
||||
}
|
||||
const pay_prepared = await client.autofill(send_mpt_tx)
|
||||
const pay_signed = wallet.sign(pay_prepared)
|
||||
results += `\n\nSending ${mpt_quantity} ${mpt_issuance_id} to ${destinationField.value} ...`
|
||||
resultField.value = results
|
||||
const pay_result = await client.submitAndWait(pay_signed.tx_blob)
|
||||
if (pay_result.result.meta.TransactionResult == "tesSUCCESS") {
|
||||
results += 'Transaction succeeded.\n\n'
|
||||
results += JSON.stringify(pay_result.result, null, 2)
|
||||
resultField.value = results
|
||||
} else {
|
||||
results += `\nTransaction failed: ${pay_result.result.meta.TransactionResult}\n\n`
|
||||
results += JSON.stringify(pay_result.result, null, 2)
|
||||
resultField.value = results
|
||||
}
|
||||
client.disconnect()
|
||||
} // end of sendMPT()
|
||||
|
||||
// *******************************************************
|
||||
// ******************** Get MPTs *************************
|
||||
// *******************************************************
|
||||
|
||||
async function getMPTs() {
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
await client.connect()
|
||||
const wallet = xrpl.Wallet.fromSeed(accountSeedField.value)
|
||||
let results = `Connected to ${net}....`
|
||||
resultField.value = results
|
||||
const mpts = await client.request({
|
||||
command: "account_objects",
|
||||
account: wallet.address,
|
||||
ledger_index: "validated",
|
||||
type: "mptoken"
|
||||
})
|
||||
let JSONString = JSON.stringify(mpts.result, null, 2)
|
||||
let JSONParse = JSON.parse(JSONString)
|
||||
let numberOfMPTs = JSONParse.account_objects.length
|
||||
let x = 0
|
||||
while (x < numberOfMPTs){
|
||||
results += "\n\nMPT Issuance ID: " + JSONParse.account_objects[x].MPTokenIssuanceID
|
||||
+ "\nMPT Amount: " + JSONParse.account_objects[x].MPTAmount
|
||||
x++
|
||||
}
|
||||
results += "\n\n" + JSONString
|
||||
resultField.value = results
|
||||
client.disconnect()
|
||||
} // End of getMPTs()
|
||||
|
||||
// **********************************************************************
|
||||
// ****** MPTAuthorize Transaction ***************************************
|
||||
// **********************************************************************
|
||||
|
||||
async function authorizeMPT() {
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
await client.connect()
|
||||
let results = `Connected to ${net}....`
|
||||
resultField.value = results
|
||||
const wallet = xrpl.Wallet.fromSeed(accountSeedField.value)
|
||||
const mpt_issuance_id = mptIdField.value
|
||||
const auth_mpt_tx = {
|
||||
"TransactionType": "MPTokenAuthorize",
|
||||
"Account": wallet.address,
|
||||
"MPTokenIssuanceID": mpt_issuance_id,
|
||||
}
|
||||
const auth_prepared = await client.autofill(auth_mpt_tx)
|
||||
const auth_signed = wallet.sign(auth_prepared)
|
||||
results += `\n\nSending authorization...`
|
||||
resultField.value = results
|
||||
const auth_result = await client.submitAndWait(auth_signed.tx_blob)
|
||||
if (auth_result.result.meta.TransactionResult == "tesSUCCESS") {
|
||||
results += `\nTransaction succeeded`
|
||||
resultField.value = results
|
||||
} else {
|
||||
results += `\nTransaction failed: ${auth_result.result.meta.TransactionResult}`
|
||||
resultField.value = results
|
||||
}
|
||||
client.disconnect()
|
||||
} // end of MPTAuthorize()
|
||||
BIN
_code-samples/mpt-sender/send-mpt.zip
Normal file
@@ -55,6 +55,14 @@ MPTs are intended to be complementary to IOUs. While there might be use cases w
|
||||
|
||||
## See Also
|
||||
|
||||
- **Use Case**
|
||||
|
||||
- [Creating an Asset-backed Multi-purpose Token](../../../use-cases/tokenization/creating-an-asset-backed-multi-purpose-token.md)
|
||||
|
||||
- **Tutorial**
|
||||
|
||||
- [Sending MPTs](../../../tutorials/javascript/send-payments/sending-mpts.md)
|
||||
|
||||
- **References:**
|
||||
- [MPToken](../../../references/protocol/ledger-data/ledger-entry-types/mptoken.md)
|
||||
- [MPTokenIssuance](../../../references/protocol/ledger-data/ledger-entry-types/mptokenissuance.md)
|
||||
|
||||
BIN
docs/img/tut-send-mpt-0-empty-form.png
Normal file
|
After Width: | Height: | Size: 202 KiB |
BIN
docs/img/tut-send-mpt-1-gathered-info.png
Normal file
|
After Width: | Height: | Size: 247 KiB |
BIN
docs/img/tut-send-mpt-2-account-2.png
Normal file
|
After Width: | Height: | Size: 254 KiB |
BIN
docs/img/tut-send-mpt-2-authorize-mpt.png
Normal file
|
After Width: | Height: | Size: 305 KiB |
BIN
docs/img/tut-send-mpt-3-send-mpt.png
Normal file
|
After Width: | Height: | Size: 424 KiB |
BIN
docs/img/tut-send-mpt-4-get-mpts.png
Normal file
|
After Width: | Height: | Size: 411 KiB |
BIN
docs/img/uc-mpt1-mpt-generator-empty-form.png
Normal file
|
After Width: | Height: | Size: 200 KiB |
BIN
docs/img/uc-mpt1-mpt-generator.png
Normal file
|
After Width: | Height: | Size: 183 KiB |
BIN
docs/img/uc-mpt1-t-bill-account-configuration.png
Normal file
|
After Width: | Height: | Size: 449 KiB |
BIN
docs/img/uc-mpt1-t-bill-create-success.png
Normal file
|
After Width: | Height: | Size: 585 KiB |
BIN
docs/img/uc-mpt1-t-bill-gather-mpt-info.png
Normal file
|
After Width: | Height: | Size: 397 KiB |
BIN
docs/img/uc-mpt1-t-bill-in-explorer.png
Normal file
|
After Width: | Height: | Size: 224 KiB |
BIN
docs/img/uc-mpt1-t-bill-mpt-generator-generate-code.png
Normal file
|
After Width: | Height: | Size: 552 KiB |
BIN
docs/img/uc-mpt1-t-bill-mpt-generator.png
Normal file
|
After Width: | Height: | Size: 343 KiB |
824
docs/tutorials/javascript/send-payments/sending-mpts.md
Normal file
@@ -0,0 +1,824 @@
|
||||
---
|
||||
seo:
|
||||
description: Issue an asset-backed token such as a US Treasury bill using multi-purpose tokens.
|
||||
labels:
|
||||
- Tokens
|
||||
- MPT
|
||||
---
|
||||
# Sending MPTs
|
||||
|
||||
_(Requires the [MPToken amendment][] {% not-enabled /%})_
|
||||
|
||||
To send an MPT to another account, the receiving account must first authorize the receipt of the MPT, based on its MPToken Issuance ID. This is to prevent malicious users from spamming accounts with unwanted tokens that could negatively impact storage and XRP reserves.
|
||||
|
||||
Once an account receives an MPT, it can send the MPT to another account, provided the MPT was created with the _Can Transfer_ flag set, and the receiving account authorizes the MPT.
|
||||
|
||||
## Send MPT Utility
|
||||
|
||||
The Send MPT utility <!-- embedded below -->lets you create an account, authorize it to receive a specific MPT issuance, then send it the authorized MPT from an issuer or holder account. (You can issue an MPT using the [MPT Generator](../../../use-cases/tokenization/creating-an-asset-backed-multi-purpose-token.md) utility.)
|
||||
|
||||

|
||||
|
||||
You can download a [standalone version of the MPT Sender](../../../../_code-samples/mpt-sender/send-mpt.zip) as sample code<!--, or use the embedded form that follows-->.
|
||||
|
||||
## Get Accounts
|
||||
|
||||
To send an MPT, you need the **Seed** value for the MPT issuer to retrieve its account, then you need either a new account or an account seed for the target account. You can use the [MPT Generator](../../../use-cases/tokenization/creating-an-asset-backed-multi-purpose-token.md) to create a new MPT for transfer.
|
||||
|
||||
To get the accounts:
|
||||
|
||||
1. Open <tt>send-mpt.html</tt> in a browser.
|
||||
2. Choose your ledger instance (**Devnet** or **Testnet**).
|
||||
3. If you used the MPT Generator:
|
||||
1. Paste the gathered info in the **Result** field.
|
||||

|
||||
2. Cut and paste the MPT Issuance ID to the **MPT Issuance ID** field.
|
||||
3. Click **Distribute Account Info** to populate the **Account 1** fields.<br/><br/>
|
||||
(If you did not use the MPT Generator, enter the **Account 1 Name**, **Account 1 Address**, **Account 1 Seed**, and **MPT Issuance ID** in the corresponding fields.)
|
||||
4. Click **Get New Account 2**.
|
||||
5. Optionally, add the **Account 2 Name**, an arbitrary human-readable name that helps to differentiate the accounts.
|
||||

|
||||
|
||||
## Authorize MPT
|
||||
|
||||
To receive MPTs, an account needs to authorize the MPT.
|
||||
|
||||
To authorize Account 2 to accept MPTs:
|
||||
|
||||
1. Click the **Account 2** radio button.
|
||||
2. Enter an **Amount**, the maximum number of MPTs the account will accept.
|
||||
2. Click **Authorize MPTs**.
|
||||

|
||||
|
||||
## Send MPT
|
||||
|
||||
To send an MPT:
|
||||
|
||||
1. Click the **Account 1** radio button.
|
||||
3. Enter the **MPT Issuance ID**.
|
||||
2. Enter an **Amount** of MPTs to send.
|
||||
3. Enter the **Destination** (likely the value in the **Account 2 Address** field, but it can be any account on the same ledger instance).
|
||||
4. Click **Send MPT**.
|
||||

|
||||
|
||||
## Get MPTs
|
||||
|
||||
To verify receipt of the MPTs:
|
||||
|
||||
1. Click the **Account 2** radio button.
|
||||
2. Click **Get MPTs**.
|
||||

|
||||
|
||||
# Code Walkthrough
|
||||
|
||||
You can download a [standalone version of the MPT Sender](../../../../_code-samples/mpt-sender/send-mpt.zip) as sample code.
|
||||
|
||||
## send-mpt.js
|
||||
|
||||
The code that supports the MPT features is in the `send-mpt.js` file. Standard support for connecting to the XRP Ledger is included in the `account-support.js` file.
|
||||
|
||||
### sendMPT()
|
||||
|
||||
Connect to the network and instantiate the account wallet.
|
||||
|
||||
```javascript
|
||||
async function sendMPT() {
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
await client.connect()
|
||||
let results = `Connected to ${net}....`
|
||||
resultField.value = results
|
||||
const wallet = xrpl.Wallet.fromSeed(accountSeedField.value)
|
||||
```
|
||||
|
||||
Instantiate the parameter variables.
|
||||
|
||||
```javascript
|
||||
const mpt_issuance_id = mptIdField.value
|
||||
const mpt_quantity = amountField.value
|
||||
```
|
||||
|
||||
Create a Payment transaction using the MPT for the Amount.
|
||||
|
||||
```javascript
|
||||
const send_mpt_tx = {
|
||||
"TransactionType": "Payment",
|
||||
"Account": wallet.address,
|
||||
"Amount": {
|
||||
"mpt_issuance_id": mpt_issuance_id,
|
||||
"value": mpt_quantity,
|
||||
},
|
||||
"Destination": destinationField.value,
|
||||
}
|
||||
```
|
||||
|
||||
Prepare and sign the transaction.
|
||||
|
||||
```javascript
|
||||
const pay_prepared = await client.autofill(send_mpt_tx)
|
||||
const pay_signed = wallet.sign(pay_prepared)
|
||||
```
|
||||
|
||||
Send the prepared transaction and report the results.
|
||||
|
||||
```javascript
|
||||
results += `\n\nSending ${mpt_quantity} ${mpt_issuance_id} to ${destinationField.value} ...`
|
||||
resultField.value = results
|
||||
const pay_result = await client.submitAndWait(pay_signed.tx_blob)
|
||||
if (pay_result.result.meta.TransactionResult == "tesSUCCESS") {
|
||||
results += 'Transaction succeeded.\n\n'
|
||||
results += JSON.stringify(pay_result.result, null, 2)
|
||||
resultField.value = results
|
||||
} else {
|
||||
results += `\nTransaction failed: ${pay_result.result.meta.TransactionResult}\n\n`
|
||||
results += JSON.stringify(pay_result.result, null, 2)
|
||||
resultField.value = results
|
||||
}
|
||||
client.disconnect()
|
||||
} // end of sendMPT()
|
||||
```
|
||||
|
||||
## getMPTs
|
||||
|
||||
Get all of the MPTs for the selected account by filtering for MPT objects and looping through the array to display them one at a time.
|
||||
|
||||
Connect to the XRPL instance and get the account wallet.
|
||||
|
||||
```javascript
|
||||
async function getMPTs() {
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
await client.connect()
|
||||
const wallet = xrpl.Wallet.fromSeed(accountSeedField.value)
|
||||
let results = `Connected to ${net}....`
|
||||
resultField.value = results
|
||||
```
|
||||
|
||||
Send an `account_objects` request, specifying the type _mptoken_.
|
||||
|
||||
```javascript
|
||||
const mpts = await client.request({
|
||||
command: "account_objects",
|
||||
account: wallet.address,
|
||||
ledger_index: "validated",
|
||||
type: "mptoken"
|
||||
})
|
||||
```
|
||||
|
||||
Stringify and parse the JSON result string.
|
||||
|
||||
```javascript
|
||||
let JSONString = JSON.stringify(mpts.result, null, 2)
|
||||
let JSONParse = JSON.parse(JSONString)
|
||||
let numberOfMPTs = JSONParse.account_objects.length
|
||||
```
|
||||
|
||||
Loop through the filtered array of account_objects to list all of the MPTs held by the account.
|
||||
|
||||
```javascript
|
||||
let x = 0
|
||||
while (x < numberOfMPTs){
|
||||
results += "\n\nMPT Issuance ID: " + JSONParse.account_objects[x].MPTokenIssuanceID
|
||||
+ "\nMPT Amount: " + JSONParse.account_objects[x].MPTAmount
|
||||
x++
|
||||
}
|
||||
```
|
||||
|
||||
Return the parsed results, followed by the raw results.
|
||||
|
||||
```javascript
|
||||
results += "\n\n" + JSONString
|
||||
resultField.value = results
|
||||
client.disconnect()
|
||||
} // End of getMPTs()
|
||||
```
|
||||
|
||||
## authorizeMPT
|
||||
|
||||
Before you can send an MPT to another account, the target account must authorize the MPT.
|
||||
|
||||
Connect to the XRPL and instantiate the account wallet.
|
||||
|
||||
```javascript
|
||||
async function authorizeMPT() {
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
await client.connect()
|
||||
let results = `Connected to ${net}....`
|
||||
resultField.value = results
|
||||
const wallet = xrpl.Wallet.fromSeed(accountSeedField.value)
|
||||
```
|
||||
|
||||
Capture the MPT issuance ID in a variable.
|
||||
|
||||
```javascript
|
||||
const mpt_issuance_id = mptIdField.value
|
||||
```
|
||||
|
||||
Create the MPTokenAuthorize transaction, passing the target account's address and the MPT Issuance ID.
|
||||
|
||||
```javascript
|
||||
const auth_mpt_tx = {
|
||||
"TransactionType": "MPTokenAuthorize",
|
||||
"Account": wallet.address,
|
||||
"MPTokenIssuanceID": mpt_issuance_id,
|
||||
}
|
||||
```
|
||||
|
||||
Prepare, sign, and send the transaction.
|
||||
|
||||
```javascript
|
||||
const auth_prepared = await client.autofill(auth_mpt_tx)
|
||||
const auth_signed = wallet.sign(auth_prepared)
|
||||
results += `\n\nSending authorization...`
|
||||
resultField.value = results
|
||||
const auth_result = await client.submitAndWait(auth_signed.tx_blob)
|
||||
```
|
||||
|
||||
Report the results.
|
||||
|
||||
```javascript
|
||||
if (auth_result.result.meta.TransactionResult == "tesSUCCESS") {
|
||||
results += `\nTransaction succeeded`
|
||||
resultField.value = results
|
||||
} else {
|
||||
results += `\nTransaction failed: ${auth_result.result.meta.TransactionResult}`
|
||||
resultField.value = results
|
||||
}
|
||||
client.disconnect()
|
||||
} // end of MPTAuthorize()
|
||||
|
||||
```
|
||||
|
||||
## send-mpt.html
|
||||
|
||||
```html
|
||||
<html>
|
||||
<head>
|
||||
<title>Send MPT</title>
|
||||
<link href='https://fonts.googleapis.com/css?family=Work Sans' rel='stylesheet'>
|
||||
<link href="modular-tutorials.css" rel="stylesheet">
|
||||
<script src='https://unpkg.com/xrpl@4.1.0/build/xrpl-latest.js'></script>
|
||||
<script src="account-support.js"></script>
|
||||
<script src='send-mpt.js'></script>
|
||||
<script>
|
||||
if (typeof module !== "undefined") {
|
||||
const xrpl = require('xrpl')
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<!-- ************************************************************** -->
|
||||
<!-- ********************** The Form ****************************** -->
|
||||
<!-- ************************************************************** -->
|
||||
|
||||
<body>
|
||||
<h1>Send MPT</h1>
|
||||
<form id="theForm">
|
||||
<span class="tooltip" tooltip-data="Choose the XRPL host server for your account.">
|
||||
Choose your ledger instance:
|
||||
</span>
|
||||
|
||||
<input type="radio" id="dn" name="server" value="wss://s.devnet.rippletest.net:51233" checked>
|
||||
<label for="dn">Devnet</label>
|
||||
|
||||
<input type="radio" id="tn" name="server" value="wss://s.altnet.rippletest.net:51233">
|
||||
<label for="tn">Testnet</label>
|
||||
<br /><br />
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<button type="button" onClick="getNewAccount1()">Get New Account 1</button>
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" onClick="getAccountFromSeed1()">Get Account 1 From Seed</button>
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" onClick="getNewAccount2()">Get New Account 2</button>
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" onClick="getAccountFromSeed2()">Get Account 2 From Seed</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="tooltip" tooltip-data="Arbitrary human-readable name for the account."><label for="account1name">Account 1 Name</label>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="account1name" size="40"></input>
|
||||
</td>
|
||||
<td>
|
||||
<span class="tooltip" tooltip-data="Arbitrary human-readable name for the account.">
|
||||
<label for="account2name">Account 2 Name</label>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="account2name" size="40"></input>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="tooltip" tooltip-data="Identifying address for the account.">
|
||||
<label for="account1address">Account 1 Address</label>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="account1address" size="40"></input>
|
||||
</td>
|
||||
<td>
|
||||
<span class="tooltip" tooltip-data="Identifying address for the account.">
|
||||
<label for="account2address">Account 2 Address</label>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="account2address" size="40"></input>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="tooltip" tooltip-data="Seed for deriving public and private keys for the account.">
|
||||
<label for="account1seed">Account 1 Seed</label>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="account1seed" size="40"></input>
|
||||
</td>
|
||||
<td>
|
||||
<span class="tooltip" tooltip-data="Seed for deriving public and private keys for the account.">
|
||||
<label for="account2seed">Account 2 Seed</label>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="account2seed" size="40"></input>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<hr />
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td align="right">
|
||||
<span class="tooltip" tooltip-data="Name of the currently selected account.">
|
||||
<label for="accountNameField">Account Name</label>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="accountNameField" size="40" readonly></input>
|
||||
<input type="radio" id="account1" name="accounts" value="account1">
|
||||
<label for="account1">Account 1</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right">
|
||||
<span class="tooltip" tooltip-data="Address of the currently selected account.">
|
||||
<label for="accountAddressField">Account Address</label>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="accountAddressField" size="40" readonly></input>
|
||||
<input type="radio" id="account2" name="accounts" value="account2">
|
||||
<label for="account2">Account 2</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right">
|
||||
<span class="tooltip" tooltip-data="Seed of the currently selected account.">
|
||||
<label for="accountSeedField">Account Seed</label>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="accountSeedField" size="40" readonly></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
<span class="tooltip" tooltip-data="XRP balance for the currently selected account.">
|
||||
<label for="xrpBalanceField">XRP Balance</label>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="xrpBalanceField" size="40" readonly></input>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
<span class="tooltip" tooltip-data="Issuance ID of the MPT you want to trade.">
|
||||
<lable for="mptIdField">MPT Issuance ID</lable>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="mptIdField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" onClick="authorizeMPT()">Authorize MPT</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
<span class="tooltip" tooltip-data="Number of MPTs to send.">
|
||||
<label for="amountField">Amount</label>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="amountField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" onClick="sendMPT()">Send MPT</button>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
<span class="tooltip" tooltip-data="Destination account address for MPT transfer.">
|
||||
<lable for="destinationField">Destination</lable>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="destinationField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
<td align="left" valign="top">
|
||||
<button type="button" onClick="getMPTs()">Get MPTs</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<p align="right">
|
||||
<textarea id="resultField" cols="80" rows="20"></textarea>
|
||||
</p>
|
||||
</td>
|
||||
<td align="left" valign="top">
|
||||
<button type="button" onClick="gatherAccountInfo()">Gather Account Info</button><br/>
|
||||
<button type="button" onClick="distributeAccountInfo()">Distribute Account Info</button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</body>
|
||||
<script>
|
||||
let radioButtons = document.querySelectorAll('input[type="radio"]');
|
||||
radioButtons.forEach(radio => {
|
||||
radio.addEventListener('change', function() {
|
||||
if (this.value === 'account1') {
|
||||
populate1()
|
||||
} else if (this.value === 'account2') {
|
||||
populate2()
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</html>
|
||||
```
|
||||
<!--
|
||||
<div>
|
||||
<link href='https://fonts.googleapis.com/css?family=Work Sans' rel='stylesheet'>
|
||||
<script src='https://unpkg.com/xrpl@4.1.0/build/xrpl-latest.js'></script>
|
||||
<script>
|
||||
if (typeof module !== "undefined") {
|
||||
const xrpl = require("xrpl")
|
||||
}
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
getHolderAccountFromSeedButton.addEventListener("click", getHolderFromSeed)
|
||||
getReceiverAccountButton.addEventListener("click", getAccount)
|
||||
getReceiverFromSeedButton.addEventListener("click", getReceiverFromSeed)
|
||||
authorizeMPTButton.addEventListener("click", authorizeMPT)
|
||||
sendMPTButton.addEventListener("click", sendMPT)
|
||||
getMPTsButton.addEventListener("click", getMPTs)
|
||||
})
|
||||
function 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()
|
||||
// *******************************************************
|
||||
// ************* Get Account *****************************
|
||||
// *******************************************************
|
||||
async function getAccount() {
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
receiverAccountField.value = "Getting a new account..."
|
||||
results = 'Connecting to ' + net + '....'
|
||||
//-------------------------------This uses the default faucet for Testnet/Devnet.
|
||||
let faucetHost = null
|
||||
await client.connect()
|
||||
results += '\nConnected, funding wallet.'
|
||||
// ----------------------------------------Create and fund a test account wallet.
|
||||
const my_wallet = (await client.fundWallet(null, { faucetHost })).wallet
|
||||
results += '\nGot a wallet.'
|
||||
// ------------------------------------------------------Get the current balance.
|
||||
receiverAccountField.value = my_wallet.address
|
||||
receiverSeedField.value = my_wallet.seed
|
||||
results += '\nAccount created.'
|
||||
console.log(results)
|
||||
client.disconnect()
|
||||
} // End of getAccount()
|
||||
// **********************************************************
|
||||
// *********** Get Holder from Seed *************************
|
||||
// **********************************************************
|
||||
async function getHolderFromSeed() {
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
holderAccountField.value = "Getting holder account from seed..."
|
||||
results = 'Connecting to ' + getNet() + '....'
|
||||
await client.connect()
|
||||
results += '\nConnected, finding wallets.\n'
|
||||
console.log(results)
|
||||
// --------------------------------------------------Find the test account wallet.
|
||||
const my_wallet = xrpl.Wallet.fromSeed(holderSeedField.value)
|
||||
// -------------------------------------------------------Get the current balance.
|
||||
holderAccountField.value = my_wallet.address
|
||||
holderSeedField.value = my_wallet.seed
|
||||
client.disconnect()
|
||||
} // End of getHolderFromSeed()
|
||||
// **********************************************************
|
||||
// *********** Get Receiver from Seed *************************
|
||||
// **********************************************************
|
||||
async function getReceiverFromSeed() {
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
receiverAccountField.value = "Getting receiver account from seed..."
|
||||
results = 'Connecting to ' + getNet() + '....'
|
||||
await client.connect()
|
||||
results += '\nConnected, finding wallets.\n'
|
||||
resultsArea.value = results
|
||||
// --------------------------------------------------Find the test account wallet.
|
||||
const my_wallet = xrpl.Wallet.fromSeed(receiverSeedField.value)
|
||||
// -------------------------------------------------------Get the current balance.
|
||||
receiverAccountField.value = my_wallet.address
|
||||
receiverSeedField.value = my_wallet.seed
|
||||
resultsArea.value = results
|
||||
client.disconnect()
|
||||
} // End of getReceiverFromSeed()
|
||||
// *******************************************************
|
||||
// *************** Send MPT **********************
|
||||
// *******************************************************
|
||||
async function sendMPT() {
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
results = 'Connecting to ' + getNet() + '....'
|
||||
resultsArea.value = results
|
||||
await client.connect()
|
||||
results += '\nConnected.'
|
||||
resultsArea.value = results
|
||||
const holder_wallet = xrpl.Wallet.fromSeed(holderSeedField.value)
|
||||
const mpt_issuance_id = mptIssuanceIDField.value
|
||||
const mpt_quantity = quantityField.value
|
||||
const send_mpt_tx = {
|
||||
"TransactionType": "Payment",
|
||||
"Account": holder_wallet.address,
|
||||
"Amount": {
|
||||
"mpt_issuance_id": mpt_issuance_id,
|
||||
"value": mpt_quantity,
|
||||
},
|
||||
"Destination": receiverAccountField.value,
|
||||
}
|
||||
const pay_prepared = await client.autofill(send_mpt_tx)
|
||||
const pay_signed = holder_wallet.sign(pay_prepared)
|
||||
results += `\n\nSending ${mpt_quantity} ${mpt_issuance_id} to ${receiverAccountField.value} ...`
|
||||
resultsArea.value = results
|
||||
const pay_result = await client.submitAndWait(pay_signed.tx_blob)
|
||||
if (pay_result.result.meta.TransactionResult == "tesSUCCESS") {
|
||||
results += 'Transaction succeeded.\n\n'
|
||||
results += JSON.stringify(pay_result.result, null, 2)
|
||||
resultsArea.value = results
|
||||
} else {
|
||||
results += 'Transaction failed: See JavaScript console for details.'
|
||||
results += JSON.stringify(pay_result.result, null, 2)
|
||||
resultsArea.value = results
|
||||
}
|
||||
client.disconnect()
|
||||
} // end of sendMPT()
|
||||
// *******************************************************
|
||||
// ******************** Get MPTs *************************
|
||||
// *******************************************************
|
||||
async function getMPTs() {
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
results = 'Connecting to ' + getNet() + '....'
|
||||
resultsArea.value = results
|
||||
await client.connect()
|
||||
const receiver_wallet = xrpl.Wallet.fromSeed(receiverSeedField.value)
|
||||
results += '\nConnected.'
|
||||
resultsArea.value = results
|
||||
const mpts = await client.request({
|
||||
command: "account_objects",
|
||||
account: receiver_wallet.address,
|
||||
ledger_index: "validated",
|
||||
type: "mptoken"
|
||||
})
|
||||
let JSONString = JSON.stringify(mpts.result, null, 2)
|
||||
let JSONParse = JSON.parse(JSONString)
|
||||
let numberOfMPTs = JSONParse.account_objects.length
|
||||
let x = 0
|
||||
while (x < numberOfMPTs){
|
||||
results += "\n\nMPT Issuance ID: " + JSONParse.account_objects[x].MPTokenIssuanceID
|
||||
+ "\nMPT Amount: " + JSONParse.account_objects[x].MPTAmount
|
||||
x++
|
||||
}
|
||||
results += "\n\n" + JSONString
|
||||
resultsArea.value = results
|
||||
client.disconnect()
|
||||
} // End of getMPTs()
|
||||
// **********************************************************************
|
||||
// ****** MPTAuthorize Transaction ***************************************
|
||||
// **********************************************************************
|
||||
async function authorizeMPT() {
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
results = 'Connecting to ' + getNet() + '....'
|
||||
resultsArea.value = results
|
||||
await client.connect()
|
||||
const receiver_wallet = xrpl.Wallet.fromSeed(receiverSeedField.value)
|
||||
const mpt_issuance_id = mptIssuanceIDField.value
|
||||
const auth_mpt_tx = {
|
||||
"TransactionType": "MPTokenAuthorize",
|
||||
"Account": receiver_wallet.address,
|
||||
"MPTokenIssuanceID": mpt_issuance_id,
|
||||
}
|
||||
const auth_prepared = await client.autofill(auth_mpt_tx)
|
||||
const auth_signed = receiver_wallet.sign(auth_prepared)
|
||||
results += `\n\nSending authorization...`
|
||||
resultsArea.value = results
|
||||
const auth_result = await client.submitAndWait(auth_signed.tx_blob)
|
||||
console.log(JSON.stringify(auth_result.result, null, 2))
|
||||
if (auth_result.result.meta.TransactionResult == "tesSUCCESS") {
|
||||
results += `Transaction succeeded`
|
||||
resultsArea.value = results
|
||||
} else {
|
||||
results += 'Transaction failed: See JavaScript console for details.'
|
||||
resultsArea.value = results
|
||||
}
|
||||
client.disconnect()
|
||||
} // end of MPTAuthorize()
|
||||
</script>
|
||||
<div>
|
||||
<form>
|
||||
<link href='https://fonts.googleapis.com/css?family=Work Sans' rel='stylesheet'>
|
||||
<script src='https://unpkg.com/xrpl@4.1.0/build/xrpl-latest.js'></script>
|
||||
<!-- Required meta tags - - >
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col align-self-start">
|
||||
<h4>MPT Sender</h4>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col align-self-start">
|
||||
<b>1. Choose your preferred network.</b>
|
||||
</div>
|
||||
<div class="col align-self-center">
|
||||
<input type="radio" id="tn" name="server"
|
||||
value="wss://s.altnet.rippletest.net:51233">
|
||||
<label for="tn">Testnet</label>
|
||||
<br/>
|
||||
<input type="radio" id="dn" name="server"
|
||||
value="wss://s.devnet.rippletest.net:51233" checked>
|
||||
<label for="dn">Devnet</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col align-self-start">
|
||||
<b>2. Get the holder (or issuer) account from its seed.<br/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col align-self-start">
|
||||
<label for="holderSeedField">Holder Seed</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col align-self-start">
|
||||
<input type="text" id="holderSeedField" size="40"></input>
|
||||
<br/><br/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col align-self-start">
|
||||
<label for="holderAccountField">Holder Account</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col align-self-start">
|
||||
<input type="text" id="holderAccountField" size="40"></input>
|
||||
</div>
|
||||
</div>
|
||||
<br/>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col align-self-start">
|
||||
<button type="button" id="getHolderAccountFromSeedButton" class="btn btn-primary">Get Holder Account From Seed</button>
|
||||
<br/><br/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col align-self-start">
|
||||
<b>3. Get a new receiver account or retrieve one from its seed.</b>
|
||||
<div class="row">
|
||||
<div class="col align-self-start">
|
||||
<label for="receiverSeedField">Receiver Seed</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col align-self-start">
|
||||
<input type="text" id="receiverSeedField" size="40"></input>
|
||||
<br/><br/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col align-self-start">
|
||||
<label for="receiverAccountField">Receiver Account</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col align-self-start">
|
||||
<input type="text" id="receiverAccountField" size="40"></input>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col align-self-start">
|
||||
<button type="button" id="getReceiverAccountButton" class="btn btn-primary">Get New Receiver Account</button>
|
||||
</div>
|
||||
<div class="col align-self-start">
|
||||
<button type="button" id="getReceiverFromSeedButton" class="btn btn-primary">Get Receiver Account From Seed</button>
|
||||
<br/><br/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col align-self-start">
|
||||
<b>4. Enter the <i>MPT Issuance ID</i>.</b>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col align-self-start">
|
||||
<label for="mptIssuanceIDField">MPT Issuance ID</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col align-self-start">
|
||||
<input type="text" id="mptIssuanceIDField" size="40"></input>
|
||||
<br/><br/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col align-self-start">
|
||||
<b>5. Click <i>Authorize MPT</i> to authorize the MPT for the receiver.</b>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<button type="button" id="authorizeMPTButton" class="btn btn-primary">Authorize MPT</button>
|
||||
</div>
|
||||
<br/>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col align-self-start">
|
||||
<b>5. Enter the <i>Quantity</i> of MPTs to send.</b>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col align-self-start">
|
||||
<label for="quantity">Quantity</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col align-self-start">
|
||||
<input type="text" id="quantityField" size="40"></input>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-align-items-left">
|
||||
<br/>
|
||||
<p><b>6. Click Send MPTs</b><br/>
|
||||
<button type="button" id="sendMPTButton" class="btn btn-primary">Send MPTs</button>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-align-self-start">
|
||||
<p><b>Results</b></p>
|
||||
<textarea class="form-control" id="resultsArea" rows="18" cols="40"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-align-self-start">
|
||||
<br/>
|
||||
<p><b>7. Click Get MPTs</b><br/>
|
||||
<button type = "button" id="getMPTsButton" class="btn btn-primary">Get MPTs</button>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<hr/>
|
||||
|
||||
-->
|
||||
{% raw-partial file="/docs/_snippets/common-links.md" /%}
|
||||
@@ -0,0 +1,455 @@
|
||||
---
|
||||
seo:
|
||||
description: Issue an asset-backed token such as a US Treasury bill using multi-purpose tokens.
|
||||
labels:
|
||||
- Tokens
|
||||
- MPT
|
||||
---
|
||||
# Creating an Asset-backed Multi-purpose Token
|
||||
|
||||
_(Requires the [MPToken amendment][] {% not-enabled /%})_
|
||||
|
||||
_As a financial professional, I want to use multi-purpose tokens to create an asset-backed token in order to profit from resale transactions._
|
||||
|
||||
A multi-purpose token (MPT) is a compact and flexible object that offers the best aspects of fungible and non-fungible tokens. It is the next generation of tokenization on the XRPL. Notable features include:
|
||||
|
||||
- MPTs store metadata directly on the XRPL blockchain, with the option of linking to additional off-chain data.
|
||||
- MPTs can have a fixed token supply, with a cap on the maximum number of tokens.
|
||||
- MPT issuers can collect transfer fees each time the token is traded.
|
||||
- MPTs can be non-transferable, for use cases such as airline credits.
|
||||
- MPTs also allow advanced compliance features.
|
||||
|
||||
To learn more, see [Multi-purpose Tokens](../../concepts/tokens/fungible-tokens/multi-purpose-tokens.md).
|
||||
|
||||
## MPT Generator
|
||||
|
||||

|
||||
|
||||
You can download a [standalone version of the MPT Generator](../../../_code-samples/mpt-generator/mpt-generator.zip) as sample code<!--, or use the embedded form that follows-->.
|
||||
|
||||
In practice, you want to use an Issuer account configuration to issue an MPT, but you can try the form with a new, unconfigured account and the transaction works fine.<!-- See [Creating a US Treasury Bill](#creating-a-us-treasury-bill) for a full description of the issuance process.The form is populated with sample values, but you can change the parameters for your own experiments.--> A T-bill is one example of the many types of asset you can create and trade on the XRP Ledger.
|
||||
|
||||
<!--
|
||||
<hr/>
|
||||
<div>
|
||||
<link href='https://fonts.googleapis.com/css?family=Work Sans' rel='stylesheet'>
|
||||
<script src='https://unpkg.com/xrpl@4.1.0/build/xrpl-latest.js'></script>
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
getNewAccountButton.addEventListener("click", getAccount)
|
||||
getAccountFromSeedButton.addEventListener("click", getAccountFromSeed)
|
||||
generateCodeButton.addEventListener("click", generateCode)
|
||||
sendTransactionButton.addEventListener("click", sendTransaction)
|
||||
})
|
||||
function 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()
|
||||
// *******************************************************
|
||||
// ************* Get Account *****************************
|
||||
// *******************************************************
|
||||
async function getAccount() {
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
accountField.value = "Getting a new account..."
|
||||
results = 'Connecting to ' + net + '....'
|
||||
//-------------------------------This uses the default faucet for Testnet/Devnet.
|
||||
let faucetHost = null
|
||||
console.log(results)
|
||||
await client.connect()
|
||||
results += '\nConnected, funding wallet.'
|
||||
// ----------------------------------------Create and fund a test account wallet.
|
||||
const my_wallet = (await client.fundWallet(null, { faucetHost })).wallet
|
||||
results += '\nGot a wallet.'
|
||||
// ------------------------------------------------------Get the current balance.
|
||||
const my_balance = (await client.getXrpBalance(my_wallet.address))
|
||||
accountField.value = my_wallet.address
|
||||
seedField.value = my_wallet.seed
|
||||
results += '\nAccount created.'
|
||||
console.log(results)
|
||||
client.disconnect()
|
||||
} // End of getAccount()
|
||||
if (typeof module !== "undefined") {
|
||||
const xrpl = require("xrpl")
|
||||
}
|
||||
async function getAccountFromSeed() {
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
accountField.value = "Getting account from seed..."
|
||||
results = 'Connecting to ' + getNet() + '....'
|
||||
await client.connect()
|
||||
results += '\nConnected, finding wallets.\n'
|
||||
console.log(results)
|
||||
// --------------------------------------------------Find the test account wallet.
|
||||
const my_wallet = xrpl.Wallet.fromSeed(seedField.value)
|
||||
// -------------------------------------------------------Get the current balance.
|
||||
accountField.value = my_wallet.address
|
||||
seedField.value = my_wallet.seed
|
||||
client.disconnect()
|
||||
} // End of getAccountFromSeed()
|
||||
function generateCode() {
|
||||
let v_flags = 0
|
||||
if (clawbackSlider.checked) {v_flags+=64}
|
||||
if (lockSlider.checked) {v_flags+=2}
|
||||
if (authTokenSlider.checked) {v_flags +=4}
|
||||
if (txrSlider.checked) {v_flags += 32}
|
||||
if (tradeSlider.checked) {v_flags += 16}
|
||||
if (escrowSlider.checked) {v_flags+=8}
|
||||
const mptHexString = xrpl.convertStringToHex(metadataTextArea.value)
|
||||
let v_codeBlock = "{\n \"TransactionType\": \"MPTokenIssuanceCreate\",\n \"Account\": \"" + accountField.value +
|
||||
"\",\n \"AssetScale\": 2, \n \"MaximumAmount\": \"" + maximumAmountField.value +
|
||||
"\",\n \"TransferFee\": " + transferFeeField.value +
|
||||
",\n \"Flags\": " + v_flags + ",\n \"MPTokenMetadata\": \"" + mptHexString + "\"\n}"
|
||||
codeTextArea.value = v_codeBlock
|
||||
}
|
||||
// *******************************************************
|
||||
// *************** Send Transaction **********************
|
||||
// *******************************************************
|
||||
async function sendTransaction() {
|
||||
successURLfield.value="Sending transaction..."
|
||||
let v_flags = 0
|
||||
if (clawbackSlider.checked) {v_flags+=64}
|
||||
if (lockSlider.checked) {v_flags+=2}
|
||||
if (authTokenSlider.checked) {v_flags +=4}
|
||||
if (txrSlider.checked) {v_flags += 32}
|
||||
if (tradeSlider.checked) {v_flags += 16}
|
||||
if (escrowSlider.checked) {v_flags+=8}
|
||||
results = 'Connecting to ' + getNet() + '....'
|
||||
console.log(results)
|
||||
let net = getNet()
|
||||
const my_wallet = xrpl.Wallet.fromSeed(seedField.value)
|
||||
const client = new xrpl.Client(net)
|
||||
await client.connect()
|
||||
const metadataHexString = xrpl.convertStringToHex(metadataTextArea.value)
|
||||
const transactionJson = {
|
||||
"TransactionType": "MPTokenIssuanceCreate",
|
||||
"Account": accountField.value,
|
||||
"AssetScale": parseInt(assetScaleField.value),
|
||||
"MaximumAmount": maximumAmountField.value,
|
||||
"TransferFee": parseInt(transferFeeField.value),
|
||||
"Flags": v_flags,
|
||||
"MPTokenMetadata": metadataHexString
|
||||
}
|
||||
const tx = await client.submitAndWait(transactionJson, { wallet: my_wallet} )
|
||||
client.disconnect()
|
||||
if (document.getElementById("tn").checked) {
|
||||
successURLfield.value += "https://testnet.xrpl.org/ledgers/" + tx.result.ledger_index
|
||||
} else {
|
||||
successURLfield.value = "https://devnet.xrpl.org/ledgers/" + tx.result.ledger_index
|
||||
}
|
||||
mptIssuanceIdField.value = JSON.stringify(tx.result.meta.mpt_issuance_id)
|
||||
} //End of sendTransaction()
|
||||
|
||||
</script>
|
||||
<div>
|
||||
<form>
|
||||
<link href='https://fonts.googleapis.com/css?family=Work Sans' rel='stylesheet'>
|
||||
<script src='https://unpkg.com/xrpl@4.1.0/build/xrpl-latest.js'></script>
|
||||
<!-- Required meta tags - - >
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col align-self-start">
|
||||
<h4>MPT Generator</h4>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col align-self-start">
|
||||
<b>1. Choose your preferred network.</b>
|
||||
</div>
|
||||
<div class="col align-self-center">
|
||||
<input type="radio" id="tn" name="server"
|
||||
value="wss://s.altnet.rippletest.net:51233">
|
||||
<label for="tn">Testnet</label>
|
||||
<br/>
|
||||
<input type="radio" id="dn" name="server"
|
||||
value="wss://s.devnet.rippletest.net:51233" checked>
|
||||
<label for="dn">Devnet</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col align-self-start">
|
||||
<b>2. Get a new account or retrieve one from its seed.</b><br/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col align-self-start">
|
||||
<label for="accountField">Account</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col align-self-start">
|
||||
<input type="text" id="accountField" size="40"></input>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col align-self-start">
|
||||
<label for="seedField">Seed</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col align-self-start">
|
||||
<input type="text" id="seedField" size="40"></input>
|
||||
<br/><br/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col align-self-start">
|
||||
<button type="button" id="getNewAccountButton" class="btn btn-primary">Get New Account</button>
|
||||
</div>
|
||||
<div class="col align-self-start">
|
||||
<button type="button" id="getAccountFromSeedButton" class="btn btn-primary">Get Account From Seed</button>
|
||||
<br/><br/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col align-self-start">
|
||||
<b>3. Enter parameter values for your new MPT.</b>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col align-right">
|
||||
<label for="assetScaleField">Asset Scale</label>
|
||||
</div>
|
||||
<div class="col align-self-start">
|
||||
<input type="text" size="10" id="assetScaleField" value="2"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col align-right">
|
||||
<label for="maximumAmountField">Maximum Tokens</label>
|
||||
</div>
|
||||
<div class="col align-self-start">
|
||||
<input type="text" size="10" id="maximumAmountField" value="1000000"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col align-right">
|
||||
<label for="transferFeeField">Transfer Fee</label>
|
||||
</div>
|
||||
<div class="col align-self-start">
|
||||
<input type="text" size="10" id="transferFeeField" value="314"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row"><p></div>
|
||||
<div>
|
||||
<div class="row">
|
||||
<div class="col align-self-start">
|
||||
<b>4. Set flags for your new MPT.</b>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col align-self-start">
|
||||
<label for="clawbackSlider">Clawback</label>
|
||||
</div>
|
||||
<div class="col align-self-start">
|
||||
<input type="checkbox" id="clawbackSlider">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col align-self-start">
|
||||
<label for="lockSlider">Lock</label>
|
||||
</div>
|
||||
<div class="col align-self-start">
|
||||
<input type="checkbox" id="lockSlider">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col align-self-start">
|
||||
<label for="authTokenSlider">Require Authorization</label>
|
||||
</div>
|
||||
<div class="col align-self-start">
|
||||
<input type="checkbox" id="authTokenSlider">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col align-self-start">
|
||||
<label for="txrSlider">Can Transfer</label>
|
||||
</div>
|
||||
<div class="col align-self-start">
|
||||
<input type="checkbox" id="txrSlider" checked>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col align-self-start">
|
||||
<label for="tradeSlider">Can Trade</label>
|
||||
</div>
|
||||
<div class="col align-self-start">
|
||||
<input type="checkbox" id="tradeSlider">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col align-self-start">
|
||||
<label for="escrowSlider">Can Escrow</label>
|
||||
</div>
|
||||
<div class="col align-self-start">
|
||||
<input type="checkbox" id="escrowSlider">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col align-self-start">
|
||||
<b>5. Enter the token metadata.</b>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col align-self-start">
|
||||
<textarea class="form-contol" id="metadataTextArea" rows="18" cols="40"
|
||||
value='{
|
||||
"Name": "US Treasury Bill Token",
|
||||
"Identifier": "USTBT",
|
||||
"Issuer": "US Treasury",
|
||||
"IssueDate": "2024-03-25",
|
||||
"MaturityDate": "2025-03-25",
|
||||
"FaceValue": 1000,
|
||||
"InterestRate": 2.5,
|
||||
"InterestFrequency": "Quarterly",
|
||||
"Collateral": "US Government",
|
||||
"Jurisdiction": "United States",
|
||||
"RegulatoryCompliance": "SEC Regulations",
|
||||
"SecurityType": "Treasury Bill",
|
||||
"ExternalUrl": "https://example.com/t-bill-token-metadata.json"
|
||||
}'></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-align-items-left">
|
||||
<br/>
|
||||
<p><b>6. Click Generate Transaction</b><br/>
|
||||
<button type="button" id="generateCodeButton" class="btn btn-primary">Generate Transaction</button>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-align-self-start">
|
||||
<p><b>MPToken Create Transaction</b></p>
|
||||
<textarea class="form-control" id="codeTextArea" rows="18" cols="40"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-align-self-start">
|
||||
<br/>
|
||||
<p><b>7. Click Send Transaction</b><br/>
|
||||
<button type = "button" id="sendTransactionButton" class="btn btn-primary">Send Transaction</button>
|
||||
</p>
|
||||
<p>
|
||||
<b>8. Follow the URL to your new T-bill.</b>
|
||||
</p>
|
||||
<input type="text" id="successURLfield" size="40"></input>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<p><b>MPT Issuance ID</b><br/>
|
||||
<input type="text" id="mptIssuanceIdField" size="40"></input>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<hr/>
|
||||
-->
|
||||
## Creating a US Treasury Bill as an MPT
|
||||
|
||||
A US Treasury bill (T-bill) is a short-term debt security issued by the US government. T-bills are considered a safe investment because they're backed by the US government. T-bills are appealing to investors in American states that have high income tax because the interest earned is exempt from state and local taxes. See [Treasury Bills In Depth](https://www.treasurydirect.gov/research-center/history-of-marketable-securities/bills/t-bills-indepth/).
|
||||
|
||||
### Creating an Issuing Account
|
||||
|
||||
You can use the Account Configurator to experiment with the settings for a T-bill issuing account in a sandbox environment. When you are satisfied with your configuration, you can create an account on XRPL Mainnet to begin trading.
|
||||
|
||||
To create a new MPT Issuer account:
|
||||
- In the Account Configurator utility, choose ledger instance **Devnet**.
|
||||
- Click **Get New Account**.
|
||||
- Choose account configuration template **Issuer**.
|
||||
|
||||
The form sets the standard flags for an Issuer account and displays additional configuration fields.
|
||||
|
||||

|
||||
|
||||
| Parameter | Value | Description |
|
||||
|-----------|-------|-------------|
|
||||
| **Domain** | _TOML domain_ | URL to the server where your TOML file is stored. For an experimental account, you can enter any URL. When you configure the account, the domain is automatically converted to a hexidecimal string. If you reconfigure the account, you need to enter the original domain again. |
|
||||
| **Transfer Rate** | 1005000000 | A value between 1000000000 and 2000000000 representing the percentage value you collect when a holder transfers one of your issued tokens. A Transfer Rate of 1005000000 returns .5% of the transfer value to this account. See [Transfer Rate](../../references/protocol/transactions/types/accountset.md#transferrate). |
|
||||
| **Tick Size** | 5 | Round offers to this many significant digits. Valid values are 3 to 15, or 0 to disable. |
|
||||
| **Signer Accounts** | _account addresses_ | Accounts that have a vote regarding approval of transactions for this account. |
|
||||
| **Signer Weights** | _int_ | The weight of each signer's signature, relative to other signers. |
|
||||
| **Signer Quorum** | _int_ | The required minimum value of signer weights to approve a transaction. |
|
||||
|
||||
{% admonition type="info" name="Note" %}In practice, configuring signers for your issuing account is a best practice. To reduce complexity, this example does not use signer configuration.{% /admonition %}
|
||||
|
||||
#### Issuer Account Flag Settings
|
||||
|
||||
Use the sliders to configure the standard suggested flag settings. Overall, you want holders of your T-bill to be able to trade with other holders, so rippling is an essential function. You want to be careful about what other accounts are able to send to your account, so you should disallow most types of transfers. One exception is trust lines, which you do want other accounts to be able to create to your issuing account.
|
||||
|
||||
|Flag |Purpose |
|
||||
|------------------------------|------------------------------------------------------------------------------------|
|
||||
| defaultRipple | Allow transfers to third-party holders by default. |
|
||||
| depositAuth | Require authorization for another account to deposit to this account. |
|
||||
| disallowIncomingCheck | Prevent other accounts from sending checks to this account. |
|
||||
| disallowIncomingNFTokenOffer | Prevent other accounts from sending NFTokenOffers to this account. |
|
||||
| disallowIncomingPayChan | Prevent other accounts from creating Payment Channels to this account. |
|
||||
| disallowIncomingXRP | Prevent other accounts from sending XRP to this account. |
|
||||
|
||||
Once you've set your preferred values in the account configurator, click **Configure Account** to finish preparing your account to issue T-bills.
|
||||
|
||||
### Generating a US Treasury Bill as a Multi-purpose Token
|
||||
|
||||
You can represent a US Treasury Bill (T-bill) on the XRPL by creating a multi-purpose token. The example below shows random possible values you might use as a starting point. Adjust as needed for your use case.
|
||||
|
||||

|
||||
|
||||
| Parameter | Value | Description |
|
||||
|-----------|-------|-------------|
|
||||
| Asset Scale | 2 | The difference, in orders of magnitude, between a standard T-bill unit and the corresponding fractional unit. |
|
||||
| Maximum Tokens | 500000 | The maximum number of this T-bill MPT that will ever be issued by this account. |
|
||||
| Transfer Fee | 314 | Fee collected when the T-bill MPT is transferred to another account. |
|
||||
|
||||
As an example, you might set the following flags when creating your T-bill MPT.
|
||||
|
||||
| Flag | Description |
|
||||
|------|-------------|
|
||||
| Can Transfer | A holder can transfer the T-bill MPT to another account. |
|
||||
| Can Trade | A holder can trade the T-bill MPT with another account. |
|
||||
|
||||
#### Token Metadata
|
||||
|
||||
The metadata you provide is what distinguishes your token from other MPTs. The following JSON definition shows sample configuration information for a T-bill. Copy and paste the data, or your own metadata, into the **Token Metadata** field.
|
||||
|
||||
```json
|
||||
{
|
||||
"Name": "US Treasury Bill Token",
|
||||
"Identifier": "USTBT",
|
||||
"Issuer": "US Treasury",
|
||||
"IssueDate": "2024-03-25",
|
||||
"MaturityDate": "2025-03-25",
|
||||
"FaceValue": 1000,
|
||||
"InterestRate": 2.5,
|
||||
"InterestFrequency": "Quarterly",
|
||||
"Collateral": "US Government",
|
||||
"Jurisdiction": "United States",
|
||||
"RegulatoryCompliance": "SEC Regulations",
|
||||
"SecurityType": "Treasury Bill",
|
||||
"ExternalUrl": "https://example.com/t-bill-token-metadata.json"
|
||||
}
|
||||
```
|
||||
Once you've set your preferred values, click **Generate Transaction** to see the transaction syntax for your settings. The `Flags` field displays the sum of the flags you've selected, and the `MPTokenMetadata` is converted to a hexidecimal string.
|
||||
|
||||

|
||||
|
||||
To create your T-bill MPT, click **Send Transaction**. When your transaction succeeds, a link to the record in the XRPL Explorer is displayed in the result field.
|
||||
|
||||

|
||||
|
||||
Follow the link and scroll down to find the `MPTokenIssuanceCreate` transaction for your new T-bill in the Explorer.
|
||||
|
||||

|
||||
|
||||
Click **Gather MPT Information** to copy the account information and MPT Issuance ID to the result field. Copy the information and save it to send the MPT to another account as shown in [Sending MPTs](../../tutorials/javascript/send-payments/sending-mpts.md).
|
||||
|
||||

|
||||
|
||||
{% raw-partial file="/docs/_snippets/common-links.md" /%}
|
||||
@@ -20,6 +20,10 @@ const useCases = [
|
||||
description: "NFT Marketplace",
|
||||
link: "/docs/use-cases/tokenization/nftoken-marketplace/",
|
||||
},
|
||||
{
|
||||
description: "Multi-purpose Token Issuer",
|
||||
link: "/docs/use-cases/tokenization/creating-an-asset-backed-multi-purpose-token"
|
||||
},
|
||||
{
|
||||
description: "Authorized Minter",
|
||||
link: "/docs/use-cases/tokenization/authorized-minter/",
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
---
|
||||
html: nft-mkt-overview.html
|
||||
parent: tokenization.html
|
||||
seo:
|
||||
description: Overview of NFT Marketplace use cases.
|
||||
labels:
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
- page: docs/use-cases/tokenization/authorized-minter.md
|
||||
- page: docs/use-cases/tokenization/digital-artist.md
|
||||
- page: docs/use-cases/tokenization/real-world-assets.page.tsx
|
||||
- page: docs/use-cases/tokenization/creating-an-asset-backed-multi-purpose-token.md
|
||||
- page: docs/use-cases/defi/index.md
|
||||
expanded: false
|
||||
items:
|
||||
@@ -192,6 +193,7 @@
|
||||
- page: docs/tutorials/javascript/send-payments/create-time-based-escrows.md
|
||||
- page: docs/tutorials/javascript/send-payments/create-conditional-escrows.md
|
||||
- page: docs/tutorials/javascript/send-payments/send-and-cash-checks.md
|
||||
- page: docs/tutorials/javascript/send-payments/sending-mpts.md
|
||||
- page: docs/tutorials/javascript/nfts/index.md
|
||||
expanded: false
|
||||
items:
|
||||
|
||||