Merge pull request #1911 from XRPLF/pythonQuickstart
Quickstart Python draft
@@ -1,7 +1,5 @@
|
||||
# Quickstart Samples Archive
|
||||
# Quickstart Samples
|
||||
|
||||
Create a test harness for XRPL features using 4 iterative HTML pages and accompanying JavaScript files.
|
||||
Create a test harness for XRPL features using JavaScript or Python.
|
||||
|
||||
Get up and running with the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/quickstart/js/quickstart.zip) archive, which includes 4 iterative HTML pages as a test harness for XRPL features, with accompanying JavaScript files. For the full explanation, see the [XRPL Quickstart Tutorial](https://xrpl.org/xrpl-quickstart.html).
|
||||
|
||||
Includes 3 bonus samples for Brokering NFToken Sales, Using an Authorized Minter, and Batch Minting.
|
||||
For the full explanation, see the XRPL Quickstart Tutorial.
|
||||
|
||||
228
content/_code-samples/quickstart/js/1.get-accounts-send-xrp.html
Normal file
@@ -0,0 +1,228 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Token Test Harness</title>
|
||||
<link href='https://fonts.googleapis.com/css?family=Work Sans' rel='stylesheet'>
|
||||
<style>
|
||||
body{font-family: "Work Sans", sans-serif;padding: 20px;background: #fafafa;}
|
||||
h1{font-weight: bold;}
|
||||
input, button {padding: 6px;margin-bottom: 8px;}
|
||||
button{font-weight: bold;font-family: "Work Sans", sans-serif;}
|
||||
td{vertical-align: middle;}
|
||||
</style>
|
||||
<script src='https://unpkg.com/xrpl@2.7.0/build/xrpl-latest-min.js'></script>
|
||||
<script src='ripplex1-send-xrp.js'></script>
|
||||
<script>
|
||||
if (typeof module !== "undefined") {
|
||||
const xrpl = require('xrpl')
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<!-- ************************************************************** -->
|
||||
<!-- ********************** The Form ****************************** -->
|
||||
<!-- ************************************************************** -->
|
||||
|
||||
<body>
|
||||
<h1>Token Test Harness</h1>
|
||||
<form id="theForm">
|
||||
Choose your ledger instance:
|
||||
|
||||
<input type="radio" id="tn" name="server"
|
||||
value="wss://s.altnet.rippletest.net:51233" checked>
|
||||
<label for="testnet">Testnet</label>
|
||||
|
||||
<input type="radio" id="dn" name="server"
|
||||
value="wss://s.devnet.rippletest.net:51233">
|
||||
<label for="devnet">Devnet</label>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="getAccountsFromSeeds()">Get Accounts From Seeds</button>
|
||||
<br/>
|
||||
<textarea id="seeds" cols="40" rows= "2"></textarea>
|
||||
<br/><br/>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<td>
|
||||
<button type="button" onClick="getAccount('standby')">Get New Standby Account</button>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td align="right">
|
||||
Standby Account
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyAccountField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Public Key
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyPubKeyField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Private Key
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyPrivKeyField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Seed
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbySeedField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
XRP Balance
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyBalanceField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Amount
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyAmountField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Destination
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyDestinationField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p align="right">
|
||||
<textarea id="standbyResultField" cols="80" rows="20" ></textarea>
|
||||
</p>
|
||||
</td>
|
||||
</td>
|
||||
<td>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td align="center" valign="top">
|
||||
<button type="button" onClick="sendXRP()">Send XRP></button>
|
||||
</td>
|
||||
</tr>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td align="center" valign="top">
|
||||
<button type="button" onClick="oPsendXRP()"><Send XRP</button>
|
||||
</td>
|
||||
<td align="right">
|
||||
<button type="button" onClick="getAccount('operational')">Get New Operational Account</button>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td align="right">
|
||||
Operational Account
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalAccountField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Public Key
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalPubKeyField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Private Key
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalPrivKeyField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Seed
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalSeedField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
XRP Balance
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalBalanceField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Amount
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalAmountField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Destination
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalDestinationField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p align="right">
|
||||
<textarea id="operationalResultField" cols="80" rows="20" ></textarea>
|
||||
</p>
|
||||
</td>
|
||||
</td>
|
||||
</tr>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,273 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Token Test Harness</title>
|
||||
<link href='https://fonts.googleapis.com/css?family=Work Sans' rel='stylesheet'>
|
||||
<style>
|
||||
body{font-family: "Work Sans", sans-serif;padding: 20px;background: #fafafa;}
|
||||
h1{font-weight: bold;}
|
||||
input, button {padding: 6px;margin-bottom: 8px;}
|
||||
button{font-weight: bold;font-family: "Work Sans", sans-serif;}
|
||||
td{vertical-align: middle;}
|
||||
</style>
|
||||
<script src='https://unpkg.com/xrpl@2.7.0/build/xrpl-latest-min.js'></script>
|
||||
<script src='ripplex1-send-xrp.js'></script>
|
||||
<script src='ripplex2-send-currency.js'></script>
|
||||
<script>
|
||||
if (typeof module !== "undefined") {
|
||||
const xrpl = require('xrpl')
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<!-- ************************************************************** -->
|
||||
<!-- ********************** The Form ****************************** -->
|
||||
<!-- ************************************************************** -->
|
||||
|
||||
<body>
|
||||
<h1>Token Test Harness</h1>
|
||||
<form id="theForm">
|
||||
Choose your ledger instance:
|
||||
|
||||
<input type="radio" id="tn" name="server"
|
||||
value="wss://s.altnet.rippletest.net:51233" checked>
|
||||
<label for="testnet">Testnet</label>
|
||||
|
||||
<input type="radio" id="dn" name="server"
|
||||
value="wss://s.devnet.rippletest.net:51233">
|
||||
<label for="devnet">Devnet</label>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="getAccountsFromSeeds()">Get Accounts From Seeds</button>
|
||||
<br/>
|
||||
<textarea id="seeds" cols="40" rows= "2"></textarea>
|
||||
<br/><br/>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<td>
|
||||
<button type="button" onClick="getAccount('standby')">Get New Standby Account</button>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td align="right">
|
||||
Standby Account
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyAccountField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Public Key
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyPubKeyField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Private Key
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyPrivKeyField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Seed
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbySeedField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
XRP Balance
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyBalanceField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Amount
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyAmountField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Destination
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyDestinationField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td><button type="button" onClick="configureAccount('standby',document.querySelector('#standbyDefault').checked)">Configure Account</button></td>
|
||||
<td>
|
||||
<input type="checkbox" id="standbyDefault" checked="true"/>
|
||||
<label for="standbyDefault">Allow Rippling</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Currency
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyCurrencyField" size="40" value="USD"></input>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p align="left">
|
||||
<textarea id="standbyResultField" cols="80" rows="20" ></textarea>
|
||||
</p>
|
||||
</td>
|
||||
</td>
|
||||
<td>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td align="center" valign="top">
|
||||
<button type="button" onClick="sendXRP()">Send XRP></button>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="createTrustline()">Create TrustLine</button>
|
||||
<br/>
|
||||
<button type="button" onClick="sendCurrency()">Send Currency</button>
|
||||
<br/>
|
||||
<button type="button" onClick="getBalances()">Get Balances</button>
|
||||
</td>
|
||||
</tr>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td align="center" valign="top">
|
||||
<button type="button" onClick="oPsendXRP()">< Send XRP</button>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="oPcreateTrustline()">Create TrustLine</button>
|
||||
<br/>
|
||||
<button type="button" onClick="oPsendCurrency()">Send Currency</button>
|
||||
<br/>
|
||||
<button type="button" onClick="getBalances()">Get Balances</button>
|
||||
</td>
|
||||
<td valign="top" align="right">
|
||||
<button type="button" onClick="getAccount('operational')">Get New Operational Account</button>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td align="right">
|
||||
Operational Account
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalAccountField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Public Key
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalPubKeyField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Private Key
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalPrivKeyField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Seed
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalSeedField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
XRP Balance
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalBalanceField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Amount
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalAmountField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Destination
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalDestinationField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
</td>
|
||||
<td align="right">
|
||||
<input type="checkbox" id="operationalDefault" checked="true"/>
|
||||
<label for="operationalDefault">Allow Rippling</label>
|
||||
<button type="button" onClick="configureAccount('operational',document.querySelector('#operationalDefault').checked)">Configure Account</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Currency
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalCurrencyField" size="40" value="USD"></input>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p align="right">
|
||||
<textarea id="operationalResultField" cols="80" rows="20" ></textarea>
|
||||
</p>
|
||||
</td>
|
||||
</td>
|
||||
</tr>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
320
content/_code-samples/quickstart/js/3.mint-nfts.html
Normal file
@@ -0,0 +1,320 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Token Test Harness</title>
|
||||
<link href='https://fonts.googleapis.com/css?family=Work Sans' rel='stylesheet'>
|
||||
<style>
|
||||
body{font-family: "Work Sans", sans-serif;padding: 20px;background: #fafafa;}
|
||||
h1{font-weight: bold;}
|
||||
input, button {padding: 6px;margin-bottom: 8px;}
|
||||
button{font-weight: bold;font-family: "Work Sans", sans-serif;}
|
||||
td{vertical-align: middle;}
|
||||
</style>
|
||||
<script src='https://unpkg.com/xrpl@2.7.0/build/xrpl-latest-min.js'></script>
|
||||
<script src='ripplex1-send-xrp.js'></script>
|
||||
<script src='ripplex2-send-currency.js'></script>
|
||||
<script src='ripplex3-mint-nfts.js'></script>
|
||||
<script>
|
||||
if (typeof module !== "undefined") {
|
||||
const xrpl = require('xrpl')
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<!-- ************************************************************** -->
|
||||
<!-- ********************** The Form ****************************** -->
|
||||
<!-- ************************************************************** -->
|
||||
|
||||
<body>
|
||||
<h1>Token Test Harness</h1>
|
||||
<form id="theForm">
|
||||
Choose your ledger instance:
|
||||
|
||||
<input type="radio" id="tn" name="server"
|
||||
value="wss://s.altnet.rippletest.net:51233" checked>
|
||||
<label for="testnet">Testnet</label>
|
||||
|
||||
<input type="radio" id="dn" name="server"
|
||||
value="wss://s.devnet.rippletest.net:51233">
|
||||
<label for="devnet">Devnet</label>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="getAccountsFromSeeds()">Get Accounts From Seeds</button>
|
||||
<br/>
|
||||
<textarea id="seeds" cols="40" rows= "2"></textarea>
|
||||
<br/><br/>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<td>
|
||||
<button type="button" onClick="getAccount('standby')">Get New Standby Account</button>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td align="right">
|
||||
Standby Account
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyAccountField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Public Key
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyPubKeyField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Private Key
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyPrivKeyField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Seed
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbySeedField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
XRP Balance
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyBalanceField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Amount
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyAmountField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Destination
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyDestinationField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td><button type="button" onClick="configureAccount('standby',document.querySelector('#standbyDefault').checked)">Configure Account</button></td>
|
||||
<td>
|
||||
<input type="checkbox" id="standbyDefault" checked="true"/>
|
||||
<label for="standbyDefault">Allow Rippling</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Currency
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyCurrencyField" size="40" value="USD"></input>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFT URL</td>
|
||||
<td><input type="text" id="standbyTokenUrlField"
|
||||
value = "ipfs://bafybeigdyrzt5sfp7udm7hu76uh7y26nf4dfuylqabf3oclgtqy55fbzdi" size="80"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">Flags</td>
|
||||
<td><input type="text" id="standbyFlagsField" value="1" size="10"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFT ID</td>
|
||||
<td><input type="text" id="standbyTokenIdField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">Transfer Fee</td>
|
||||
<td><input type="text" id="standbyTransferFeeField" value="" size="80"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
<p align="left">
|
||||
<textarea id="standbyResultField" cols="80" rows="20" ></textarea>
|
||||
</p>
|
||||
</td>
|
||||
</td>
|
||||
<td>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td align="center" valign="top">
|
||||
<button type="button" onClick="sendXRP()">Send XRP></button>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="createTrustline()">Create TrustLine</button>
|
||||
<br/>
|
||||
<button type="button" onClick="sendCurrency()">Send Currency</button>
|
||||
<br/>
|
||||
<button type="button" onClick="getBalances()">Get Balances</button>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="mintToken()">Mint NFT</button>
|
||||
<br/>
|
||||
<button type="button" onClick="getTokens()">Get NFTs</button>
|
||||
<br/>
|
||||
<button type="button" onClick="burnToken()">Burn NFT</button>
|
||||
</td>
|
||||
</tr>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td align="center" valign="top">
|
||||
<button type="button" onClick="oPsendXRP()">< Send XRP</button>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="oPcreateTrustline()">Create TrustLine</button>
|
||||
<br/>
|
||||
<button type="button" onClick="oPsendCurrency()">Send Currency</button>
|
||||
<br/>
|
||||
<button type="button" onClick="getBalances()">Get Balances</button>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="oPmintToken()">Mint NFT</button>
|
||||
<br/>
|
||||
<button type="button" onClick="oPgetTokens()">Get NFTs</button>
|
||||
<br/>
|
||||
<button type="button" onClick="oPburnToken()">Burn NFT</button>
|
||||
<td valign="top" align="right">
|
||||
<button type="button" onClick="getAccount('operational')">Get New Operational Account</button>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td align="right">
|
||||
Operational Account
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalAccountField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Public Key
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalPubKeyField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Private Key
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalPrivKeyField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Seed
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalSeedField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
XRP Balance
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalBalanceField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Amount
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalAmountField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Destination
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalDestinationField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
</td>
|
||||
<td align="right"> <input type="checkbox" id="operationalDefault" checked="true"/>
|
||||
<label for="operationalDefault">Allow Rippling</label>
|
||||
<button type="button" onClick="configureAccount('operational',document.querySelector('#operationalDefault').checked)">Configure Account</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Currency
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalCurrencyField" size="40" value="USD"></input>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFT URL</td>
|
||||
<td><input type="text" id="operationalTokenUrlField"
|
||||
value = "ipfs://bafybeigdyrzt5sfp7udm7hu76uh7y26nf4dfuylqabf3oclgtqy55fbzdi" size="80"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">Flags</td>
|
||||
<td><input type="text" id="operationalFlagsField" value="1" size="10"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFT ID</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>
|
||||
</table>
|
||||
<p align="right">
|
||||
<textarea id="operationalResultField" cols="80" rows="20" ></textarea>
|
||||
</p>
|
||||
</td>
|
||||
</td>
|
||||
</tr>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
361
content/_code-samples/quickstart/js/4.transfer-nfts.html
Normal file
@@ -0,0 +1,361 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Token Test Harness</title>
|
||||
<link href='https://fonts.googleapis.com/css?family=Work Sans' rel='stylesheet'>
|
||||
<style>
|
||||
body{font-family: "Work Sans", sans-serif;padding: 20px;background: #fafafa;}
|
||||
h1{font-weight: bold;}
|
||||
input, button {padding: 6px;margin-bottom: 8px;}
|
||||
button{font-weight: bold;font-family: "Work Sans", sans-serif;}
|
||||
td{vertical-align: middle;}
|
||||
</style>
|
||||
<script src='https://unpkg.com/xrpl@2.7.0/build/xrpl-latest-min.js'></script>
|
||||
<script src='ripplex1-send-xrp.js'></script>
|
||||
<script src='ripplex2-send-currency.js'></script>
|
||||
<script src='ripplex3-mint-nfts.js'></script>
|
||||
<script src='ripplex4-transfer-nfts.js'></script>
|
||||
<script>
|
||||
if (typeof module !== "undefined") {
|
||||
const xrpl = require('xrpl')
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<!-- ************************************************************** -->
|
||||
<!-- ********************** The Form ****************************** -->
|
||||
<!-- ************************************************************** -->
|
||||
|
||||
<body>
|
||||
<h1>Token Test Harness</h1>
|
||||
<form id="theForm">
|
||||
Choose your ledger instance:
|
||||
|
||||
<input type="radio" id="tn" name="server"
|
||||
value="wss://s.altnet.rippletest.net:51233" checked>
|
||||
<label for="testnet">Testnet</label>
|
||||
|
||||
<input type="radio" id="dn" name="server"
|
||||
value="wss://s.devnet.rippletest.net:51233">
|
||||
<label for="devnet">Devnet</label>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="getAccountsFromSeeds()">Get Accounts From Seeds</button>
|
||||
<br/>
|
||||
<textarea id="seeds" cols="40" rows= "2"></textarea>
|
||||
<br/><br/>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<td>
|
||||
<button type="button" onClick="getAccount('standby')">Get New Standby Account</button>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td align="right">
|
||||
Standby Account
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyAccountField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Public Key
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyPubKeyField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Private Key
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyPrivKeyField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Seed
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbySeedField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
XRP Balance
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyBalanceField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Amount
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyAmountField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td><button type="button" onClick="configureAccount('standby',document.querySelector('#standbyDefault').checked)">Configure Account</button></td>
|
||||
<td>
|
||||
<input type="checkbox" id="standbyDefault" checked="true"/>
|
||||
<label for="standbyDefault">Allow Rippling</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Currency
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyCurrencyField" size="40" value="USD"></input>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFT URL</td>
|
||||
<td><input type="text" id="standbyTokenUrlField"
|
||||
value = "ipfs://bafybeigdyrzt5sfp7udm7hu76uh7y26nf4dfuylqabf3oclgtqy55fbzdi" size="80"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">Flags</td>
|
||||
<td><input type="text" id="standbyFlagsField" value="1" size="10"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFT ID</td>
|
||||
<td><input type="text" id="standbyTokenIdField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFT Offer Index</td>
|
||||
<td><input type="text" id="standbyTokenOfferIndexField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">Owner</td>
|
||||
<td><input type="text" id="standbyOwnerField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">Destination</td>
|
||||
<td><input type="text" id="standbyDestinationField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">Expiration</td>
|
||||
<td><input type="text" id="standbyExpirationField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">Transfer Fee</td>
|
||||
<td><input type="text" id="standbyTransferFeeField" value="" size="80"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
<p align="left">
|
||||
<textarea id="standbyResultField" cols="80" rows="20" ></textarea>
|
||||
</p>
|
||||
</td>
|
||||
</td>
|
||||
<td>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td align="center" valign="top">
|
||||
<button type="button" onClick="sendXRP()">Send XRP></button>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="createTrustline()">Create TrustLine</button>
|
||||
<br/>
|
||||
<button type="button" onClick="sendCurrency()">Send Currency</button>
|
||||
<br/>
|
||||
<button type="button" onClick="getBalances()">Get Balances</button>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="mintToken()">Mint NFT</button>
|
||||
<br/>
|
||||
<button type="button" onClick="getTokens()">Get NFTs</button>
|
||||
<br/>
|
||||
<button type="button" onClick="burnToken()">Burn NFT</button>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="createSellOffer()">Create Sell Offer</button>
|
||||
<br/>
|
||||
<button type="button" onClick="acceptSellOffer()">Accept Sell Offer</button>
|
||||
<br/>
|
||||
<button type="button" onClick="createBuyOffer()">Create Buy Offer</button>
|
||||
<br/>
|
||||
<button type="button" onClick="acceptBuyOffer()">Accept Buy Offer</button>
|
||||
<br/>
|
||||
<button type="button" onClick="getOffers()">Get Offers</button>
|
||||
<br/>
|
||||
<button type="button" onClick="cancelOffer()">Cancel Offer</button>
|
||||
</td>
|
||||
</tr>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td align="center" valign="top">
|
||||
<button type="button" onClick="oPsendXRP()">< Send XRP</button>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="oPcreateTrustline()">Create TrustLine</button>
|
||||
<br/>
|
||||
<button type="button" onClick="oPsendCurrency()">Send Currency</button>
|
||||
<br/>
|
||||
<button type="button" onClick="getBalances()">Get Balances</button>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="oPmintToken()">Mint NFT</button>
|
||||
<br/>
|
||||
<button type="button" onClick="oPgetTokens()">Get NFTs</button>
|
||||
<br/>
|
||||
<button type="button" onClick="oPburnToken()">Burn NFT</button>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="oPcreateSellOffer()">Create Sell Offer</button>
|
||||
<br/>
|
||||
<button type="button" onClick="oPacceptSellOffer()">Accept Sell Offer</button>
|
||||
<br/>
|
||||
<button type="button" onClick="oPcreateBuyOffer()">Create Buy Offer</button>
|
||||
<br/>
|
||||
<button type="button" onClick="oPacceptBuyOffer()">Accept Buy Offer</button>
|
||||
<br/>
|
||||
<button type="button" onClick="oPgetOffers()">Get Offers</button>
|
||||
<br/>
|
||||
<button type="button" onClick="oPcancelOffer()">Cancel Offer</button>
|
||||
</td>
|
||||
<td valign="top" align="right">
|
||||
<button type="button" onClick="getAccount('operational')">Get New Operational Account</button>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td align="right">
|
||||
Operational Account
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalAccountField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Public Key
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalPubKeyField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Private Key
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalPrivKeyField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Seed
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalSeedField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
XRP Balance
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalBalanceField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Amount
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalAmountField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
</td>
|
||||
<td align="right"> <input type="checkbox" id="operationalDefault" checked="true"/>
|
||||
<label for="operationalDefault">Allow Rippling</label>
|
||||
<button type="button" onClick="configureAccount('operational',document.querySelector('#operationalDefault').checked)">Configure Account</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Currency
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalCurrencyField" size="40" value="USD"></input>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFT URL</td>
|
||||
<td><input type="text" id="operationalTokenUrlField"
|
||||
value = "ipfs://bafybeigdyrzt5sfp7udm7hu76uh7y26nf4dfuylqabf3oclgtqy55fbzdi" size="80"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">Flags</td>
|
||||
<td><input type="text" id="operationalFlagsField" value="1" size="10"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFT ID</td>
|
||||
<td><input type="text" id="operationalTokenIdField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFT Offer Index</td>
|
||||
<td><input type="text" id="operationalTokenOfferIndexField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">Owner</td>
|
||||
<td><input type="text" id="operationalOwnerField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">Destination</td>
|
||||
<td><input type="text" id="operationalDestinationField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">Expiration</td>
|
||||
<td><input type="text" id="operationalExpirationField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">Transfer Fee</td>
|
||||
<td><input type="text" id="operationalTransferFeeField" value="" size="80"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
<p align="right">
|
||||
<textarea id="operationalResultField" cols="80" rows="20" ></textarea>
|
||||
</p>
|
||||
</td>
|
||||
</td>
|
||||
</tr>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
447
content/_code-samples/quickstart/js/5.broker-nfts.html
Normal file
@@ -0,0 +1,447 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Token Test Harness</title>
|
||||
<link href='https://fonts.googleapis.com/css?family=Work Sans' rel='stylesheet'>
|
||||
<style>
|
||||
body{font-family: "Work Sans", sans-serif;padding: 20px;background: #fafafa;}
|
||||
h1{font-weight: bold;}
|
||||
input, button {padding: 6px;margin-bottom: 8px;}
|
||||
button{font-weight: bold;font-family: "Work Sans", sans-serif;}
|
||||
td{vertical-align: middle;}
|
||||
</style>
|
||||
<script src='https://unpkg.com/xrpl@2.7.0/build/xrpl-latest-min.js'></script>
|
||||
<script src='ripplex1-send-xrp.js'></script>
|
||||
<script src='ripplex2-send-currency.js'></script>
|
||||
<script src='ripplex3-mint-nfts.js'></script>
|
||||
<script src='ripplex4-transfer-nfts.js'></script>
|
||||
<script src='ripplex5-broker-nfts.js'></script>
|
||||
<script>
|
||||
if (typeof module !== "undefined") {
|
||||
const xrpl = require('xrpl')
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- ************************************************************** -->
|
||||
<!-- ********************** The Form ****************************** -->
|
||||
<!-- ************************************************************** -->
|
||||
|
||||
<body>
|
||||
<h1>Token Test Harness</h1>
|
||||
<form id="theForm">
|
||||
Choose your ledger instance:
|
||||
|
||||
<input type="radio" id="tn" name="server"
|
||||
value="wss://s.altnet.rippletest.net:51233" checked>
|
||||
<label for="testnet">Testnet</label>
|
||||
|
||||
<input type="radio" id="dn" name="server"
|
||||
value="wss://s.devnet.rippletest.net:51233">
|
||||
<label for="devnet">Devnet</label>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="getAccountsFromSeeds()">Get Accounts From Seeds</button>
|
||||
<br/>
|
||||
<textarea id="seeds" cols="40" rows= "3"></textarea>
|
||||
<br/><br/>
|
||||
<table align="center">
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<button type="button" onClick="getAccount('broker')">Get New Broker Account</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right">
|
||||
Broker Account
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="brokerAccountField" size="40"></input>
|
||||
<button type="button" id="another" onclick="brokerSale()">Broker Sale</button>
|
||||
</td>
|
||||
<td rowspan="7">
|
||||
<textarea id="brokerResultField" cols="40" rows="12"></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Public Key
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="brokerPubKeyField" size="40"></input>
|
||||
<button type="button" onClick="brGetOffers()">Get Offers</button>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Private Key
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="brokerPrivKeyField" size="40"></input>
|
||||
<button type="button" onClick="brCancelOffer()">Cancel Offer</button>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Seed
|
||||
<br>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="brokerSeedField" size="40"></input>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
XRP Balance
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="brokerBalanceField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Amount
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="brokerAmountField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFT ID</td>
|
||||
<td><input type="text" id="brokerTokenIdField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">Sell NFT Offer Index</td>
|
||||
<td><input type="text" id="brokerTokenSellOfferIndexField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">Buy NFT Offer Index</td>
|
||||
<td><input type="text" id="brokerTokenBuyOfferIndexField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">Owner</td>
|
||||
<td><input type="text" id="brokerOwnerField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">Broker Fee</td>
|
||||
<td><input type="text" id="brokerBrokerFeeField" value="" size="80"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
<br/><br/>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<td>
|
||||
<button type="button" onClick="getAccount('standby')">Get New Standby Account</button>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td align="right">
|
||||
Standby Account
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyAccountField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Public Key
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyPubKeyField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Private Key
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyPrivKeyField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Seed
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbySeedField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
XRP Balance
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyBalanceField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Amount
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyAmountField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td><button type="button" onClick="configureAccount('standby',document.querySelector('#standbyDefault').checked)">Configure Account</button></td>
|
||||
<td>
|
||||
<input type="checkbox" id="standbyDefault" checked="true"/>
|
||||
<label for="standbyDefault">Allow Rippling</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Currency
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyCurrencyField" size="40" value="USD"></input>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFT URL</td>
|
||||
<td><input type="text" id="standbyTokenUrlField"
|
||||
value = "ipfs://bafybeigdyrzt5sfp7udm7hu76uh7y26nf4dfuylqabf3oclgtqy55fbzdi" size="80"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">Flags</td>
|
||||
<td><input type="text" id="standbyFlagsField" value="1" size="10"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFT ID</td>
|
||||
<td><input type="text" id="standbyTokenIdField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFT Offer Index</td>
|
||||
<td><input type="text" id="standbyTokenOfferIndexField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">Owner</td>
|
||||
<td><input type="text" id="standbyOwnerField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">Destination</td>
|
||||
<td><input type="text" id="standbyDestinationField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">Expiration</td>
|
||||
<td><input type="text" id="standbyExpirationField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">Transfer Fee</td>
|
||||
<td><input type="text" id="standbyTransferFeeField" value="" size="80"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
<p align="left">
|
||||
<textarea id="standbyResultField" cols="80" rows="20" ></textarea>
|
||||
</p>
|
||||
</td>
|
||||
</td>
|
||||
<td>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td align="center" valign="top">
|
||||
<button type="button" onClick="sendXRP()">Send XRP></button>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="createTrustline()">Create TrustLine</button>
|
||||
<br/>
|
||||
<button type="button" onClick="sendCurrency()">Send Currency</button>
|
||||
<br/>
|
||||
<button type="button" onClick="getBalances()">Get Balances</button>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="mintToken()">Mint NFT</button>
|
||||
<br/>
|
||||
<button type="button" onClick="getTokens()">Get NFTs</button>
|
||||
<br/>
|
||||
<button type="button" onClick="burnToken()">Burn NFT</button>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="createSellOffer()">Create Sell Offer</button>
|
||||
<br/>
|
||||
<button type="button" onClick="acceptSellOffer()">Accept Sell Offer</button>
|
||||
<br/>
|
||||
<button type="button" onClick="createBuyOffer()">Create Buy Offer</button>
|
||||
<br/>
|
||||
<button type="button" onClick="acceptBuyOffer()">Accept Buy Offer</button>
|
||||
<br/>
|
||||
<button type="button" onClick="getOffers()">Get Offers</button>
|
||||
<br/>
|
||||
<button type="button" onClick="cancelOffer()">Cancel Offer</button>
|
||||
</td>
|
||||
</tr>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td align="center" valign="top">
|
||||
<button type="button" onClick="oPsendXRP()">< Send XRP</button>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="oPcreateTrustline()">Create TrustLine</button>
|
||||
<br/>
|
||||
<button type="button" onClick="oPsendCurrency()">Send Currency</button>
|
||||
<br/>
|
||||
<button type="button" onClick="getBalances()">Get Balances</button>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="oPmintToken()">Mint NFT</button>
|
||||
<br/>
|
||||
<button type="button" onClick="oPgetTokens()">Get NFTs</button>
|
||||
<br/>
|
||||
<button type="button" onClick="oPburnToken()">Burn NFT</button>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="oPcreateSellOffer()">Create Sell Offer</button>
|
||||
<br/>
|
||||
<button type="button" onClick="oPacceptSellOffer()">Accept Sell Offer</button>
|
||||
<br/>
|
||||
<button type="button" onClick="oPcreateBuyOffer()">Create Buy Offer</button>
|
||||
<br/>
|
||||
<button type="button" onClick="oPacceptBuyOffer()">Accept Buy Offer</button>
|
||||
<br/>
|
||||
<button type="button" onClick="oPgetOffers()">Get Offers</button>
|
||||
<br/>
|
||||
<button type="button" onClick="oPcancelOffer()">Cancel Offer</button>
|
||||
</td>
|
||||
<td valign="top" align="right">
|
||||
<button type="button" onClick="getAccount('operational')">Get New Operational Account</button>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td align="right">
|
||||
Operational Account
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalAccountField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Public Key
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalPubKeyField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Private Key
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalPrivKeyField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Seed
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalSeedField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
XRP Balance
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalBalanceField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Amount
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalAmountField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
</td>
|
||||
<td align="right"> <input type="checkbox" id="operationalDefault" checked="true"/>
|
||||
<label for="operationalDefault">Allow Rippling</label>
|
||||
<button type="button" onClick="configureAccount('operational',document.querySelector('#operationalDefault').checked)">Configure Account</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Currency
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalCurrencyField" size="40" value="USD"></input>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFT URL</td>
|
||||
<td><input type="text" id="operationalTokenUrlField"
|
||||
value = "ipfs://bafybeigdyrzt5sfp7udm7hu76uh7y26nf4dfuylqabf3oclgtqy55fbzdi" size="80"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">Flags</td>
|
||||
<td><input type="text" id="operationalFlagsField" value="1" size="10"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFT ID</td>
|
||||
<td><input type="text" id="operationalTokenIdField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFT Offer Index</td>
|
||||
<td><input type="text" id="operationalTokenOfferIndexField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">Owner</td>
|
||||
<td><input type="text" id="operationalOwnerField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">Destination</td>
|
||||
<td><input type="text" id="operationalDestinationField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">Expiration</td>
|
||||
<td><input type="text" id="operationalExpirationField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">Transfer Fee</td>
|
||||
<td><input type="text" id="operationalTransferFeeField" value="" size="80"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
<p align="right">
|
||||
<textarea id="operationalResultField" cols="80" rows="20" ></textarea>
|
||||
</p>
|
||||
</td>
|
||||
</td>
|
||||
</tr>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
386
content/_code-samples/quickstart/js/6.authorized-minter.html
Normal file
@@ -0,0 +1,386 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Token Test Harness</title>
|
||||
<link href='https://fonts.googleapis.com/css?family=Work Sans' rel='stylesheet'>
|
||||
<style>
|
||||
body{font-family: "Work Sans", sans-serif;padding: 20px;background: #fafafa;}
|
||||
h1{font-weight: bold;}
|
||||
input, button {padding: 6px;margin-bottom: 8px;}
|
||||
button{font-weight: bold;font-family: "Work Sans", sans-serif;}
|
||||
td{vertical-align: middle;}
|
||||
</style>
|
||||
<script src='https://unpkg.com/xrpl@2.7.0/build/xrpl-latest-min.js'></script>
|
||||
<script src='ripplex1-send-xrp.js'></script>
|
||||
<script src='ripplex2-send-currency.js'></script>
|
||||
<script src='ripplex3-mint-nfts.js'></script>
|
||||
<script src='ripplex4-transfer-nfts.js'></script>
|
||||
<script src='ripplex6-authorized-minter.js'></script>
|
||||
<script>
|
||||
if (typeof module !== "undefined") {
|
||||
const xrpl = require('xrpl')
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<!-- ************************************************************** -->
|
||||
<!-- ********************** The Form ****************************** -->
|
||||
<!-- ************************************************************** -->
|
||||
|
||||
<body>
|
||||
<h1>Token Test Harness</h1>
|
||||
<form id="theForm">
|
||||
Choose your ledger instance:
|
||||
|
||||
<input type="radio" id="tn" name="server"
|
||||
value="wss://s.altnet.rippletest.net:51233" checked>
|
||||
<label for="testnet">Testnet</label>
|
||||
|
||||
<input type="radio" id="dn" name="server"
|
||||
value="wss://s.devnet.rippletest.net:51233">
|
||||
<label for="devnet">Devnet</label>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="getAccountsFromSeeds()">Get Accounts From Seeds</button>
|
||||
<br/>
|
||||
<textarea id="seeds" cols="40" rows= "2"></textarea>
|
||||
<br/><br/>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<td>
|
||||
<button type="button" onClick="getAccount('standby')">Get New Standby Account</button>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td align="right">
|
||||
Standby Account
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyAccountField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Public Key
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyPubKeyField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Private Key
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyPrivKeyField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Seed
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbySeedField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
XRP Balance
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyBalanceField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Amount
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyAmountField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td><button type="button" onClick="configureAccount('standby',document.querySelector('#standbyDefault').checked)">Configure Account</button></td>
|
||||
<td>
|
||||
<input type="checkbox" id="standbyDefault" checked="true"/>
|
||||
<label for="standbyDefault">Allow Rippling</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Currency
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyCurrencyField" size="40" value="USD"></input>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFT URL</td>
|
||||
<td><input type="text" id="standbyTokenUrlField"
|
||||
value = "ipfs://bafybeigdyrzt5sfp7udm7hu76uh7y26nf4dfuylqabf3oclgtqy55fbzdi" size="80"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">Flags</td>
|
||||
<td><input type="text" id="standbyFlagsField" value="1" size="10"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFT ID</td>
|
||||
<td><input type="text" id="standbyTokenIdField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFT Offer Index</td>
|
||||
<td><input type="text" id="standbyTokenOfferIndexField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">Owner</td>
|
||||
<td><input type="text" id="standbyOwnerField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">Authorized Minter</td>
|
||||
<td><input type="text" id="standbyMinterField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">Issuer</td>
|
||||
<td><input type="text" id="standbyIssuerField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">Destination</td>
|
||||
<td><input type="text" id="standbyDestinationField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">Expiration</td>
|
||||
<td><input type="text" id="standbyExpirationField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">Transfer Fee</td>
|
||||
<td><input type="text" id="standbyTransferFeeField" value="" size="80"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
<p align="left">
|
||||
<textarea id="standbyResultField" cols="80" rows="20" ></textarea>
|
||||
</p>
|
||||
</td>
|
||||
</td>
|
||||
<td>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td align="center" valign="top">
|
||||
<button type="button" onClick="sendXRP()">Send XRP></button>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="createTrustline()">Create TrustLine</button>
|
||||
<br/>
|
||||
<button type="button" onClick="sendCurrency()">Send Currency</button>
|
||||
<br/>
|
||||
<button type="button" onClick="getBalances()">Get Balances</button>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="mintToken()">Mint NFT</button>
|
||||
<br/>
|
||||
<button type="button" onClick="getTokens()">Get NFTs</button>
|
||||
<br/>
|
||||
<button type="button" onClick="burnToken()">Burn NFT</button>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="setMinter('standby')">Set Minter</button>
|
||||
<br/>
|
||||
<button type="button" onClick="mintOther()">Mint Other</button>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="createSellOffer()">Create Sell Offer</button>
|
||||
<br/>
|
||||
<button type="button" onClick="acceptSellOffer()">Accept Sell Offer</button>
|
||||
<br/>
|
||||
<button type="button" onClick="createBuyOffer()">Create Buy Offer</button>
|
||||
<br/>
|
||||
<button type="button" onClick="acceptBuyOffer()">Accept Buy Offer</button>
|
||||
<br/>
|
||||
<button type="button" onClick="getOffers()">Get Offers</button>
|
||||
<br/>
|
||||
<button type="button" onClick="cancelOffer()">Cancel Offer</button>
|
||||
</td>
|
||||
</tr>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td align="center" valign="top">
|
||||
<button type="button" onClick="oPsendXRP()">< Send XRP</button>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="oPcreateTrustline()">Create TrustLine</button>
|
||||
<br/>
|
||||
<button type="button" onClick="oPsendCurrency()">Send Currency</button>
|
||||
<br/>
|
||||
<button type="button" onClick="getBalances()">Get Balances</button>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="oPmintToken()">Mint NFT</button>
|
||||
<br/>
|
||||
<button type="button" onClick="oPgetTokens()">Get NFTs</button>
|
||||
<br/>
|
||||
<button type="button" onClick="oPburnToken()">Burn NFT</button>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="oPsetMinter()">Set Minter</button>
|
||||
<br/>
|
||||
<button type="button" onClick="oPmintOther()">Mint Other</button>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="oPcreateSellOffer()">Create Sell Offer</button>
|
||||
<br/>
|
||||
<button type="button" onClick="oPacceptSellOffer()">Accept Sell Offer</button>
|
||||
<br/>
|
||||
<button type="button" onClick="oPcreateBuyOffer()">Create Buy Offer</button>
|
||||
<br/>
|
||||
<button type="button" onClick="oPacceptBuyOffer()">Accept Buy Offer</button>
|
||||
<br/>
|
||||
<button type="button" onClick="oPgetOffers()">Get Offers</button>
|
||||
<br/>
|
||||
<button type="button" onClick="oPcancelOffer()">Cancel Offer</button>
|
||||
</td>
|
||||
<td valign="top" align="right">
|
||||
<button type="button" onClick="getAccount('operational')">Get New Operational Account</button>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td align="right">
|
||||
Operational Account
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalAccountField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Public Key
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalPubKeyField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Private Key
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalPrivKeyField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Seed
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalSeedField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
XRP Balance
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalBalanceField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Amount
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalAmountField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
</td>
|
||||
<td align="right"> <input type="checkbox" id="operationalDefault" checked="true"/>
|
||||
<label for="operationalDefault">Allow Rippling</label>
|
||||
<button type="button" onClick="configureAccount('operational',document.querySelector('#operationalDefault').checked)">Configure Account</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Currency
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="operationalCurrencyField" size="40" value="USD"></input>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFT URL</td>
|
||||
<td><input type="text" id="operationalTokenUrlField"
|
||||
value = "ipfs://bafybeigdyrzt5sfp7udm7hu76uh7y26nf4dfuylqabf3oclgtqy55fbzdi" size="80"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">Flags</td>
|
||||
<td><input type="text" id="operationalFlagsField" value="1" size="10"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFT ID</td>
|
||||
<td><input type="text" id="operationalTokenIdField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFT Offer Index</td>
|
||||
<td><input type="text" id="operationalTokenOfferIndexField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">Owner</td>
|
||||
<td><input type="text" id="operationalOwnerField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">Authorized Minter</td>
|
||||
<td><input type="text" id="operationalMinterField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">Issuer</td>
|
||||
<td><input type="text" id="operationalIssuerField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">Destination</td>
|
||||
<td><input type="text" id="operationalDestinationField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">Expiration</td>
|
||||
<td><input type="text" id="operationalExpirationField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">Transfer Fee</td>
|
||||
<td><input type="text" id="operationalTransferFeeField" value="" size="80"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
<p align="right">
|
||||
<textarea id="operationalResultField" cols="80" rows="20" ></textarea>
|
||||
</p>
|
||||
</td>
|
||||
</td>
|
||||
</tr>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
157
content/_code-samples/quickstart/js/7.batch-minting.html
Normal file
@@ -0,0 +1,157 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Token Test Harness</title>
|
||||
<link href='https://fonts.googleapis.com/css?family=Work Sans' rel='stylesheet'>
|
||||
<style>
|
||||
body{font-family: "Work Sans", sans-serif;padding: 20px;background: #fafafa;}
|
||||
h1{font-weight: bold;}
|
||||
input, button {padding: 6px;margin-bottom: 8px;}
|
||||
button{font-weight: bold;font-family: "Work Sans", sans-serif;}
|
||||
td{vertical-align: middle;}
|
||||
</style>
|
||||
<script src='https://unpkg.com/xrpl@2.7.0/build/xrpl-latest-min.js'></script>
|
||||
<script src='ripplex1-send-xrp.js'></script>
|
||||
<script src='ripplex3-mint-nfts.js'></script>
|
||||
<script src='ripplex7-batch-minting.js'></script>
|
||||
<script>
|
||||
if (typeof module !== "undefined") {
|
||||
const xrpl = require('xrpl')
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<!-- ************************************************************** -->
|
||||
<!-- ********************** The Form ****************************** -->
|
||||
<!-- ************************************************************** -->
|
||||
|
||||
<body>
|
||||
<h1>Token Test Harness</h1>
|
||||
<form id="theForm">
|
||||
Choose your ledger instance:
|
||||
|
||||
<input type="radio" id="tn" name="server"
|
||||
value="wss://s.altnet.rippletest.net:51233" checked>
|
||||
<label for="testnet">Testnet</label>
|
||||
|
||||
<input type="radio" id="dn" name="server"
|
||||
value="wss://s.devnet.rippletest.net:51233">
|
||||
<label for="devnet">Devnet</label>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="getAccountFromSeed()">Get Account From Seed</button>
|
||||
<br/>
|
||||
<textarea id="seeds" cols="40" rows= "1" maxlength="524,288"></textarea>
|
||||
<br/><br/>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<button type="button" onClick="getAccount('standby')">Get New Standby Account</button>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td align="right">
|
||||
Standby Account
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyAccountField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Public Key
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyPubKeyField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Private Key
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyPrivKeyField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Seed
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbySeedField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
XRP Balance
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyBalanceField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td><button type="button" onClick="configureAccount('standby',document.querySelector('#standbyDefault').checked)">Configure Account</button></td>
|
||||
<td>
|
||||
<input type="checkbox" id="standbyDefault" checked="true"/>
|
||||
<label for="standbyDefault">Allow Rippling</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Currency
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyCurrencyField" size="40" value="USD"></input>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFT URL</td>
|
||||
<td><input type="text" id="standbyTokenUrlField"
|
||||
value = "ipfs://bafybeigdyrzt5sfp7udm7hu76uh7y26nf4dfuylqabf3oclgtqy55fbzdi" size="80"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">Flags</td>
|
||||
<td><input type="text" id="standbyFlagsField" value="8" size="10"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFT ID</td>
|
||||
<td><input type="text" id="standbyTokenIdField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
NFT Count
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyNFTCountField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">Transfer Fee</td>
|
||||
<td><input type="text" id="standbyTransferFeeField" value="" size="80"/></td>
|
||||
</tr>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td align="left" valign="top">
|
||||
<button type="button" onClick="batchMint()">Batch Mint</button>
|
||||
<br/>
|
||||
<button type="button" onClick="getBatchNFTs()">Get Batch NFTs</button>
|
||||
<br/>
|
||||
<p align="left">
|
||||
|
||||
<!-- Note the increased maxlength to hold the most possible NFT info. -->
|
||||
|
||||
<textarea id="standbyResultField" cols="80" rows="20" maxlength="524288"></textarea>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
5
content/_code-samples/quickstart/js/ReadMe.md
Normal file
@@ -0,0 +1,5 @@
|
||||
# Quickstart JavaScript Examples
|
||||
|
||||
Run a test harness for XRPL features using HTML UI and JavaScript module files.
|
||||
|
||||
The examples are iterative, building one on another to gradually introduce new behavior. For a full explanation, see the XRPL Quickstart Tutorial (JavaScript).
|
||||
207
content/_code-samples/quickstart/js/ripplex1-send-xrp.js
Normal file
@@ -0,0 +1,207 @@
|
||||
// ******************************************************
|
||||
// ************* 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(type) {
|
||||
let net = getNet()
|
||||
|
||||
const client = new xrpl.Client(net)
|
||||
results = 'Connecting to ' + net + '....'
|
||||
|
||||
// This uses the default faucet for Testnet/Devnet
|
||||
let faucetHost = null
|
||||
|
||||
if (type == 'standby') {
|
||||
standbyResultField.value = results
|
||||
} else {
|
||||
operationalResultField.value = results
|
||||
}
|
||||
await client.connect()
|
||||
|
||||
results += '\nConnected, funding wallet.'
|
||||
if (type == 'standby') {
|
||||
standbyResultField.value = results
|
||||
} else {
|
||||
operationalResultField.value = results
|
||||
}
|
||||
|
||||
// -----------------------------------Create and fund a test account wallet
|
||||
const my_wallet = (await client.fundWallet(null, { faucetHost })).wallet
|
||||
|
||||
results += '\nGot a wallet.'
|
||||
if (type == 'standby') {
|
||||
standbyResultField.value = results
|
||||
} else {
|
||||
operationalResultField.value = results
|
||||
}
|
||||
|
||||
// ------------------------------------------------------Get the current balance.
|
||||
const my_balance = (await client.getXrpBalance(my_wallet.address))
|
||||
|
||||
if (type == 'standby') {
|
||||
standbyAccountField.value = my_wallet.address
|
||||
standbyPubKeyField.value = my_wallet.publicKey
|
||||
standbyPrivKeyField.value = my_wallet.privateKey
|
||||
standbyBalanceField.value = (await client.getXrpBalance(my_wallet.address))
|
||||
standbySeedField.value = my_wallet.seed
|
||||
results += '\nStandby account created.'
|
||||
standbyResultField.value = results
|
||||
} else {
|
||||
operationalAccountField.value = my_wallet.address
|
||||
operationalPubKeyField.value = my_wallet.publicKey
|
||||
operationalPrivKeyField.value = my_wallet.privateKey
|
||||
operationalSeedField.value = my_wallet.seed
|
||||
operationalBalanceField.value = (await client.getXrpBalance(my_wallet.address))
|
||||
results += '\nOperational account created.'
|
||||
operationalResultField.value = results
|
||||
}
|
||||
// --------------- Capture the seeds for both accounts for ease of reload.
|
||||
seeds.value = standbySeedField.value + '\n' + operationalSeedField.value
|
||||
client.disconnect()
|
||||
} // End of getAccount()
|
||||
|
||||
// *******************************************************
|
||||
// ********** Get Accounts from Seeds ********************
|
||||
// *******************************************************
|
||||
|
||||
async function getAccountsFromSeeds() {
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
results = 'Connecting to ' + getNet() + '....'
|
||||
standbyResultField.value = results
|
||||
await client.connect()
|
||||
results += '\nConnected, finding wallets.\n'
|
||||
standbyResultField.value = results
|
||||
|
||||
// -------------------------------------------------Find the test account wallets.
|
||||
var lines = seeds.value.split('\n')
|
||||
const standby_wallet = xrpl.Wallet.fromSeed(lines[0])
|
||||
const operational_wallet = xrpl.Wallet.fromSeed(lines[1])
|
||||
|
||||
// -------------------------------------------------------Get the current balance.
|
||||
const standby_balance = (await client.getXrpBalance(standby_wallet.address))
|
||||
const operational_balance = (await client.getXrpBalance(operational_wallet.address))
|
||||
|
||||
// ----------------------Populate the fields for Standby and Operational accounts.
|
||||
standbyAccountField.value = standby_wallet.address
|
||||
standbyPubKeyField.value = standby_wallet.publicKey
|
||||
standbyPrivKeyField.value = standby_wallet.privateKey
|
||||
standbySeedField.value = standby_wallet.seed
|
||||
standbyBalanceField.value = (await client.getXrpBalance(standby_wallet.address))
|
||||
|
||||
operationalAccountField.value = operational_wallet.address
|
||||
operationalPubKeyField.value = operational_wallet.publicKey
|
||||
operationalPrivKeyField.value = operational_wallet.privateKey
|
||||
operationalSeedField.value = operational_wallet.seed
|
||||
operationalBalanceField.value = (await client.getXrpBalance(operational_wallet.address))
|
||||
|
||||
client.disconnect()
|
||||
|
||||
} // End of getAccountsFromSeeds()
|
||||
|
||||
// *******************************************************
|
||||
// ******************** Send XRP *************************
|
||||
// *******************************************************
|
||||
|
||||
async function sendXRP() {
|
||||
results = "Connecting to the selected ledger.\n"
|
||||
standbyResultField.value = results
|
||||
let net = getNet()
|
||||
results = 'Connecting to ' + getNet() + '....'
|
||||
const client = new xrpl.Client(net)
|
||||
await client.connect()
|
||||
|
||||
results += "\nConnected. Sending XRP.\n"
|
||||
standbyResultField.value = results
|
||||
|
||||
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
|
||||
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
|
||||
const sendAmount = standbyAmountField.value
|
||||
|
||||
results += "\nstandby_wallet.address: = " + standby_wallet.address
|
||||
standbyResultField.value = results
|
||||
|
||||
// -------------------------------------------------------- Prepare transaction
|
||||
const prepared = await client.autofill({
|
||||
"TransactionType": "Payment",
|
||||
"Account": standby_wallet.address,
|
||||
"Amount": xrpl.xrpToDrops(sendAmount),
|
||||
"Destination": standbyDestinationField.value
|
||||
})
|
||||
|
||||
// ------------------------------------------------- Sign prepared instructions
|
||||
const signed = standby_wallet.sign(prepared)
|
||||
|
||||
// -------------------------------------------------------- Submit signed blob
|
||||
const tx = await client.submitAndWait(signed.tx_blob)
|
||||
|
||||
results += "\nBalance changes: " +
|
||||
JSON.stringify(xrpl.getBalanceChanges(tx.result.meta), null, 2)
|
||||
standbyResultField.value = results
|
||||
|
||||
standbyBalanceField.value = (await client.getXrpBalance(standby_wallet.address))
|
||||
operationalBalanceField.value = (await client.getXrpBalance(operational_wallet.address))
|
||||
client.disconnect()
|
||||
} // End of sendXRP()
|
||||
|
||||
// **********************************************************************
|
||||
// ****** Reciprocal Transactions ***************************************
|
||||
// **********************************************************************
|
||||
|
||||
// *******************************************************
|
||||
// ********* Send XRP from Operational account ***********
|
||||
// *******************************************************
|
||||
|
||||
async function oPsendXRP() {
|
||||
|
||||
results = "Connecting to the selected ledger.\n"
|
||||
operationalResultField.value = results
|
||||
let net = getNet()
|
||||
results = 'Connecting to ' + getNet() + '....'
|
||||
const client = new xrpl.Client(net)
|
||||
await client.connect()
|
||||
|
||||
results += "\nConnected. Sending XRP.\n"
|
||||
operationalResultField.value = results
|
||||
|
||||
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
|
||||
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
|
||||
const sendAmount = operationalAmountField.value
|
||||
|
||||
results += "\noperational_wallet.address: = " + operational_wallet.address
|
||||
operationalResultField.value = results
|
||||
|
||||
// ---------------------------------------------------------- Prepare transaction
|
||||
const prepared = await client.autofill({
|
||||
"TransactionType": "Payment",
|
||||
"Account": operational_wallet.address,
|
||||
"Amount": xrpl.xrpToDrops(operationalAmountField.value),
|
||||
"Destination": operationalDestinationField.value
|
||||
})
|
||||
|
||||
// ---------------------------------------------------- Sign prepared instructions
|
||||
const signed = operational_wallet.sign(prepared)
|
||||
|
||||
// ------------------------------------------------------------ Submit signed blob
|
||||
const tx = await client.submitAndWait(signed.tx_blob)
|
||||
|
||||
results += "\nBalance changes: " +
|
||||
JSON.stringify(xrpl.getBalanceChanges(tx.result.meta), null, 2)
|
||||
operationalResultField.value = results
|
||||
standbyBalanceField.value = (await client.getXrpBalance(standby_wallet.address))
|
||||
operationalBalanceField.value = (await client.getXrpBalance(operational_wallet.address))
|
||||
|
||||
client.disconnect()
|
||||
|
||||
} // End of oPsendXRP()
|
||||
282
content/_code-samples/quickstart/js/ripplex2-send-currency.js
Normal file
@@ -0,0 +1,282 @@
|
||||
// *******************************************************
|
||||
// **************** Configure Account ********************
|
||||
// *******************************************************
|
||||
|
||||
async function configureAccount(type, defaultRippleSetting) {
|
||||
let net = getNet()
|
||||
let resultField = 'standbyResultField'
|
||||
const client = new xrpl.Client(net)
|
||||
results = 'Connecting to ' + net + '....'
|
||||
await client.connect()
|
||||
results += '\nConnected, finding wallet.'
|
||||
if (type=='standby') {
|
||||
my_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
|
||||
} else {
|
||||
my_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
|
||||
resultField = 'operationalResultField'
|
||||
}
|
||||
results += '\nRipple Default Setting: ' + defaultRippleSetting
|
||||
resultField.value = results
|
||||
|
||||
let settings_tx = {}
|
||||
if (defaultRippleSetting) {
|
||||
settings_tx = {
|
||||
"TransactionType": "AccountSet",
|
||||
"Account": my_wallet.address,
|
||||
"SetFlag": xrpl.AccountSetAsfFlags.asfDefaultRipple
|
||||
}
|
||||
results += '\n Set Default Ripple flag.'
|
||||
} else {
|
||||
settings_tx = {
|
||||
"TransactionType": "AccountSet",
|
||||
"Account": my_wallet.address,
|
||||
"ClearFlag": xrpl.AccountSetAsfFlags.asfDefaultRipple
|
||||
}
|
||||
results += '\n Clear Default Ripple flag.'
|
||||
}
|
||||
results += '\nSending account setting.'
|
||||
resultField.value = results
|
||||
|
||||
const prepared = await client.autofill(settings_tx)
|
||||
const signed = my_wallet.sign(prepared)
|
||||
const result = await client.submitAndWait(signed.tx_blob)
|
||||
if (result.result.meta.TransactionResult == "tesSUCCESS") {
|
||||
results += '\nAccount setting succeeded.'
|
||||
document.getElementById(resultField).value = results
|
||||
} else {
|
||||
throw 'Error sending transaction: ${result}'
|
||||
results += '\nAccount setting failed.'
|
||||
resultField.value = results
|
||||
}
|
||||
client.disconnect()
|
||||
} // End of configureAccount()
|
||||
|
||||
// *******************************************************
|
||||
// ***************** Create TrustLine ********************
|
||||
// *******************************************************
|
||||
|
||||
async function createTrustline() {
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
results = 'Connecting to ' + getNet() + '....'
|
||||
standbyResultField.value = results
|
||||
|
||||
await client.connect()
|
||||
results += '\nConnected.'
|
||||
standbyResultField.value = results
|
||||
|
||||
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
|
||||
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
|
||||
const currency_code = standbyCurrencyField.value
|
||||
const trustSet_tx = {
|
||||
"TransactionType": "TrustSet",
|
||||
"Account": standbyDestinationField.value,
|
||||
"LimitAmount": {
|
||||
"currency": standbyCurrencyField.value,
|
||||
"issuer": standby_wallet.address,
|
||||
"value": standbyAmountField.value
|
||||
}
|
||||
}
|
||||
const ts_prepared = await client.autofill(trustSet_tx)
|
||||
const ts_signed = operational_wallet.sign(ts_prepared)
|
||||
results += '\nCreating trust line from operational account to standby account...'
|
||||
standbyResultField.value = results
|
||||
const ts_result = await client.submitAndWait(ts_signed.tx_blob)
|
||||
if (ts_result.result.meta.TransactionResult == "tesSUCCESS") {
|
||||
results += '\nTrustline established between account \n' +
|
||||
standbyDestinationField.value + ' \n and account\n' + standby_wallet.address + '.'
|
||||
standbyResultField.value = results
|
||||
} else {
|
||||
results += '\nTrustLine failed. See JavaScript console for details.'
|
||||
document.getElementById('standbyResultField').value = results
|
||||
throw 'Error sending transaction: ${ts_result.result.meta.TransactionResult}'
|
||||
}
|
||||
} //End of createTrustline()
|
||||
|
||||
// *******************************************************
|
||||
// *************** Send Issued Currency ******************
|
||||
// *******************************************************
|
||||
|
||||
async function sendCurrency() {
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
results = 'Connecting to ' + getNet() + '....'
|
||||
document.getElementById('standbyResultField').value = results
|
||||
|
||||
await client.connect()
|
||||
|
||||
results += '\nConnected.'
|
||||
standbyResultField.value = results
|
||||
|
||||
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
|
||||
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
|
||||
const currency_code = standbyCurrencyField.value
|
||||
const issue_quantity = standbyAmountField.value
|
||||
|
||||
const send_token_tx = {
|
||||
"TransactionType": "Payment",
|
||||
"Account": standby_wallet.address,
|
||||
"Amount": {
|
||||
"currency": standbyCurrencyField.value,
|
||||
"value": standbyAmountField.value,
|
||||
"issuer": standby_wallet.address
|
||||
},
|
||||
"Destination": standbyDestinationField.value
|
||||
}
|
||||
|
||||
const pay_prepared = await client.autofill(send_token_tx)
|
||||
const pay_signed = standby_wallet.sign(pay_prepared)
|
||||
results += 'Sending ${issue_quantity} ${currency_code} to ' +
|
||||
standbyDestinationField.value + '...'
|
||||
standbyResultField.value = results
|
||||
const pay_result = await client.submitAndWait(pay_signed.tx_blob)
|
||||
if (pay_result.result.meta.TransactionResult == "tesSUCCESS") {
|
||||
results += 'Transaction succeeded: https://testnet.xrpl.org/transactions/${pay_signed.hash}'
|
||||
standbyResultField.value = results
|
||||
} else {
|
||||
results += 'Transaction failed: See JavaScript console for details.'
|
||||
standbyResultField.value = results
|
||||
throw 'Error sending transaction: ${pay_result.result.meta.TransactionResult}'
|
||||
}
|
||||
standbyBalanceField.value = (await client.getXrpBalance(standby_wallet.address))
|
||||
operationalBalanceField.value = (await client.getXrpBalance(operational_wallet.address))
|
||||
getBalances()
|
||||
client.disconnect()
|
||||
} // end of sendCurrency()
|
||||
|
||||
// *******************************************************
|
||||
// ****************** Get Balances ***********************
|
||||
// *******************************************************
|
||||
|
||||
async function getBalances() {
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
results = 'Connecting to ' + getNet() + '....'
|
||||
standbyResultField.value = results
|
||||
await client.connect()
|
||||
results += '\nConnected.'
|
||||
standbyResultField.value = results
|
||||
|
||||
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
|
||||
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
|
||||
results= "\nGetting standby account balances...\n"
|
||||
const standby_balances = await client.request({
|
||||
command: "gateway_balances",
|
||||
account: standby_wallet.address,
|
||||
ledger_index: "validated",
|
||||
hotwallet: [operational_wallet.address]
|
||||
})
|
||||
results += JSON.stringify(standby_balances.result, null, 2)
|
||||
standbyResultField.value = results
|
||||
|
||||
results += "\nGetting operational account balances...\n"
|
||||
const operational_balances = await client.request({
|
||||
command: "gateway_balances",
|
||||
account: operational_wallet.address,
|
||||
ledger_index: "validated"
|
||||
})
|
||||
results += JSON.stringify(operational_balances.result, null, 2)
|
||||
operationalResultField.value = results
|
||||
operationalBalanceField.value = (await client.getXrpBalance(operational_wallet.address))
|
||||
standbyResultField.value = results
|
||||
standbyBalanceField.value = (await client.getXrpBalance(standby_wallet.address))
|
||||
|
||||
client.disconnect()
|
||||
} // End of getBalances()
|
||||
|
||||
// **********************************************************************
|
||||
// ****** Reciprocal Transactions ***************************************
|
||||
// **********************************************************************
|
||||
|
||||
// *******************************************************
|
||||
// ************ Create Operational TrustLine *************
|
||||
// *******************************************************
|
||||
|
||||
async function oPcreateTrustline() {
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
results = 'Connecting to ' + getNet() + '....'
|
||||
operationalResultField.value = results
|
||||
|
||||
await client.connect()
|
||||
results += '\nConnected.'
|
||||
operationalResultField.value = results
|
||||
|
||||
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
|
||||
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
|
||||
const trustSet_tx = {
|
||||
"TransactionType": "TrustSet",
|
||||
"Account": operationalDestinationField.value,
|
||||
"LimitAmount": {
|
||||
"currency": operationalCurrencyField.value,
|
||||
"issuer": operational_wallet.address,
|
||||
"value": operationalAmountField.value
|
||||
}
|
||||
}
|
||||
const ts_prepared = await client.autofill(trustSet_tx)
|
||||
const ts_signed = standby_wallet.sign(ts_prepared)
|
||||
results += '\nCreating trust line from operational account to ' +
|
||||
operationalDestinationField.value + ' account...'
|
||||
operationalResultField.value = results
|
||||
const ts_result = await client.submitAndWait(ts_signed.tx_blob)
|
||||
if (ts_result.result.meta.TransactionResult == "tesSUCCESS") {
|
||||
results += '\nTrustline established between account \n' + operational_wallet.address +
|
||||
' \n and account\n' + operationalDestinationField.value + '.'
|
||||
operationalResultField.value = results
|
||||
} else {
|
||||
results += '\nTrustLine failed. See JavaScript console for details.'
|
||||
operationalResultField.value = results
|
||||
throw 'Error sending transaction: ${ts_result.result.meta.TransactionResult}'
|
||||
}
|
||||
} //End of oPcreateTrustline
|
||||
|
||||
// *******************************************************
|
||||
// ************* Operational Send Issued Currency ********
|
||||
// *******************************************************
|
||||
|
||||
async function oPsendCurrency() {
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
results = 'Connecting to ' + getNet() + '....'
|
||||
operationalResultField.value = results
|
||||
|
||||
await client.connect()
|
||||
results += '\nConnected.'
|
||||
operationalResultField.value = results
|
||||
|
||||
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
|
||||
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
|
||||
const currency_code = operationalCurrencyField.value
|
||||
const issue_quantity = operationalAmountField.value
|
||||
|
||||
const send_token_tx = {
|
||||
"TransactionType": "Payment",
|
||||
"Account": operational_wallet.address,
|
||||
"Amount": {
|
||||
"currency": currency_code,
|
||||
"value": issue_quantity,
|
||||
"issuer": operational_wallet.address
|
||||
},
|
||||
"Destination": operationalDestinationField.value
|
||||
}
|
||||
|
||||
const pay_prepared = await client.autofill(send_token_tx)
|
||||
const pay_signed = operational_wallet.sign(pay_prepared)
|
||||
results += 'Sending ${issue_quantity} ${currency_code} to ' +
|
||||
operationalDestinationField.value + '...'
|
||||
operationalResultField.value = results
|
||||
const pay_result = await client.submitAndWait(pay_signed.tx_blob)
|
||||
if (pay_result.result.meta.TransactionResult == "tesSUCCESS") {
|
||||
results += 'Transaction succeeded: https://testnet.xrpl.org/transactions/${pay_signed.hash}'
|
||||
operationalResultField.value = results
|
||||
} else {
|
||||
results += 'Transaction failed: See JavaScript console for details.'
|
||||
operationalResultField.value = results
|
||||
throw 'Error sending transaction: ${pay_result.result.meta.TransactionResult}'
|
||||
}
|
||||
standbyBalanceField.value = (await client.getXrpBalance(standby_wallet.address))
|
||||
operationalBalanceField.value = (await client.getXrpBalance(operational_wallet.address))
|
||||
getBalances()
|
||||
client.disconnect()
|
||||
} // end of oPsendCurrency()
|
||||
|
||||
205
content/_code-samples/quickstart/js/ripplex3-mint-nfts.js
Normal file
@@ -0,0 +1,205 @@
|
||||
// *******************************************************
|
||||
// ********************** Mint Token *********************
|
||||
// *******************************************************
|
||||
|
||||
async function mintToken() {
|
||||
results = 'Connecting to ' + getNet() + '....'
|
||||
standbyResultField.value = results
|
||||
let net = getNet()
|
||||
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
|
||||
const client = new xrpl.Client(net)
|
||||
await client.connect()
|
||||
results += '\nConnected. Minting NFT.'
|
||||
standbyResultField.value = results
|
||||
|
||||
// Note that you must convert the token URL to a hexadecimal
|
||||
// value for this transaction.
|
||||
// ------------------------------------------------------------------------
|
||||
const transactionJson = {
|
||||
"TransactionType": "NFTokenMint",
|
||||
"Account": standby_wallet.classicAddress,
|
||||
"URI": xrpl.convertStringToHex(standbyTokenUrlField.value),
|
||||
"Flags": parseInt(standbyFlagsField.value),
|
||||
"TransferFee": parseInt(standbyTransferFeeField.value),
|
||||
"NFTokenTaxon": 0 //Required, but if you have no use for it, set to zero.
|
||||
}
|
||||
|
||||
// ----------------------------------------------------- Submit signed blob
|
||||
const tx = await client.submitAndWait(transactionJson, { wallet: standby_wallet} )
|
||||
const nfts = await client.request({
|
||||
method: "account_nfts",
|
||||
account: standby_wallet.classicAddress
|
||||
})
|
||||
|
||||
// ------------------------------------------------------- Report results
|
||||
results += '\n\nTransaction result: '+ tx.result.meta.TransactionResult
|
||||
results += '\n\nnfts: ' + JSON.stringify(nfts, null, 2)
|
||||
standbyBalanceField.value = (await client.getXrpBalance(standby_wallet.address))
|
||||
standbyResultField.value = results
|
||||
client.disconnect()
|
||||
} //End of mintToken()
|
||||
|
||||
// *******************************************************
|
||||
// ******************* Get Tokens ************************
|
||||
// *******************************************************
|
||||
|
||||
async function getTokens() {
|
||||
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
results = 'Connecting to ' + net + '...'
|
||||
standbyResultField.value = results
|
||||
await client.connect()
|
||||
results += '\nConnected. Getting NFTs...'
|
||||
standbyResultField.value = results
|
||||
const nfts = await client.request({
|
||||
method: "account_nfts",
|
||||
account: standby_wallet.classicAddress
|
||||
})
|
||||
results += '\nNFTs:\n ' + JSON.stringify(nfts,null,2)
|
||||
standbyResultField.value = results
|
||||
client.disconnect()
|
||||
} //End of getTokens()
|
||||
|
||||
// *******************************************************
|
||||
// ********************* Burn Token **********************
|
||||
// *******************************************************
|
||||
|
||||
async function burnToken() {
|
||||
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
results = 'Connecting to ' + net + '...'
|
||||
standbyResultField.value = results
|
||||
await client.connect()
|
||||
results += '\nConnected. Burning NFT...'
|
||||
standbyResultField.value = results
|
||||
|
||||
// ------------------------------------------------------- Prepare transaction
|
||||
const transactionBlob = {
|
||||
"TransactionType": "NFTokenBurn",
|
||||
"Account": standby_wallet.classicAddress,
|
||||
"NFTokenID": standbyTokenIdField.value
|
||||
}
|
||||
|
||||
//---------------------------------- Submit transaction and wait for the results
|
||||
const tx = await client.submitAndWait(transactionBlob,{wallet: standby_wallet})
|
||||
const nfts = await client.request({
|
||||
method: "account_nfts",
|
||||
account: standby_wallet.classicAddress
|
||||
})
|
||||
results += '\nTransaction result: '+ tx.result.meta.TransactionResult
|
||||
results += '\nBalance changes: ' +
|
||||
JSON.stringify(xrpl.getBalanceChanges(tx.result.meta), null, 2)
|
||||
standbyResultField.value = results
|
||||
standbyBalanceField.value = (await client.getXrpBalance(standby_wallet.address))
|
||||
results += '\nNFTs: \n' + JSON.stringify(nfts,null,2)
|
||||
standbyResultField.value = results
|
||||
client.disconnect()
|
||||
}// End of burnToken()
|
||||
|
||||
// **********************************************************************
|
||||
// ****** Reciprocal Transactions ***************************************
|
||||
// **********************************************************************
|
||||
|
||||
// *******************************************************
|
||||
// ************** Operational Mint Token *****************
|
||||
// *******************************************************
|
||||
|
||||
async function oPmintToken() {
|
||||
results = 'Connecting to ' + getNet() + '....'
|
||||
operationalResultField.value = results
|
||||
let net = getNet()
|
||||
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
|
||||
const client = new xrpl.Client(net)
|
||||
await client.connect()
|
||||
results += '\nConnected. Minting NFT.'
|
||||
operationalResultField.value = results
|
||||
|
||||
// Note that you must convert the token URL to a hexadecimal
|
||||
// value for this transaction.
|
||||
// ------------------------------------------------------------------------
|
||||
const transactionBlob = {
|
||||
"TransactionType": 'NFTokenMint',
|
||||
"Account": operational_wallet.classicAddress,
|
||||
"URI": xrpl.convertStringToHex(operationalTokenUrlField.value),
|
||||
"Flags": parseInt(operationalFlagsField.value),
|
||||
"TransferFee": parseInt(operationalTransferFeeField.value),
|
||||
"NFTokenTaxon": 0 //Required, but if you have no use for it, set to zero.
|
||||
}
|
||||
|
||||
// ----------------------------------------------------- Submit signed blob
|
||||
const tx = await client.submitAndWait(transactionBlob, { wallet: operational_wallet} )
|
||||
const nfts = await client.request({
|
||||
method: "account_nfts",
|
||||
account: operational_wallet.classicAddress
|
||||
})
|
||||
|
||||
// ------------------------------------------------------- Report results
|
||||
results += '\n\nTransaction result: '+ tx.result.meta.TransactionResult
|
||||
results += '\n\nnfts: ' + JSON.stringify(nfts, null, 2)
|
||||
operationalBalanceField.value = (await client.getXrpBalance(operational_wallet.address))
|
||||
operationalResultField.value = results
|
||||
client.disconnect()
|
||||
} //End of oPmintToken
|
||||
|
||||
// *******************************************************
|
||||
// ************** Operational Get Tokens *****************
|
||||
// *******************************************************
|
||||
|
||||
async function oPgetTokens() {
|
||||
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
results = 'Connecting to ' + getNet() + '...'
|
||||
operationalResultField.value = results
|
||||
await client.connect()
|
||||
results += '\nConnected. Getting NFTs...'
|
||||
operationalResultField.value = results
|
||||
const nfts = await client.request({
|
||||
method: "account_nfts",
|
||||
account: operational_wallet.classicAddress
|
||||
})
|
||||
results += '\nNFTs:\n ' + JSON.stringify(nfts,null,2)
|
||||
operationalResultField.value = results
|
||||
client.disconnect()
|
||||
} //End of oPgetTokens
|
||||
|
||||
// *******************************************************
|
||||
// ************* Operational Burn Token ******************
|
||||
// *******************************************************
|
||||
|
||||
async function oPburnToken() {
|
||||
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
results = 'Connecting to ' + getNet() + '...'
|
||||
operationalResultField.value = results
|
||||
await client.connect()
|
||||
results += '\nConnected. Burning NFT...'
|
||||
operationalResultField.value = results
|
||||
|
||||
// ------------------------------------------------------- Prepare transaction
|
||||
const transactionBlob = {
|
||||
"TransactionType": "NFTokenBurn",
|
||||
"Account": operational_wallet.classicAddress,
|
||||
"NFTokenID": operationalTokenIdField.value
|
||||
}
|
||||
|
||||
//-------------------------------------------------------- Submit signed blob
|
||||
const tx = await client.submitAndWait(transactionBlob,{wallet: operational_wallet})
|
||||
const nfts = await client.request({
|
||||
method: "account_nfts",
|
||||
account: operational_wallet.classicAddress
|
||||
})
|
||||
results += '\nTransaction result: '+ tx.result.meta.TransactionResult
|
||||
results += '\nBalance changes: ' +
|
||||
JSON.stringify(xrpl.getBalanceChanges(tx.result.meta), null, 2)
|
||||
operationalResultField.value = results
|
||||
operationalBalanceField.value = (await client.getXrpBalance(operational_wallet.address))
|
||||
operationalBalanceField.value = (await client.getXrpBalance(operational_wallet.address))
|
||||
results += '\nNFTs: \n' + JSON.stringify(nfts,null,2)
|
||||
operationalResultField.value = results
|
||||
client.disconnect()
|
||||
}
|
||||
// End of oPburnToken()
|
||||
677
content/_code-samples/quickstart/js/ripplex4-transfer-nfts.js
Normal file
@@ -0,0 +1,677 @@
|
||||
// *******************************************************
|
||||
// ****************** Create Sell Offer ******************
|
||||
// *******************************************************
|
||||
|
||||
async function createSellOffer() {
|
||||
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
|
||||
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
results = 'Connecting to ' + net + '...'
|
||||
standbyResultField.value = results
|
||||
await client.connect()
|
||||
results += '\nConnected. Creating sell offer...'
|
||||
standbyResultField.value = results
|
||||
|
||||
//------------------------------------- Prepare Expiration Date
|
||||
var expirationDate = null
|
||||
if (standbyExpirationField.value !="") {
|
||||
var days = standbyExpirationField.value
|
||||
let d = new Date()
|
||||
d.setDate(d.getDate() + parseInt(days))
|
||||
expirationDate = xrpl.isoTimeToRippleTime(d)
|
||||
}
|
||||
// Prepare transaction -------------------------------------------------------
|
||||
let transactionBlob = {
|
||||
"TransactionType": "NFTokenCreateOffer",
|
||||
"Account": standby_wallet.classicAddress,
|
||||
"NFTokenID": standbyTokenIdField.value,
|
||||
"Amount": standbyAmountField.value,
|
||||
"Flags": parseInt(standbyFlagsField.value),
|
||||
}
|
||||
if (expirationDate != null) {
|
||||
transactionBlob.Expiration = expirationDate
|
||||
}
|
||||
if(standbyDestinationField.value !== '') {
|
||||
transactionBlob.Destination = standbyDestinationField.value
|
||||
}
|
||||
|
||||
// Submit transaction --------------------------------------------------------
|
||||
|
||||
const tx = await client.submitAndWait(transactionBlob,{wallet: standby_wallet})
|
||||
|
||||
results += '\n\n***Sell Offers***\n'
|
||||
|
||||
let nftSellOffers
|
||||
try {
|
||||
nftSellOffers = await client.request({
|
||||
method: "nft_sell_offers",
|
||||
nft_id: standbyTokenIdField.value})
|
||||
} catch (err) {
|
||||
nftSellOffers = "No sell offers."
|
||||
}
|
||||
results += JSON.stringify(nftSellOffers,null,2)
|
||||
results += '\n\n***Buy Offers***\n'
|
||||
let nftBuyOffers
|
||||
try {
|
||||
nftBuyOffers = await client.request({
|
||||
method: "nft_buy_offers",
|
||||
nft_id: standbyTokenIdField.value })
|
||||
results += JSON.stringify(nftBuyOffers,null,2)
|
||||
} catch (err) {
|
||||
results += 'No buy offers.'
|
||||
}
|
||||
|
||||
// Check transaction results -------------------------------------------------
|
||||
results += '\n\nTransaction result:\n' +
|
||||
JSON.stringify(tx.result.meta.TransactionResult, null, 2)
|
||||
results += '\n\nBalance changes:\n' +
|
||||
JSON.stringify(xrpl.getBalanceChanges(tx.result.meta), null, 2)
|
||||
operationalBalanceField.value = (await client.getXrpBalance(operational_wallet.address))
|
||||
standbyBalanceField.value = (await client.getXrpBalance(standby_wallet.address))
|
||||
standbyResultField.value = results
|
||||
client.disconnect()
|
||||
}// End of createSellOffer()
|
||||
|
||||
// *******************************************************
|
||||
// ***************** Create Buy Offer ********************
|
||||
// *******************************************************
|
||||
|
||||
async function createBuyOffer() {
|
||||
|
||||
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
|
||||
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
let results = 'Connecting to ' + net + '...'
|
||||
standbyResultField.value = results
|
||||
await client.connect()
|
||||
results = '\nConnected. Creating buy offer...'
|
||||
standbyResultField.value = results
|
||||
|
||||
//------------------------------------- Prepare Expiration Date
|
||||
var expirationDate = null
|
||||
if (standbyExpirationField.value !="") {
|
||||
var days = standbyExpirationField.value
|
||||
let d = new Date()
|
||||
d.setDate(d.getDate() + parseInt(days))
|
||||
var expirationDate = xrpl.isoTimeToRippleTime(d)
|
||||
}
|
||||
|
||||
// Prepare transaction -------------------------------------------------------
|
||||
const transactionBlob = {
|
||||
"TransactionType": "NFTokenCreateOffer",
|
||||
"Account": standby_wallet.classicAddress,
|
||||
"Owner": standbyOwnerField.value,
|
||||
"NFTokenID": standbyTokenIdField.value,
|
||||
"Amount": standbyAmountField.value,
|
||||
"Flags": null
|
||||
}
|
||||
if (expirationDate != null) {
|
||||
transactionBlob.Expiration = expirationDate
|
||||
}
|
||||
|
||||
// Submit transaction --------------------------------------------------------
|
||||
const tx = await client.submitAndWait(transactionBlob,{wallet: standby_wallet})
|
||||
|
||||
results += "\n\n***Sell Offers***\n"
|
||||
let nftSellOffers
|
||||
try {
|
||||
nftSellOffers = await client.request({
|
||||
method: "nft_sell_offers",
|
||||
nft_id: standbyTokenIdField.value })
|
||||
} catch (err) {
|
||||
nftSellOffers = "No sell offers."
|
||||
}
|
||||
results += JSON.stringify(nftSellOffers,null,2)
|
||||
results += "\n\n***Buy Offers***\n"
|
||||
let nftBuyOffers
|
||||
try {
|
||||
nftBuyOffers = await client.request({
|
||||
method: "nft_buy_offers",
|
||||
nft_id: standbyTokenIdField.value })
|
||||
results += JSON.stringify(nftBuyOffers,null,2)
|
||||
} catch (err) {
|
||||
results += "No buy offers."
|
||||
}
|
||||
|
||||
// Check transaction results -------------------------------------------------
|
||||
results += "\n\nTransaction result:\n" +
|
||||
JSON.stringify(tx.result.meta.TransactionResult, null, 2)
|
||||
results += "\n\nBalance changes:\n" +
|
||||
JSON.stringify(xrpl.getBalanceChanges(tx.result.meta), null, 2)
|
||||
standbyResultField.value = results
|
||||
|
||||
client.disconnect()
|
||||
}// End of createBuyOffer()
|
||||
|
||||
// *******************************************************
|
||||
// ******************** Cancel Offer *********************
|
||||
// *******************************************************
|
||||
|
||||
async function cancelOffer() {
|
||||
const wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
results = 'Connecting to ' + net + '...' + standbyResultField.value
|
||||
await client.connect()
|
||||
results += "\nConnected. Cancelling offer..."
|
||||
standbyResultField.value = results
|
||||
|
||||
const tokenOfferIDs = [standbyTokenOfferIndexField.value]
|
||||
|
||||
// Prepare transaction -------------------------------------------------------
|
||||
const transactionBlob = {
|
||||
"TransactionType": "NFTokenCancelOffer",
|
||||
"Account": wallet.classicAddress,
|
||||
"NFTokenOffers": tokenOfferIDs
|
||||
}
|
||||
// Submit transaction --------------------------------------------------------
|
||||
const tx = await client.submitAndWait(transactionBlob,{wallet})
|
||||
|
||||
results += "\n\n***Sell Offers***\n"
|
||||
let nftSellOffers
|
||||
try {
|
||||
nftSellOffers = await client.request({
|
||||
method: "nft_sell_offers",
|
||||
nft_id: standbyTokenIdField.value
|
||||
})
|
||||
} catch (err) {
|
||||
nftSellOffers = "No sell offers."
|
||||
}
|
||||
results += JSON.stringify(nftSellOffers,null,2)
|
||||
results += "\n\n***Buy Offers***\n"
|
||||
let nftBuyOffers
|
||||
try {
|
||||
nftBuyOffers = await client.request({
|
||||
method: "nft_buy_offers",
|
||||
nft_id: standbyTokenIdField.value
|
||||
})
|
||||
results += JSON.stringify(nftBuyOffers,null,2)
|
||||
} catch (err) {
|
||||
nftBuyOffers = "No buy offers."
|
||||
}
|
||||
|
||||
// Check transaction results -------------------------------------------------
|
||||
|
||||
results += "\nTransaction result:\n" +
|
||||
JSON.stringify(tx.result.meta.TransactionResult, null, 2)
|
||||
results += "\nBalance changes:\n" +
|
||||
JSON.stringify(xrpl.getBalanceChanges(tx.result.meta), null, 2)
|
||||
standbyResultField.value = results
|
||||
|
||||
client.disconnect() // End of cancelOffer()
|
||||
}
|
||||
|
||||
// *******************************************************
|
||||
// ******************** Get Offers ***********************
|
||||
// *******************************************************
|
||||
|
||||
async function getOffers() {
|
||||
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
results = 'Connecting to ' + net + '...'
|
||||
standbyResultField.value = results
|
||||
await client.connect()
|
||||
results += '\nConnected. Getting offers...'
|
||||
standbyResultField.value = results
|
||||
|
||||
results += '\n\n***Sell Offers***\n'
|
||||
let nftSellOffers
|
||||
try {
|
||||
nftSellOffers = await client.request({
|
||||
method: "nft_sell_offers",
|
||||
nft_id: standbyTokenIdField.value
|
||||
})
|
||||
} catch (err) {
|
||||
nftSellOffers = 'No sell offers.'
|
||||
}
|
||||
results += JSON.stringify(nftSellOffers,null,2)
|
||||
standbyResultField.value = results
|
||||
|
||||
results += '\n\n***Buy Offers***\n'
|
||||
let nftBuyOffers
|
||||
try {
|
||||
nftBuyOffers = await client.request({
|
||||
method: "nft_buy_offers",
|
||||
nft_id: standbyTokenIdField.value
|
||||
})
|
||||
} catch (err) {
|
||||
nftBuyOffers = 'No buy offers.'
|
||||
}
|
||||
results += JSON.stringify(nftBuyOffers,null,2)
|
||||
standbyResultField.value = results
|
||||
|
||||
client.disconnect()
|
||||
}// End of getOffers()
|
||||
|
||||
// *******************************************************
|
||||
// ****************** Accept Sell Offer ******************
|
||||
// *******************************************************
|
||||
|
||||
async function acceptSellOffer() {
|
||||
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
|
||||
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
results = 'Connecting to ' + net + '...'
|
||||
standbyResultField.value = results
|
||||
await client.connect()
|
||||
results += '\nConnected. Accepting sell offer...\n\n'
|
||||
standbyResultField.value = results
|
||||
|
||||
// Prepare transaction -------------------------------------------------------
|
||||
const transactionBlob = {
|
||||
"TransactionType": "NFTokenAcceptOffer",
|
||||
"Account": standby_wallet.classicAddress,
|
||||
"NFTokenSellOffer": standbyTokenOfferIndexField.value,
|
||||
}
|
||||
// Submit transaction --------------------------------------------------------
|
||||
const tx = await client.submitAndWait(transactionBlob,{wallet: standby_wallet})
|
||||
const nfts = await client.request({
|
||||
method: "account_nfts",
|
||||
account: standby_wallet.classicAddress
|
||||
})
|
||||
|
||||
// Check transaction results -------------------------------------------------
|
||||
|
||||
standbyBalanceField.value = (await client.getXrpBalance(standby_wallet.address))
|
||||
operationalBalanceField.value = (await client.getXrpBalance(operational_wallet.address))
|
||||
|
||||
results += 'Transaction result:\n'
|
||||
results += JSON.stringify(tx.result.meta.TransactionResult, null, 2)
|
||||
results += '\nBalance changes:'
|
||||
results += JSON.stringify(xrpl.getBalanceChanges(tx.result.meta), null, 2)
|
||||
results += JSON.stringify(nfts,null,2)
|
||||
standbyResultField.value = results
|
||||
|
||||
client.disconnect()
|
||||
}// End of acceptSellOffer()
|
||||
|
||||
// *******************************************************
|
||||
// ******************* Accept Buy Offer ******************
|
||||
// *******************************************************
|
||||
|
||||
async function acceptBuyOffer() {
|
||||
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
|
||||
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
results = 'Connecting to ' + net + '...'
|
||||
standbyResultField.value = results
|
||||
await client.connect()
|
||||
results += '\nConnected. Accepting buy offer...'
|
||||
standbyResultField.value = results
|
||||
|
||||
// Prepare transaction -------------------------------------------------------
|
||||
const transactionBlob = {
|
||||
"TransactionType": "NFTokenAcceptOffer",
|
||||
"Account": standby_wallet.classicAddress,
|
||||
"NFTokenBuyOffer": standbyTokenOfferIndexField.value
|
||||
}
|
||||
// Submit transaction --------------------------------------------------------
|
||||
const tx = await client.submitAndWait(transactionBlob,{wallet: standby_wallet})
|
||||
const nfts = await client.request({
|
||||
method: "account_nfts",
|
||||
account: standby_wallet.classicAddress
|
||||
})
|
||||
results += JSON.stringify(nfts,null,2)
|
||||
standbyResultField.value = results
|
||||
|
||||
// Check transaction results -------------------------------------------------
|
||||
results += "\n\nTransaction result:\n" +
|
||||
JSON.stringify(tx.result.meta.TransactionResult, null, 2)
|
||||
results += "\nBalance changes:\n" +
|
||||
JSON.stringify(xrpl.getBalanceChanges(tx.result.meta), null, 2)
|
||||
operationalBalanceField.value =
|
||||
(await client.getXrpBalance(operational_wallet.address))
|
||||
standbyBalanceField.value =
|
||||
(await client.getXrpBalance(standby_wallet.address))
|
||||
standbyResultField.value = results
|
||||
client.disconnect()
|
||||
}// End of acceptBuyOffer()
|
||||
|
||||
// **********************************************************************
|
||||
// ****** Reciprocal Transactions ***************************************
|
||||
// **********************************************************************
|
||||
|
||||
// *******************************************************
|
||||
// *********** Operational Create Sell Offer *************
|
||||
// *******************************************************
|
||||
|
||||
async function oPcreateSellOffer() {
|
||||
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
|
||||
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
results = 'Connecting to ' + net + '...'
|
||||
operationalResultField.value = results
|
||||
await client.connect()
|
||||
results += '\nConnected. Creating sell offer...'
|
||||
operationalResultField.value = results
|
||||
|
||||
//------------------------------------- Prepare Expiration Date
|
||||
var expirationDate = null
|
||||
if (operationalExpirationField.value !="") {
|
||||
var days = operationalExpirationField.value
|
||||
let d = new Date()
|
||||
d.setDate(d.getDate() + parseInt(days))
|
||||
var expirationDate = xrpl.isoTimeToRippleTime(d)
|
||||
}
|
||||
// Prepare transaction -------------------------------------------------------
|
||||
let transactionBlob = {
|
||||
"TransactionType": "NFTokenCreateOffer",
|
||||
"Account": operational_wallet.classicAddress,
|
||||
"NFTokenID": operationalTokenIdField.value,
|
||||
"Amount": operationalAmountField.value,
|
||||
"Flags": parseInt(operationalFlagsField.value)
|
||||
}
|
||||
if (expirationDate != null) {
|
||||
transactionBlob.Expiration = expirationDate
|
||||
}
|
||||
if(standbyDestinationField.value !== '') {
|
||||
transactionBlob.Destination = operationalDestinationField.value
|
||||
}
|
||||
|
||||
// Submit transaction --------------------------------------------------------
|
||||
|
||||
const tx = await client.submitAndWait(transactionBlob,{wallet: operational_wallet})
|
||||
|
||||
results += '\n\n***Sell Offers***\n'
|
||||
|
||||
let nftSellOffers
|
||||
try {
|
||||
nftSellOffers = await client.request({
|
||||
method: "nft_sell_offers",
|
||||
nft_id: operationalTokenIdField.value
|
||||
})
|
||||
} catch (err) {
|
||||
nftSellOffers = "No sell offers."
|
||||
}
|
||||
results += JSON.stringify(nftSellOffers,null,2)
|
||||
results += '\n\n***Buy Offers***\n'
|
||||
let nftBuyOffers
|
||||
try {
|
||||
nftBuyOffers = await client.request({
|
||||
method: "nft_buy_offers",
|
||||
nft_id: operationalTokenIdField.value
|
||||
})
|
||||
results += JSON.stringify(nftBuyOffers,null,2)
|
||||
} catch (err) {
|
||||
results += 'No buy offers.'
|
||||
}
|
||||
|
||||
// Check transaction results -------------------------------------------------
|
||||
results += '\n\nTransaction result:\n' +
|
||||
JSON.stringify(tx.result.meta.TransactionResult, null, 2)
|
||||
results += '\n\nBalance changes:\n' +
|
||||
JSON.stringify(xrpl.getBalanceChanges(tx.result.meta), null, 2)
|
||||
operationalBalanceField.value =
|
||||
(await client.getXrpBalance(operational_wallet.address))
|
||||
standbyBalanceField.value =
|
||||
(await client.getXrpBalance(standby_wallet.address))
|
||||
operationalResultField.value = results
|
||||
|
||||
client.disconnect()
|
||||
} // End of oPcreateSellOffer()
|
||||
|
||||
// *******************************************************
|
||||
// ************** Operational Create Buy Offer ***********
|
||||
// *******************************************************
|
||||
|
||||
async function oPcreateBuyOffer() {
|
||||
|
||||
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
|
||||
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
let results = 'Connecting to ' + net + '...'
|
||||
operationalResultField.value = results
|
||||
await client.connect()
|
||||
results = '\nConnected. Creating buy offer...'
|
||||
operationalResultField.value = results
|
||||
|
||||
//------------------------------------- Prepare Expiration Date
|
||||
var expirationDate = null
|
||||
if (operationalExpirationField.value !="") {
|
||||
var days = operationalExpirationField.value
|
||||
let d = new Date()
|
||||
d.setDate(d.getDate() + parseInt(days))
|
||||
var expirationDate = xrpl.isoTimeToRippleTime(d)
|
||||
}
|
||||
|
||||
// Prepare transaction -------------------------------------------------------
|
||||
const transactionBlob = {
|
||||
"TransactionType": "NFTokenCreateOffer",
|
||||
"Account": operational_wallet.classicAddress,
|
||||
"Owner": operationalOwnerField.value,
|
||||
"NFTokenID": operationalTokenIdField.value,
|
||||
"Amount": operationalAmountField.value,
|
||||
"Flags": null,
|
||||
}
|
||||
if (expirationDate != null) {
|
||||
transactionBlob.Expiration = expirationDate
|
||||
}
|
||||
// Submit transaction --------------------------------------------------------
|
||||
const tx = await client.submitAndWait(transactionBlob,{wallet: operational_wallet})
|
||||
|
||||
results += "\n\n***Sell Offers***\n"
|
||||
let nftSellOffers
|
||||
try {
|
||||
nftSellOffers = await client.request({
|
||||
method: "nft_sell_offers",
|
||||
nft_id: operationalTokenIdField.value
|
||||
})
|
||||
} catch (err) {
|
||||
nftSellOffers = "No sell offers."
|
||||
}
|
||||
results += JSON.stringify(nftSellOffers,null,2)
|
||||
results += "\n\n***Buy Offers***\n"
|
||||
let nftBuyOffers
|
||||
try {
|
||||
nftBuyOffers = await client.request({
|
||||
method: "nft_buy_offers",
|
||||
nft_id: operationalTokenIdField.value
|
||||
})
|
||||
} catch (err) {
|
||||
results += "No buy offers."
|
||||
}
|
||||
results += JSON.stringify(nftBuyOffers,null,2)
|
||||
|
||||
// Check transaction results -------------------------------------------------
|
||||
results += "\n\nTransaction result:\n" +
|
||||
JSON.stringify(tx.result.meta.TransactionResult, null, 2)
|
||||
results += "\n\nBalance changes:\n" +
|
||||
JSON.stringify(xrpl.getBalanceChanges(tx.result.meta), null, 2)
|
||||
operationalResultField.value = results
|
||||
|
||||
client.disconnect()
|
||||
}// End of oPcreateBuyOffer()
|
||||
|
||||
// *******************************************************
|
||||
// ************* Operational Cancel Offer ****************
|
||||
// *******************************************************
|
||||
|
||||
async function oPcancelOffer() {
|
||||
|
||||
const wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
results = 'Connecting to ' + net + '...'
|
||||
operationalResultField.value = results
|
||||
await client.connect()
|
||||
results += "\nConnected. Cancelling offer..."
|
||||
operationalResultField.value = results
|
||||
|
||||
const tokenOfferIDs = [operationalTokenOfferIndexField.value]
|
||||
|
||||
// Prepare transaction -------------------------------------------------------
|
||||
const transactionBlob = {
|
||||
"TransactionType": "NFTokenCancelOffer",
|
||||
"Account": wallet.classicAddress,
|
||||
"NFTokenOffers": tokenOfferIDs
|
||||
}
|
||||
// Submit transaction --------------------------------------------------------
|
||||
const tx = await client.submitAndWait(transactionBlob,{wallet})
|
||||
|
||||
results += "\n\n***Sell Offers***\n"
|
||||
let nftSellOffers
|
||||
try {
|
||||
nftSellOffers = await client.request({
|
||||
method: "nft_sell_offers",
|
||||
nft_id: operationalTokenIdField.value
|
||||
})
|
||||
} catch (err) {
|
||||
nftSellOffers = "No sell offers."
|
||||
}
|
||||
results += JSON.stringify(nftSellOffers,null,2)
|
||||
results += "\n\n***Buy Offers***\n"
|
||||
let nftBuyOffers
|
||||
try {
|
||||
nftBuyOffers = await client.request({
|
||||
method: "nft_buy_offers",
|
||||
nft_id: operationalTokenIdField.value
|
||||
})
|
||||
} catch (err) {
|
||||
nftBuyOffers = "No buy offers."
|
||||
}
|
||||
results += JSON.stringify(nftBuyOffers,null,2)
|
||||
|
||||
// Check transaction results -------------------------------------------------
|
||||
|
||||
results += "\nTransaction result:\n" +
|
||||
JSON.stringify(tx.result.meta.TransactionResult, null, 2)
|
||||
results += "\nBalance changes:\n" +
|
||||
JSON.stringify(xrpl.getBalanceChanges(tx.result.meta), null, 2)
|
||||
operationalResultField.value = results
|
||||
|
||||
client.disconnect()
|
||||
}// End of oPcancelOffer()
|
||||
|
||||
// *******************************************************
|
||||
// **************** Operational Get Offers ***************
|
||||
// *******************************************************
|
||||
|
||||
async function oPgetOffers() {
|
||||
// const standby_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
results = 'Connecting to ' + net + '...'
|
||||
operationalResultField.value = results
|
||||
await client.connect()
|
||||
results += '\nConnected. Getting offers...'
|
||||
|
||||
results += '\n\n***Sell Offers***\n'
|
||||
|
||||
let nftSellOffers
|
||||
try {
|
||||
nftSellOffers = await client.request({
|
||||
method: "nft_sell_offers",
|
||||
nft_id: operationalTokenIdField.value
|
||||
})
|
||||
} catch (err) {
|
||||
nftSellOffers = 'No sell offers.'
|
||||
}
|
||||
results += JSON.stringify(nftSellOffers,null,2)
|
||||
|
||||
results += '\n\n***Buy Offers***\n'
|
||||
let nftBuyOffers
|
||||
try {
|
||||
nftBuyOffers = await client.request({
|
||||
method: "nft_buy_offers",
|
||||
nft_id: operationalTokenIdField.value
|
||||
})
|
||||
} catch (err) {
|
||||
nftBuyOffers = 'No buy offers.'
|
||||
}
|
||||
results += JSON.stringify(nftBuyOffers,null,2)
|
||||
operationalResultField.value = results
|
||||
|
||||
client.disconnect()
|
||||
}// End of oPgetOffers()
|
||||
|
||||
// *******************************************************
|
||||
// *************** Operational Accept Sell Offer *********
|
||||
// *******************************************************
|
||||
|
||||
async function oPacceptSellOffer() {
|
||||
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
|
||||
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
results = 'Connecting to ' + net + '...'
|
||||
operationalResultField.value = results
|
||||
await client.connect()
|
||||
results += '\nConnected. Accepting sell offer...\n\n'
|
||||
operationalResultField.value = results
|
||||
|
||||
// Prepare transaction -------------------------------------------------------
|
||||
const transactionBlob = {
|
||||
"TransactionType": "NFTokenAcceptOffer",
|
||||
"Account": operational_wallet.classicAddress,
|
||||
"NFTokenSellOffer": operationalTokenOfferIndexField.value,
|
||||
}
|
||||
// Submit transaction --------------------------------------------------------
|
||||
const tx = await client.submitAndWait(transactionBlob,{wallet: operational_wallet})
|
||||
const nfts = await client.request({
|
||||
method: "account_nfts",
|
||||
account: operational_wallet.classicAddress
|
||||
})
|
||||
|
||||
// Check transaction results -------------------------------------------------
|
||||
|
||||
standbyBalanceField.value = (await client.getXrpBalance(standby_wallet.address))
|
||||
operationalBalanceField.value = (await client.getXrpBalance(operational_wallet.address))
|
||||
|
||||
results += 'Transaction result:\n'
|
||||
results += JSON.stringify(tx.result.meta.TransactionResult, null, 2)
|
||||
results += '\nBalance changes:'
|
||||
results += JSON.stringify(xrpl.getBalanceChanges(tx.result.meta), null, 2)
|
||||
results += JSON.stringify(nfts,null,2)
|
||||
operationalResultField.value = results
|
||||
client.disconnect()
|
||||
}// End of acceptSellOffer()
|
||||
|
||||
// *******************************************************
|
||||
// ********* Operational Accept Buy Offer ****************
|
||||
// *******************************************************
|
||||
|
||||
async function oPacceptBuyOffer() {
|
||||
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
|
||||
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
results = 'Connecting to ' + net + '...'
|
||||
operationalResultField.value = results
|
||||
await client.connect()
|
||||
results += '\nConnected. Accepting buy offer...'
|
||||
operationalResultField.value = results
|
||||
|
||||
// Prepare transaction -------------------------------------------------------
|
||||
const transactionBlob = {
|
||||
"TransactionType": "NFTokenAcceptOffer",
|
||||
"Account": operational_wallet.classicAddress,
|
||||
"NFTokenBuyOffer": operationalTokenOfferIndexField.value
|
||||
}
|
||||
// Submit transaction --------------------------------------------------------
|
||||
const tx = await client.submitAndWait(transactionBlob,{wallet: operational_wallet})
|
||||
const nfts = await client.request({
|
||||
method: "account_nfts",
|
||||
account: operational_wallet.classicAddress
|
||||
})
|
||||
results += JSON.stringify(nfts,null,2)
|
||||
operationalResultField.value = results
|
||||
|
||||
// Check transaction results -------------------------------------------------
|
||||
results += "\n\nTransaction result:\n" +
|
||||
JSON.stringify(tx.result.meta.TransactionResult, null, 2)
|
||||
results += "\nBalance changes:\n" +
|
||||
JSON.stringify(xrpl.getBalanceChanges(tx.result.meta), null, 2)
|
||||
operationalBalanceField.value =
|
||||
(await client.getXrpBalance(operational_wallet.address))
|
||||
operationalBalanceField.value =
|
||||
(await client.getXrpBalance(standby_wallet.address))
|
||||
operationalResultField.value = results
|
||||
client.disconnect()
|
||||
}// End of acceptBuyOffer()
|
||||
331
content/_code-samples/quickstart/js/ripplex5-broker-nfts.js
Normal file
@@ -0,0 +1,331 @@
|
||||
// *******************************************************
|
||||
// *******************************************************
|
||||
// ************** Broker Transactions ********************
|
||||
// *******************************************************
|
||||
// *******************************************************
|
||||
|
||||
// *******************************************************
|
||||
// *************** Broker Get Offers *********************
|
||||
// *******************************************************
|
||||
|
||||
async function brGetOffers() {
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
results = 'Connecting to ' + getNet() + '...'
|
||||
brokerResultField.value = results
|
||||
await client.connect()
|
||||
results += '\nConnected. Getting offers...'
|
||||
brokerResultField.value = results
|
||||
|
||||
results += '\n\n***Sell Offers***\n'
|
||||
let nftSellOffers
|
||||
try {
|
||||
nftSellOffers = await client.request({
|
||||
method: "nft_sell_offers",
|
||||
nft_id: brokerTokenIdField.value
|
||||
})
|
||||
} catch (err) {
|
||||
nftSellOffers = 'No sell offers.'
|
||||
}
|
||||
results += JSON.stringify(nftSellOffers,null,2)
|
||||
brokerResultField.value = results
|
||||
|
||||
results += '\n\n***Buy Offers***\n'
|
||||
let nftBuyOffers
|
||||
try {
|
||||
nftBuyOffers = await client.request({
|
||||
method: "nft_buy_offers",
|
||||
nft_id: brokerTokenIdField.value
|
||||
})
|
||||
} catch (err) {
|
||||
nftBuyOffers = 'No buy offers.'
|
||||
}
|
||||
results += JSON.stringify(nftBuyOffers,null,2)
|
||||
brokerResultField.value = results
|
||||
client.disconnect()
|
||||
}// End of brGetOffers()
|
||||
|
||||
// *******************************************************
|
||||
// ******************* Broker Sale ***********************
|
||||
// *******************************************************
|
||||
|
||||
async function brokerSale() {
|
||||
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
|
||||
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
|
||||
const broker_wallet = xrpl.Wallet.fromSeed (brokerSeedField.value)
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
results = 'Connecting to ' + getNet() + '...'
|
||||
brokerResultField.value = results
|
||||
await client.connect()
|
||||
results += '\nConnected. Brokering sale...'
|
||||
brokerResultField.value = results
|
||||
|
||||
// Prepare transaction -------------------------------------------------------
|
||||
const transactionBlob = {
|
||||
"TransactionType": "NFTokenAcceptOffer",
|
||||
"Account": broker_wallet.classicAddress,
|
||||
"NFTokenSellOffer": brokerTokenSellOfferIndexField.value,
|
||||
"NFTokenBuyOffer": brokerTokenBuyOfferIndexField.value,
|
||||
"NFTokenBrokerFee": brokerBrokerFeeField.value
|
||||
}
|
||||
// Submit transaction --------------------------------------------------------
|
||||
const tx = await client.submitAndWait(transactionBlob,{wallet: broker_wallet})
|
||||
|
||||
// Check transaction results -------------------------------------------------
|
||||
results += "\n\nTransaction result:\n" +
|
||||
JSON.stringify(tx.result.meta.TransactionResult, null, 2)
|
||||
results += "\nBalance changes:\n" +
|
||||
JSON.stringify(xrpl.getBalanceChanges(tx.result.meta), null, 2)
|
||||
operationalBalanceField.value = (await client.getXrpBalance(operational_wallet.address))
|
||||
standbyBalanceField.value = (await client.getXrpBalance(standby_wallet.address))
|
||||
brokerBalanceField.value = (await client.getXrpBalance(broker_wallet.address))
|
||||
brokerResultField.value = results
|
||||
client.disconnect()
|
||||
}// End of brokerSale()
|
||||
|
||||
// *******************************************************
|
||||
// ************* Broker Cancel Offer ****************
|
||||
// *******************************************************
|
||||
|
||||
async function brCancelOffer() {
|
||||
const wallet = xrpl.Wallet.fromSeed(brokerSeedField.value)
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
results = 'Connecting to ' + getNet() + '...'
|
||||
brokerResultField.value = results
|
||||
await client.connect()
|
||||
results += "\nConnected. Cancelling offer..."
|
||||
brokerResultField.value = results
|
||||
|
||||
const tokenOfferIDs = [brokerTokenBuyOfferIndexField.value]
|
||||
|
||||
// Prepare transaction -------------------------------------------------------
|
||||
const transactionBlob = {
|
||||
"TransactionType": "NFTokenCancelOffer",
|
||||
"Account": wallet.classicAddress,
|
||||
"NFTokenOffers": tokenOfferIDs
|
||||
}
|
||||
// Submit transaction --------------------------------------------------------
|
||||
const tx = await client.submitAndWait(transactionBlob,{wallet})
|
||||
|
||||
results += "\n\n***Sell Offers***\n"
|
||||
let nftSellOffers
|
||||
try {
|
||||
nftSellOffers = await client.request({
|
||||
method: "nft_sell_offers",
|
||||
nft_id: brokerTokenBuyOfferIndexField.value
|
||||
})
|
||||
} catch (err) {
|
||||
nftSellOffers = "No sell offers."
|
||||
}
|
||||
results += JSON.stringify(nftSellOffers,null,2)
|
||||
results += "\n\n***Buy Offers***\n"
|
||||
let nftBuyOffers
|
||||
try {
|
||||
nftBuyOffers = await client.request({
|
||||
method: "nft_buy_offers",
|
||||
nft_id: brokerTokenBuyOfferIndexField.value })
|
||||
} catch (err) {
|
||||
nftBuyOffers = "No buy offers."
|
||||
}
|
||||
results += JSON.stringify(nftBuyOffers,null,2)
|
||||
|
||||
// Check transaction results -------------------------------------------------
|
||||
|
||||
results += "\nTransaction result:\n" +
|
||||
JSON.stringify(tx.result.meta.TransactionResult, null, 2)
|
||||
results += "\nBalance changes:\n" +
|
||||
JSON.stringify(xrpl.getBalanceChanges(tx.result.meta), null, 2)
|
||||
brokerResultField.value = results
|
||||
client.disconnect()
|
||||
}// End of brCancelOffer()
|
||||
|
||||
// ***************************************************************************
|
||||
// ************** Revised Functions ******************************************
|
||||
// ***************************************************************************
|
||||
|
||||
// *******************************************************
|
||||
// ************* Get Account *****************************
|
||||
// *******************************************************
|
||||
|
||||
|
||||
async function getAccount(type) {
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
results = 'Connecting to ' + net + '....'
|
||||
|
||||
// This uses the default faucet for Testnet/Devnet
|
||||
let faucetHost = null
|
||||
|
||||
if (type == 'standby') {
|
||||
standbyResultField.value = results
|
||||
}
|
||||
if (type == 'operational') {
|
||||
operationalResultField.value = results
|
||||
}
|
||||
if (type == 'broker') {
|
||||
brokerResultField.value = results
|
||||
}
|
||||
await client.connect()
|
||||
|
||||
results += '\nConnected, funding wallet.'
|
||||
if (type == 'standby') {
|
||||
standbyResultField.value = results
|
||||
}
|
||||
if (type == 'operational') {
|
||||
operationalResultField.value = results
|
||||
}
|
||||
if (type == 'broker') {
|
||||
brokerResultField.value = results
|
||||
}
|
||||
|
||||
// -----------------------------------Create and fund a test account wallet
|
||||
const my_wallet = (await client.fundWallet(null, { faucetHost })).wallet
|
||||
|
||||
results += '\nGot a wallet.'
|
||||
if (type == 'standby') {
|
||||
standbyResultField.value = results
|
||||
}
|
||||
if (type == 'operational') {
|
||||
operationalResultField.value = results
|
||||
}
|
||||
if (type == 'broker') {
|
||||
brokerResultField.value = results
|
||||
}
|
||||
|
||||
// -----------------------------------Get the current balance.
|
||||
const my_balance = (await client.getXrpBalance(my_wallet.address))
|
||||
|
||||
if (type == 'standby') {
|
||||
standbyAccountField.value = my_wallet.address
|
||||
standbyPubKeyField.value = my_wallet.publicKey
|
||||
standbyPrivKeyField.value = my_wallet.privateKey
|
||||
standbyBalanceField.value = (await client.getXrpBalance(my_wallet.address))
|
||||
standbySeedField.value = my_wallet.seed
|
||||
results += '\nStandby account created.'
|
||||
standbyResultField.value = results
|
||||
}
|
||||
if (type == 'operational') {
|
||||
operationalAccountField.value = my_wallet.address
|
||||
operationalPubKeyField.value = my_wallet.publicKey
|
||||
operationalPrivKeyField.value = my_wallet.privateKey
|
||||
operationalSeedField.value = my_wallet.seed
|
||||
operationalBalanceField.value = (await client.getXrpBalance(my_wallet.address))
|
||||
results += '\nOperational account created.'
|
||||
operationalResultField.value = results
|
||||
}
|
||||
if (type == 'broker') {
|
||||
brokerAccountField.value = my_wallet.address
|
||||
brokerPubKeyField.value = my_wallet.publicKey
|
||||
brokerPrivKeyField.value = my_wallet.privateKey
|
||||
brokerSeedField.value = my_wallet.seed
|
||||
brokerBalanceField.value = (await client.getXrpBalance(my_wallet.address))
|
||||
results += '\nBroker account created.'
|
||||
brokerResultField.value = results
|
||||
}
|
||||
// --------------- Capture the seeds for accounts for ease of reload.
|
||||
seeds.value = standbySeedField.value + '\n' + operationalSeedField.value + "\n" +
|
||||
brokerSeedField.value
|
||||
client.disconnect()
|
||||
} // End of getAccount()
|
||||
|
||||
// *******************************************************
|
||||
// ********** Get Accounts from Seeds ********************
|
||||
// *******************************************************
|
||||
|
||||
async function getAccountsFromSeeds() {
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
results = 'Connecting to ' + getNet() + '....'
|
||||
standbyResultField.value = results
|
||||
await client.connect()
|
||||
results += '\nConnected, finding wallets.\n'
|
||||
standbyResultField.value = results
|
||||
|
||||
// -----------------------------------Find the test account wallets
|
||||
var lines = seeds.value.split('\n');
|
||||
const standby_wallet = xrpl.Wallet.fromSeed(lines[0])
|
||||
const operational_wallet = xrpl.Wallet.fromSeed(lines[1])
|
||||
const broker_wallet = xrpl.Wallet.fromSeed(lines[2])
|
||||
|
||||
// -----------------------------------Get the current balance.
|
||||
const standby_balance = (await client.getXrpBalance(standby_wallet.address))
|
||||
const operational_balance = (await client.getXrpBalance(operational_wallet.address))
|
||||
const broker_balance = (await client.getXrpBalance(broker_wallet.address))
|
||||
|
||||
standbyAccountField.value = standby_wallet.address
|
||||
standbyPubKeyField.value = standby_wallet.publicKey
|
||||
standbyPrivKeyField.value = standby_wallet.privateKey
|
||||
standbySeedField.value = standby_wallet.seed
|
||||
standbyBalanceField.value = (await client.getXrpBalance(standby_wallet.address))
|
||||
|
||||
operationalAccountField.value = operational_wallet.address
|
||||
operationalPubKeyField.value = operational_wallet.publicKey
|
||||
operationalPrivKeyField.value = operational_wallet.privateKey
|
||||
operationalSeedField.value = operational_wallet.seed
|
||||
operationalBalanceField.value = (await client.getXrpBalance(operational_wallet.address))
|
||||
|
||||
brokerAccountField.value = broker_wallet.address
|
||||
brokerPubKeyField.value = broker_wallet.publicKey
|
||||
brokerPrivKeyField.value = broker_wallet.privateKey
|
||||
brokerSeedField.value = broker_wallet.seed
|
||||
brokerBalanceField.value = (await client.getXrpBalance(broker_wallet.address))
|
||||
|
||||
client.disconnect()
|
||||
getBalances()
|
||||
} // End of getAccountsFromSeeds()
|
||||
|
||||
// *******************************************************
|
||||
// ****************** Get Balances ***********************
|
||||
// *******************************************************
|
||||
|
||||
async function getBalances() {
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
results = 'Connecting to ' + getNet() + '....'
|
||||
standbyResultField.value = results
|
||||
|
||||
await client.connect()
|
||||
|
||||
results += '\nConnected.'
|
||||
standbyResultField.value = results
|
||||
|
||||
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
|
||||
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
|
||||
const broker_wallet = xrpl.Wallet.fromSeed(brokerSeedField.value)
|
||||
|
||||
results = "\nGetting standby account balances...\n"
|
||||
const standby_balances = await client.request({
|
||||
command: "gateway_balances",
|
||||
account: standby_wallet.address,
|
||||
ledger_index: "validated",
|
||||
hotwallet: [operational_wallet.address]
|
||||
})
|
||||
results += JSON.stringify(standby_balances.result, null, 2)
|
||||
standbyResultField.value = results
|
||||
|
||||
results= "\nGetting operational account balances...\n"
|
||||
const operational_balances = await client.request({
|
||||
command: "account_lines",
|
||||
account: operational_wallet.address,
|
||||
ledger_index: "validated"
|
||||
})
|
||||
results += JSON.stringify(operational_balances.result, null, 2)
|
||||
operationalResultField.value = results
|
||||
|
||||
results= "\nGetting broker account balances...\n"
|
||||
const broker_balances = await client.request({
|
||||
command: "account_lines",
|
||||
account: broker_wallet.address,
|
||||
ledger_index: "validated"
|
||||
})
|
||||
results += JSON.stringify(broker_balances.result, null, 2)
|
||||
brokerResultField.value = results
|
||||
|
||||
operationalBalanceField.value = (await client.getXrpBalance(operational_wallet.address))
|
||||
standbyBalanceField.value = (await client.getXrpBalance(standby_wallet.address))
|
||||
brokerBalanceField.value = (await client.getXrpBalance(broker_wallet.address))
|
||||
|
||||
client.disconnect()
|
||||
} // End of getBalances()
|
||||
@@ -0,0 +1,163 @@
|
||||
// *******************************************************
|
||||
// **************** Set Minter *************************
|
||||
// *******************************************************
|
||||
|
||||
async function setMinter() {
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
results = 'Connecting to ' + getNet() + '....'
|
||||
standbyResultField.value = results
|
||||
await client.connect()
|
||||
results += '\nConnected, finding wallet.'
|
||||
standbyResultField.value = results
|
||||
my_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
|
||||
standbyResultField.value = results
|
||||
|
||||
tx_json = {
|
||||
"TransactionType": "AccountSet",
|
||||
"Account": my_wallet.address,
|
||||
"NFTokenMinter": standbyMinterField.value,
|
||||
"SetFlag": xrpl.AccountSetAsfFlags.asfAuthorizedNFTokenMinter
|
||||
}
|
||||
results += '\nSet Minter.'
|
||||
standbyResultField.value = results
|
||||
|
||||
const prepared = await client.autofill(tx_json)
|
||||
const signed = my_wallet.sign(prepared)
|
||||
const result = await client.submitAndWait(signed.tx_blob)
|
||||
if (result.result.meta.TransactionResult == "tesSUCCESS") {
|
||||
results += '\nAccount setting succeeded.\n'
|
||||
results += JSON.stringify(result,null,2)
|
||||
standbyResultField.value = results
|
||||
} else {
|
||||
throw 'Error sending transaction: ${result}'
|
||||
results += '\nAccount setting failed.'
|
||||
standbyResultField.value = results
|
||||
}
|
||||
client.disconnect()
|
||||
} // End of configureAccount()
|
||||
|
||||
// *******************************************************
|
||||
// **************** Mint Other *************************
|
||||
// *******************************************************
|
||||
|
||||
async function mintOther() {
|
||||
results = 'Connecting to ' + getNet() + '....'
|
||||
standbyResultField.value = results
|
||||
let net = getNet()
|
||||
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
|
||||
const client = new xrpl.Client(net)
|
||||
await client.connect()
|
||||
results += '\nConnected. Minting NFT.'
|
||||
standbyResultField.value = results
|
||||
|
||||
// This version adds the "Issuer" field.
|
||||
// ------------------------------------------------------------------------
|
||||
const tx_json = {
|
||||
"TransactionType": "NFTokenMint",
|
||||
"Account": standby_wallet.classicAddress,
|
||||
"URI": xrpl.convertStringToHex(standbyTokenUrlField.value),
|
||||
"Flags": parseInt(standbyFlagsField.value),
|
||||
"TransferFee": parseInt(standbyTransferFeeField.value),
|
||||
"Issuer": standbyIssuerField.value,
|
||||
"NFTokenTaxon": 0 //Required, but if you have no use for it, set to zero.
|
||||
}
|
||||
|
||||
// ----------------------------------------------------- Submit transaction
|
||||
const tx = await client.submitAndWait(tx_json, { wallet: standby_wallet} )
|
||||
const nfts = await client.request({
|
||||
method: "account_nfts",
|
||||
account: standby_wallet.classicAddress
|
||||
})
|
||||
|
||||
// ------------------------------------------------------- Report results
|
||||
results += '\n\nTransaction result: '+ tx.result.meta.TransactionResult
|
||||
results += '\n\nnfts: ' + JSON.stringify(nfts, null, 2)
|
||||
standbyResultField.value = results + (await
|
||||
client.getXrpBalance(standby_wallet.address))
|
||||
standbyResultField.value = results
|
||||
client.disconnect()
|
||||
} //End of mintToken()
|
||||
|
||||
// *******************************************************
|
||||
// **************** Set Operational Minter **************
|
||||
// ********************************************************
|
||||
|
||||
async function oPsetMinter() {
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
results = 'Connecting to ' + getNet() + '....'
|
||||
operationalResultField.value = results
|
||||
await client.connect()
|
||||
results += '\nConnected, finding wallet.'
|
||||
operationalResultField.value = results
|
||||
my_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
|
||||
operationalResultField.value = results
|
||||
|
||||
tx_json = {
|
||||
"TransactionType": "AccountSet",
|
||||
"Account": my_wallet.address,
|
||||
"NFTokenMinter": operationalMinterField.value,
|
||||
"SetFlag": xrpl.AccountSetAsfFlags.asfAuthorizedNFTokenMinter
|
||||
}
|
||||
results += '\nSet Minter.'
|
||||
operationalResultField.value = results
|
||||
|
||||
const prepared = await client.autofill(tx_json)
|
||||
const signed = my_wallet.sign(prepared)
|
||||
const result = await client.submitAndWait(signed.tx_blob)
|
||||
if (result.result.meta.TransactionResult == "tesSUCCESS") {
|
||||
results += '\nAccount setting succeeded.\n'
|
||||
results += JSON.stringify(result,null,2)
|
||||
operationalResultField.value = results
|
||||
} else {
|
||||
throw 'Error sending transaction: ${result}'
|
||||
results += '\nAccount setting failed.'
|
||||
operationalResultField.value = results
|
||||
}
|
||||
|
||||
client.disconnect()
|
||||
} // End of oPsetMinter()
|
||||
|
||||
|
||||
// *******************************************************
|
||||
// ************** Operational Mint Other *****************
|
||||
// *******************************************************
|
||||
|
||||
async function oPmintOther() {
|
||||
results = 'Connecting to ' + getNet() + '....'
|
||||
operationalResultField.value = results
|
||||
let net = getNet()
|
||||
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
|
||||
const client = new xrpl.Client(net)
|
||||
await client.connect()
|
||||
results += '\nConnected. Minting NFT.'
|
||||
operationalResultField.value = results
|
||||
|
||||
// This version adds the "Issuer" field.
|
||||
// ------------------------------------------------------------------------
|
||||
const tx_json = {
|
||||
"TransactionType": 'NFTokenMint',
|
||||
"Account": operational_wallet.classicAddress,
|
||||
"URI": xrpl.convertStringToHex(operationalTokenUrlField.value),
|
||||
"Flags": parseInt(operationalFlagsField.value),
|
||||
"Issuer": operationalIssuerField.value,
|
||||
"TransferFee": parseInt(operationalTransferFeeField.value),
|
||||
"NFTokenTaxon": 0 //Required, but if you have no use for it, set to zero.
|
||||
}
|
||||
|
||||
// ----------------------------------------------------- Submit signed blob
|
||||
const tx = await client.submitAndWait(tx_json, { wallet: operational_wallet} )
|
||||
const nfts = await client.request({
|
||||
method: "account_nfts",
|
||||
account: operational_wallet.classicAddress
|
||||
})
|
||||
|
||||
// ------------------------------------------------------- Report results
|
||||
results += '\n\nTransaction result: '+ tx.result.meta.TransactionResult
|
||||
results += '\n\nnfts: ' + JSON.stringify(nfts, null, 2)
|
||||
results += await client.getXrpBalance(operational_wallet.address)
|
||||
operationalResultField.value = results
|
||||
client.disconnect()
|
||||
} //End of oPmintToken
|
||||
|
||||
@@ -6,25 +6,24 @@ async function getAccountFromSeed() {
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
results = 'Connecting to ' + getNet() + '....'
|
||||
document.getElementById('standbyResultField').value = results
|
||||
standbyResultField.value = results
|
||||
await client.connect()
|
||||
results += '\nConnected, finding wallets.\n'
|
||||
document.getElementById('standbyResultField').value = results
|
||||
standbyResultField.value = results
|
||||
|
||||
// -------------------------------------------- Find the test account wallet.
|
||||
var theSeed = document.getElementById('seeds').value
|
||||
var theSeed = seeds.value
|
||||
const standby_wallet = xrpl.Wallet.fromSeed(theSeed)
|
||||
|
||||
// ------------------------------------------------- Get the current balance.
|
||||
const standby_balance = (await client.getXrpBalance(standby_wallet.address))
|
||||
|
||||
// --------------------------------- Populate the fields for Standby account.
|
||||
document.getElementById('standbyAccountField').value = standby_wallet.address
|
||||
document.getElementById('standbyPubKeyField').value = standby_wallet.publicKey
|
||||
document.getElementById('standbyPrivKeyField').value = standby_wallet.privateKey
|
||||
document.getElementById('standbySeedField').value = standby_wallet.seed
|
||||
document.getElementById('standbyBalanceField').value =
|
||||
(await client.getXrpBalance(standby_wallet.address))
|
||||
standbyAccountField.value = standby_wallet.address
|
||||
standbyPubKeyField.value = standby_wallet.publicKey
|
||||
standbyPrivKeyField.value = standby_wallet.privateKey
|
||||
standbySeedField.value = standby_wallet.seed
|
||||
standbyBalanceField.value = (await client.getXrpBalance(standby_wallet.address))
|
||||
|
||||
client.disconnect()
|
||||
|
||||
@@ -34,15 +33,15 @@ async function getAccountFromSeed() {
|
||||
// **************** Get Batch Tokens *********************
|
||||
// *******************************************************
|
||||
|
||||
async function getBatchNFTokens() {
|
||||
async function getBatchNFTs() {
|
||||
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
results = 'Connecting to ' + net + '...'
|
||||
document.getElementById('standbyResultField').value = results
|
||||
standbyResultField.value = results
|
||||
await client.connect()
|
||||
results += '\nConnected. Getting NFTokens...'
|
||||
document.getElementById('standbyResultField').value = results
|
||||
results += '\nConnected. Getting NFTs...'
|
||||
standbyResultField.value = results
|
||||
|
||||
results += "\n\nNFTs:\n"
|
||||
let nfts = await client.request({
|
||||
@@ -62,7 +61,7 @@ async function getBatchNFTokens() {
|
||||
})
|
||||
results += '\n' + JSON.stringify(nfts,null,2)
|
||||
}
|
||||
document.getElementById('standbyResultField').value = results
|
||||
standbyResultField.value = results
|
||||
client.disconnect()
|
||||
} //End of getBatchTokens()
|
||||
|
||||
@@ -77,12 +76,12 @@ async function batchMint() {
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
results = 'Connecting to ' + getNet() + '....'
|
||||
document.getElementById('standbyResultField').value = results
|
||||
standbyResultField.value = results
|
||||
await client.connect()
|
||||
results += '\nConnected, finding wallet.'
|
||||
document.getElementById('standbyResultField').value = results
|
||||
standbyResultField.value = results
|
||||
standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
|
||||
document.getElementById('standbyResultField').value = results
|
||||
standbyResultField.value = results
|
||||
|
||||
//----------------- Get account information, particularly the Sequence number.
|
||||
|
||||
@@ -93,15 +92,15 @@ async function batchMint() {
|
||||
|
||||
my_sequence = account_info.result.account_data.Sequence
|
||||
results += "\n\nSequence Number: " + my_sequence + "\n\n"
|
||||
document.getElementById('standbyResultField').value = results
|
||||
standbyResultField.value = results
|
||||
|
||||
// ###################################
|
||||
// Create ticket numbers for the batch
|
||||
|
||||
// Without tickets, if one transaction fails, all others in the batch fail.
|
||||
// With tickets, there can be failures, but the rest will continue, and you
|
||||
// can investigate any problems afterward.
|
||||
/* ###################################
|
||||
Create ticket numbers for the batch
|
||||
|
||||
Without tickets, if one transaction fails, all others in the batch fail.
|
||||
With tickets, there can be failures, but the rest will continue, and you
|
||||
can investigate any problems afterward.
|
||||
*/
|
||||
|
||||
//---------------------- Parse the requested number from NFTokenCountField.
|
||||
const nftokenCount = parseInt(standbyNFTokenCountField.value)
|
||||
@@ -134,11 +133,11 @@ async function batchMint() {
|
||||
}
|
||||
|
||||
//-------------------------------------------------------- Report progress.
|
||||
results += "Tickets generated, minting NFTokens.\n\n"
|
||||
document.getElementById('standbyResultField').value = results
|
||||
results += "Tickets generated, minting NFTs.\n\n"
|
||||
standbyResultField.value = results
|
||||
|
||||
// ###################################
|
||||
// Mint NFTokens
|
||||
// Mint NFTs
|
||||
|
||||
for (let i=0; i < nftokenCount; i++) {
|
||||
const transactionBlob = {
|
||||
@@ -176,11 +175,8 @@ async function batchMint() {
|
||||
}
|
||||
|
||||
results += '\n\nTransaction result: '+ tx.result.meta.TransactionResult
|
||||
results += '\n\nnftokens: ' + JSON.stringify(nfts, null, 2)
|
||||
document.getElementById('standbyBalanceField').value =
|
||||
(await client.getXrpBalance(standby_wallet.address))
|
||||
document.getElementById('standbyResultField').value = results
|
||||
results += '\n\nNFTs: ' + JSON.stringify(nfts, null, 2)
|
||||
standbyBalanceField.value = (await client.getXrpBalance(standby_wallet.address))
|
||||
standbyResultField.value = results
|
||||
client.disconnect()
|
||||
} // End of batchMint()
|
||||
|
||||
|
||||
} // End of batchMint()
|
||||
5
content/_code-samples/quickstart/py/ReadMe.md
Normal file
@@ -0,0 +1,5 @@
|
||||
# Quickstart Python Examples
|
||||
|
||||
Run a test harness for XRPL features using Python UI and module files.
|
||||
|
||||
The examples are iterative, building one on another to gradually introduce new behavior. For a full explanation, see the XRPL Quickstart Tutorial (Python).
|
||||
162
content/_code-samples/quickstart/py/lesson1-send-xrp.py
Normal file
@@ -0,0 +1,162 @@
|
||||
import tkinter as tk
|
||||
import xrpl
|
||||
import json
|
||||
|
||||
from mod1 import get_account, get_account_info, send_xrp
|
||||
|
||||
#############################################
|
||||
## Handlers #################################
|
||||
#############################################
|
||||
|
||||
# sb seed: snk7pMfHPZoUpwMQuFApo3XTLRJhn
|
||||
# op seed: spmiHeaCDMFX56SNZVsCbi34WEE52
|
||||
|
||||
def get_standby_account():
|
||||
new_wallet = get_account(ent_standby_seed.get())
|
||||
ent_standby_account.delete(0, tk.END)
|
||||
ent_standby_seed.delete(0, tk.END)
|
||||
ent_standby_account.insert(0, new_wallet.classic_address)
|
||||
ent_standby_seed.insert(0, new_wallet.seed)
|
||||
|
||||
|
||||
def get_standby_account_info():
|
||||
accountInfo = get_account_info(ent_standby_account.get())
|
||||
ent_standby_balance.delete(0, tk.END)
|
||||
ent_standby_balance.insert(0,accountInfo['Balance'])
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0",json.dumps(accountInfo, indent=4))
|
||||
|
||||
|
||||
def standby_send_xrp():
|
||||
response = send_xrp(ent_standby_seed.get(),ent_standby_amount.get(),
|
||||
ent_standby_destination.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0",json.dumps(response.result, indent=4))
|
||||
get_standby_account_info()
|
||||
get_operational_account_info()
|
||||
|
||||
|
||||
def get_operational_account():
|
||||
new_wallet = get_account(ent_operational_seed.get())
|
||||
ent_operational_account.delete(0, tk.END)
|
||||
ent_operational_account.insert(0, new_wallet.classic_address)
|
||||
ent_operational_seed.delete(0, tk.END)
|
||||
ent_operational_seed.insert(0, new_wallet.seed)
|
||||
|
||||
|
||||
def get_operational_account_info():
|
||||
accountInfo = get_account_info(ent_operational_account.get())
|
||||
ent_operational_balance.delete(0, tk.END)
|
||||
ent_operational_balance.insert(0,accountInfo['Balance'])
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0",json.dumps(accountInfo, indent=4))
|
||||
|
||||
|
||||
def operational_send_xrp():
|
||||
response = send_xrp(ent_operational_seed.get(),ent_operational_amount.get(), ent_operational_destination.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0",json.dumps(response.result,indent=4))
|
||||
get_standby_account_info()
|
||||
get_operational_account_info()
|
||||
|
||||
|
||||
# Create a new window with the title "Quickstart Module 1"
|
||||
window = tk.Tk()
|
||||
window.title("Quickstart Module 1")
|
||||
|
||||
# Form frame
|
||||
frm_form = tk.Frame(relief=tk.SUNKEN, borderwidth=3)
|
||||
frm_form.pack()
|
||||
|
||||
# Create the Label and Entry widgets for "Standby Account"
|
||||
lbl_standy_seed = tk.Label(master=frm_form, text="Standby Seed")
|
||||
ent_standby_seed = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standby_account = tk.Label(master=frm_form, text="Standby Account")
|
||||
ent_standby_account = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standy_amount = tk.Label(master=frm_form, text="Amount")
|
||||
ent_standby_amount = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standby_destination = tk.Label(master=frm_form, text="Destination")
|
||||
ent_standby_destination = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standby_balance = tk.Label(master=frm_form, text="XRP Balance")
|
||||
ent_standby_balance = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standby_results = tk.Label(master=frm_form,text='Results')
|
||||
text_standby_results = tk.Text(master=frm_form, height = 20, width = 65)
|
||||
|
||||
# Place fields in a grid.
|
||||
lbl_standy_seed.grid(row=0, column=0, sticky="w")
|
||||
ent_standby_seed.grid(row=0, column=1)
|
||||
lbl_standby_account.grid(row=2, column=0, sticky="e")
|
||||
ent_standby_account.grid(row=2, column=1)
|
||||
lbl_standy_amount.grid(row=3, column=0, sticky="e")
|
||||
ent_standby_amount.grid(row=3, column=1)
|
||||
lbl_standby_destination.grid(row=4, column=0, sticky="e")
|
||||
ent_standby_destination.grid(row=4, column=1)
|
||||
lbl_standby_balance.grid(row=5, column=0, sticky="e")
|
||||
ent_standby_balance.grid(row=5, column=1)
|
||||
lbl_standby_results.grid(row=6, column=0, sticky="ne")
|
||||
text_standby_results.grid(row=6, column=1, sticky="nw")
|
||||
|
||||
###############################################
|
||||
## Operational Account ########################
|
||||
###############################################
|
||||
|
||||
# Create the Label and Entry widgets for "Operational Account"
|
||||
lbl_operational_seed = tk.Label(master=frm_form, text="Operational Seed")
|
||||
ent_operational_seed = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_account = tk.Label(master=frm_form, text="Operational Account")
|
||||
ent_operational_account = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_amount = tk.Label(master=frm_form, text="Amount")
|
||||
ent_operational_amount = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_destination = tk.Label(master=frm_form, text="Destination")
|
||||
ent_operational_destination = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_balance = tk.Label(master=frm_form, text="XRP Balance")
|
||||
ent_operational_balance = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_results = tk.Label(master=frm_form,text='Results')
|
||||
text_operational_results = tk.Text(master=frm_form, height = 20, width = 65)
|
||||
|
||||
|
||||
#Place the widgets in a grid
|
||||
lbl_operational_seed.grid(row=0, column=4, sticky="e")
|
||||
ent_operational_seed.grid(row=0, column=5, sticky="w")
|
||||
lbl_operational_account.grid(row=2,column=4, sticky="e")
|
||||
ent_operational_account.grid(row=2,column=5, sticky="w")
|
||||
lbl_operational_amount.grid(row=3, column=4, sticky="e")
|
||||
ent_operational_amount.grid(row=3, column=5, sticky="w")
|
||||
lbl_operational_destination.grid(row=4, column=4, sticky="e")
|
||||
ent_operational_destination.grid(row=4, column=5, sticky="w")
|
||||
lbl_operational_balance.grid(row=5, column=4, sticky="e")
|
||||
ent_operational_balance.grid(row=5, column=5, sticky="w")
|
||||
lbl_operational_results.grid(row=6, column=4, sticky="ne")
|
||||
text_operational_results.grid(row=6, column=5, sticky="nw")
|
||||
|
||||
#############################################
|
||||
## Buttons ##################################
|
||||
#############################################
|
||||
|
||||
# Create the Get Standby Account Buttons
|
||||
btn_get_standby_account = tk.Button(master=frm_form, text="Get Standby Account",
|
||||
command = get_standby_account)
|
||||
btn_get_standby_account.grid(row=0, column=2, sticky = "nsew")
|
||||
btn_get_standby_account_info = tk.Button(master=frm_form,
|
||||
text="Get Standby Account Info",
|
||||
command = get_standby_account_info)
|
||||
btn_get_standby_account_info.grid(row=1, column=2, sticky = "nsew")
|
||||
btn_standby_send_xrp = tk.Button(master=frm_form, text="Send XRP >",
|
||||
command = standby_send_xrp)
|
||||
btn_standby_send_xrp.grid(row=2, column = 2, sticky = "nsew")
|
||||
|
||||
# Create the Operational Account Buttons
|
||||
btn_get_operational_account = tk.Button(master=frm_form,
|
||||
text="Get Operational Account",
|
||||
command = get_operational_account)
|
||||
btn_get_operational_account.grid(row=0, column=3, sticky = "nsew")
|
||||
btn_get_op_account_info = tk.Button(master=frm_form, text="Get Op Account Info",
|
||||
command = get_operational_account_info)
|
||||
btn_get_op_account_info.grid(row=1, column=3, sticky = "nsew")
|
||||
btn_op_send_xrp = tk.Button(master=frm_form, text="< Send XRP",
|
||||
command = operational_send_xrp)
|
||||
btn_op_send_xrp.grid(row=2, column = 3, sticky = "nsew")
|
||||
|
||||
|
||||
# Start the application
|
||||
window.mainloop()
|
||||
273
content/_code-samples/quickstart/py/lesson2-send-currency.py
Normal file
@@ -0,0 +1,273 @@
|
||||
import tkinter as tk
|
||||
import xrpl
|
||||
import json
|
||||
|
||||
from mod1 import get_account, get_account_info, send_xrp
|
||||
from mod2 import (
|
||||
create_trust_line,
|
||||
send_currency,
|
||||
get_balance,
|
||||
configure_account,
|
||||
)
|
||||
|
||||
#############################################
|
||||
## Handlers #################################
|
||||
#############################################
|
||||
|
||||
# Module 2 Handlers
|
||||
def standby_create_trust_line():
|
||||
results = create_trust_line(ent_standby_seed.get(),
|
||||
ent_standby_destination.get(),
|
||||
ent_standby_currency.get(),
|
||||
ent_standby_amount.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def standby_send_currency():
|
||||
results = send_currency(ent_standby_seed.get(),
|
||||
ent_standby_destination.get(),
|
||||
ent_standby_currency.get(),
|
||||
ent_standby_amount.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def standby_configure_account():
|
||||
results = configure_account(
|
||||
ent_standby_seed.get(),
|
||||
standbyRippling)
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def operational_create_trust_line():
|
||||
results = create_trust_line(ent_operational_seed.get(),
|
||||
ent_operational_destination.get(),
|
||||
ent_operational_currency.get(),
|
||||
ent_operational_amount.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def operational_send_currency():
|
||||
results = send_currency(ent_operational_seed.get(),
|
||||
ent_operational_destination.get(),
|
||||
ent_operational_currency.get(),
|
||||
ent_operational_amount.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def operational_configure_account():
|
||||
results = configure_account(
|
||||
ent_operational_seed.get(),
|
||||
operationalRippling)
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def get_balances():
|
||||
results = get_balance(ent_operational_account.get(), ent_standby_account.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
results = get_balance(ent_standby_account.get(), ent_operational_account.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
# Module 1 Handlers
|
||||
def get_standby_account():
|
||||
new_wallet = get_account(ent_standby_seed.get())
|
||||
ent_standby_account.delete(0, tk.END)
|
||||
ent_standby_seed.delete(0, tk.END)
|
||||
ent_standby_account.insert(0, new_wallet.classic_address)
|
||||
ent_standby_seed.insert(0, new_wallet.seed)
|
||||
|
||||
|
||||
def get_standby_account_info():
|
||||
accountInfo = get_account_info(ent_standby_account.get())
|
||||
ent_standby_balance.delete(0, tk.END)
|
||||
ent_standby_balance.insert(0,accountInfo['Balance'])
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0",json.dumps(accountInfo, indent=4))
|
||||
|
||||
|
||||
def standby_send_xrp():
|
||||
response = send_xrp(ent_standby_seed.get(),ent_standby_amount.get(),
|
||||
ent_standby_destination.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0",json.dumps(response.result, indent=4))
|
||||
get_standby_account_info()
|
||||
get_operational_account_info()
|
||||
|
||||
|
||||
def get_operational_account():
|
||||
new_wallet = get_account(ent_operational_seed.get())
|
||||
ent_operational_account.delete(0, tk.END)
|
||||
ent_operational_account.insert(0, new_wallet.classic_address)
|
||||
ent_operational_seed.delete(0, tk.END)
|
||||
ent_operational_seed.insert(0, new_wallet.seed)
|
||||
|
||||
|
||||
def get_operational_account_info():
|
||||
accountInfo = get_account_info(ent_operational_account.get())
|
||||
ent_operational_balance.delete(0, tk.END)
|
||||
ent_operational_balance.insert(0,accountInfo['Balance'])
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0",json.dumps(accountInfo, indent=4))
|
||||
|
||||
|
||||
def operational_send_xrp():
|
||||
response = send_xrp(ent_operational_seed.get(),ent_operational_amount.get(), ent_operational_destination.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0",json.dumps(response.result,indent=4))
|
||||
get_standby_account_info()
|
||||
get_operational_account_info()
|
||||
|
||||
|
||||
# Create a new window with the title "Quickstart Module 2"
|
||||
window = tk.Tk()
|
||||
window.title("Quickstart Module 2")
|
||||
|
||||
|
||||
standbyRippling = tk.BooleanVar()
|
||||
operationalRippling = tk.BooleanVar()
|
||||
|
||||
|
||||
# Form frame
|
||||
frm_form = tk.Frame(relief=tk.SUNKEN, borderwidth=3)
|
||||
frm_form.pack()
|
||||
|
||||
# Create the Label and Entry widgets for "Standby Account"
|
||||
lbl_standy_seed = tk.Label(master=frm_form, text="Standby Seed")
|
||||
ent_standby_seed = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standby_account = tk.Label(master=frm_form, text="Standby Account")
|
||||
ent_standby_account = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standy_amount = tk.Label(master=frm_form, text="Amount")
|
||||
ent_standby_amount = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standby_destination = tk.Label(master=frm_form, text="Destination")
|
||||
ent_standby_destination = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standby_balance = tk.Label(master=frm_form, text="XRP Balance")
|
||||
ent_standby_balance = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standby_currency = tk.Label(master=frm_form, text="Currency")
|
||||
ent_standby_currency = tk.Entry(master=frm_form, width=50)
|
||||
cb_standby_allow_rippling = tk.Checkbutton(master=frm_form, text="Allow Rippling", variable=standbyRippling, onvalue=True, offvalue=False)
|
||||
lbl_standby_results = tk.Label(master=frm_form,text='Results')
|
||||
text_standby_results = tk.Text(master=frm_form, height = 20, width = 65)
|
||||
|
||||
# Place field in a grid.
|
||||
lbl_standy_seed.grid(row=0, column=0, sticky="w")
|
||||
ent_standby_seed.grid(row=0, column=1)
|
||||
lbl_standby_account.grid(row=2, column=0, sticky="e")
|
||||
ent_standby_account.grid(row=2, column=1)
|
||||
lbl_standy_amount.grid(row=3, column=0, sticky="e")
|
||||
ent_standby_amount.grid(row=3, column=1)
|
||||
lbl_standby_destination.grid(row=4, column=0, sticky="e")
|
||||
ent_standby_destination.grid(row=4, column=1)
|
||||
lbl_standby_balance.grid(row=5, column=0, sticky="e")
|
||||
ent_standby_balance.grid(row=5, column=1)
|
||||
lbl_standby_currency.grid(row=6, column=0, sticky="e")
|
||||
ent_standby_currency.grid(row=6, column=1)
|
||||
cb_standby_allow_rippling.grid(row=7,column=1, sticky="w")
|
||||
lbl_standby_results.grid(row=8, column=0, sticky="ne")
|
||||
text_standby_results.grid(row=8, column=1, sticky="nw")
|
||||
cb_standby_allow_rippling.select()
|
||||
|
||||
###############################################
|
||||
## Operational Account ########################
|
||||
###############################################
|
||||
|
||||
# Create the Label and Entry widgets for "Operational Account"
|
||||
lbl_operational_seed = tk.Label(master=frm_form, text="Operational Seed")
|
||||
ent_operational_seed = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_account = tk.Label(master=frm_form, text="Operational Account")
|
||||
ent_operational_account = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_amount = tk.Label(master=frm_form, text="Amount")
|
||||
ent_operational_amount = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_destination = tk.Label(master=frm_form, text="Destination")
|
||||
ent_operational_destination = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_balance = tk.Label(master=frm_form, text="XRP Balance")
|
||||
ent_operational_balance = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_currency = tk.Label(master=frm_form, text="Currency")
|
||||
ent_operational_currency = tk.Entry(master=frm_form, width=50)
|
||||
cb_operational_allow_rippling = tk.Checkbutton(master=frm_form, text="Allow Rippling", variable=operationalRippling, onvalue=True, offvalue=False)
|
||||
|
||||
lbl_operational_results = tk.Label(master=frm_form,text='Results')
|
||||
text_operational_results = tk.Text(master=frm_form, height = 20, width = 65)
|
||||
|
||||
#Place the widgets in a grid
|
||||
lbl_operational_seed.grid(row=0, column=4, sticky="e")
|
||||
ent_operational_seed.grid(row=0, column=5, sticky="w")
|
||||
lbl_operational_account.grid(row=2,column=4, sticky="e")
|
||||
ent_operational_account.grid(row=2,column=5, sticky="w")
|
||||
lbl_operational_amount.grid(row=3, column=4, sticky="e")
|
||||
ent_operational_amount.grid(row=3, column=5, sticky="w")
|
||||
lbl_operational_destination.grid(row=4, column=4, sticky="e")
|
||||
ent_operational_destination.grid(row=4, column=5, sticky="w")
|
||||
lbl_operational_balance.grid(row=5, column=4, sticky="e")
|
||||
ent_operational_balance.grid(row=5, column=5, sticky="w")
|
||||
lbl_operational_currency.grid(row=6, column=4, sticky="e")
|
||||
ent_operational_currency.grid(row=6, column=5)
|
||||
cb_operational_allow_rippling.grid(row=7,column=5, sticky="w")
|
||||
lbl_operational_results.grid(row=8, column=4, sticky="ne")
|
||||
text_operational_results.grid(row=8, column=5, sticky="nw")
|
||||
cb_operational_allow_rippling.select()
|
||||
|
||||
#############################################
|
||||
## Buttons ##################################
|
||||
#############################################
|
||||
|
||||
# Create the Standby Account Buttons
|
||||
btn_get_standby_account = tk.Button(master=frm_form, text="Get Standby Account",
|
||||
command = get_standby_account)
|
||||
btn_get_standby_account.grid(row=0, column=2, sticky = "nsew")
|
||||
btn_get_standby_account_info = tk.Button(master=frm_form,
|
||||
text="Get Standby Account Info",
|
||||
command = get_standby_account_info)
|
||||
btn_get_standby_account_info.grid(row=1, column=2, sticky = "nsew")
|
||||
btn_standby_send_xrp = tk.Button(master=frm_form, text="Send XRP >",
|
||||
command = standby_send_xrp)
|
||||
btn_standby_send_xrp.grid(row=2, column = 2, sticky = "nsew")
|
||||
btn_standby_create_trust_line = tk.Button(master=frm_form,
|
||||
text="Create Trust Line",
|
||||
command = standby_create_trust_line)
|
||||
btn_standby_create_trust_line.grid(row=3, column=2, sticky = "nsew")
|
||||
btn_standby_send_currency = tk.Button(master=frm_form, text="Send Currency >",
|
||||
command = standby_send_currency)
|
||||
btn_standby_send_currency.grid(row=4, column=2, sticky = "nsew")
|
||||
btn_standby_send_currency = tk.Button(master=frm_form, text="Get Balances",
|
||||
command = get_balances)
|
||||
btn_standby_send_currency.grid(row=5, column=2, sticky = "nsew")
|
||||
btn_standby_configure_account = tk.Button(master=frm_form,
|
||||
text="Configure Account",
|
||||
command = standby_configure_account)
|
||||
btn_standby_configure_account.grid(row=7,column=0, sticky = "nsew")
|
||||
|
||||
|
||||
# Create the Operational Account Buttons
|
||||
btn_get_operational_account = tk.Button(master=frm_form,
|
||||
text="Get Operational Account",
|
||||
command = get_operational_account)
|
||||
btn_get_operational_account.grid(row=0, column=3, sticky = "nsew")
|
||||
btn_get_op_account_info = tk.Button(master=frm_form, text="Get Op Account Info",
|
||||
command = get_operational_account_info)
|
||||
btn_get_op_account_info.grid(row=1, column=3, sticky = "nsew")
|
||||
btn_op_send_xrp = tk.Button(master=frm_form, text="< Send XRP",
|
||||
command = operational_send_xrp)
|
||||
btn_op_send_xrp.grid(row=2, column = 3, sticky = "nsew")
|
||||
btn_op_create_trust_line = tk.Button(master=frm_form, text="Create Trust Line",
|
||||
command = operational_create_trust_line)
|
||||
btn_op_create_trust_line.grid(row=3, column=3, sticky = "nsew")
|
||||
btn_op_send_currency = tk.Button(master=frm_form, text="< Send Currency",
|
||||
command = operational_send_currency)
|
||||
btn_op_send_currency.grid(row=4, column=3, sticky = "nsew")
|
||||
btn_op_get_balances = tk.Button(master=frm_form, text="Get Balances",
|
||||
command = get_balances)
|
||||
btn_op_get_balances.grid(row=5, column=3, sticky = "nsew")
|
||||
btn_op_configure_account = tk.Button(master=frm_form, text="Configure Account",
|
||||
command = operational_configure_account)
|
||||
btn_op_configure_account.grid(row=7,column=4, sticky = "nsew")
|
||||
|
||||
# Start the application
|
||||
window.mainloop()
|
||||
396
content/_code-samples/quickstart/py/lesson3-mint-token.py
Normal file
@@ -0,0 +1,396 @@
|
||||
import tkinter as tk
|
||||
import xrpl
|
||||
import json
|
||||
|
||||
from mod1 import get_account, get_account_info, send_xrp
|
||||
from mod2 import (
|
||||
create_trust_line,
|
||||
send_currency,
|
||||
get_balance,
|
||||
configure_account,
|
||||
)
|
||||
from mod3 import (
|
||||
mint_token,
|
||||
get_tokens,
|
||||
burn_token,
|
||||
)
|
||||
|
||||
#############################################
|
||||
## Handlers #################################
|
||||
#############################################
|
||||
|
||||
# Module 3 Handlers
|
||||
|
||||
def standby_mint_token():
|
||||
results = mint_token(
|
||||
ent_standby_seed.get(),
|
||||
ent_standby_uri.get(),
|
||||
ent_standby_flags.get(),
|
||||
ent_standby_transfer_fee.get(),
|
||||
ent_standby_taxon.get()
|
||||
)
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def standby_get_tokens():
|
||||
results = get_tokens(ent_standby_account.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def standby_burn_token():
|
||||
results = burn_token(
|
||||
ent_standby_seed.get(),
|
||||
ent_standby_nft_id.get()
|
||||
)
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def operational_mint_token():
|
||||
results = mint_token(
|
||||
ent_operational_seed.get(),
|
||||
ent_operational_uri.get(),
|
||||
ent_operational_flags.get(),
|
||||
ent_operational_transfer_fee.get(),
|
||||
ent_operational_taxon.get()
|
||||
)
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def operational_get_tokens():
|
||||
results = get_tokens(ent_operational_account.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def operational_burn_token():
|
||||
results = burn_token(
|
||||
ent_operational_seed.get(),
|
||||
ent_operational_nft_id.get()
|
||||
)
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
# Module 2 Handlers
|
||||
|
||||
def standby_create_trust_line():
|
||||
results = create_trust_line(ent_standby_seed.get(),
|
||||
ent_standby_destination.get(),
|
||||
ent_standby_currency.get(),
|
||||
ent_standby_amount.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def standby_send_currency():
|
||||
results = send_currency(ent_standby_seed.get(),
|
||||
ent_standby_destination.get(),
|
||||
ent_standby_currency.get(),
|
||||
ent_standby_amount.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def standby_configure_account():
|
||||
results = configure_account(
|
||||
ent_standby_seed.get(),
|
||||
standbyRippling)
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def operational_create_trust_line():
|
||||
results = create_trust_line(ent_operational_seed.get(),
|
||||
ent_operational_destination.get(),
|
||||
ent_operational_currency.get(),
|
||||
ent_operational_amount.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def operational_send_currency():
|
||||
results = send_currency(ent_operational_seed.get(),
|
||||
ent_operational_destination.get(),
|
||||
ent_operational_currency.get(),
|
||||
ent_operational_amount.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def operational_configure_account():
|
||||
results = configure_account(
|
||||
ent_operational_seed.get(),
|
||||
operationalRippling)
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def get_balances():
|
||||
results = get_balance(ent_operational_account.get(), ent_standby_account.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
results = get_balance(ent_standby_account.get(), ent_operational_account.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
# Module 1 Handlers
|
||||
def get_standby_account():
|
||||
new_wallet = get_account(ent_standby_seed.get())
|
||||
ent_standby_account.delete(0, tk.END)
|
||||
ent_standby_seed.delete(0, tk.END)
|
||||
ent_standby_account.insert(0, new_wallet.classic_address)
|
||||
ent_standby_seed.insert(0, new_wallet.seed)
|
||||
|
||||
|
||||
def get_standby_account_info():
|
||||
accountInfo = get_account_info(ent_standby_account.get())
|
||||
ent_standby_balance.delete(0, tk.END)
|
||||
ent_standby_balance.insert(0,accountInfo['Balance'])
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0",json.dumps(accountInfo, indent=4))
|
||||
|
||||
|
||||
def standby_send_xrp():
|
||||
response = send_xrp(ent_standby_seed.get(),ent_standby_amount.get(),
|
||||
ent_standby_destination.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0",json.dumps(response.result, indent=4))
|
||||
get_standby_account_info()
|
||||
get_operational_account_info()
|
||||
|
||||
|
||||
def get_operational_account():
|
||||
new_wallet = get_account(ent_operational_seed.get())
|
||||
ent_operational_account.delete(0, tk.END)
|
||||
ent_operational_account.insert(0, new_wallet.classic_address)
|
||||
ent_operational_seed.delete(0, tk.END)
|
||||
ent_operational_seed.insert(0, new_wallet.seed)
|
||||
|
||||
|
||||
def get_operational_account_info():
|
||||
accountInfo = get_account_info(ent_operational_account.get())
|
||||
ent_operational_balance.delete(0, tk.END)
|
||||
ent_operational_balance.insert(0,accountInfo['Balance'])
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0",json.dumps(accountInfo, indent=4))
|
||||
|
||||
|
||||
def operational_send_xrp():
|
||||
response = send_xrp(ent_operational_seed.get(),ent_operational_amount.get(), ent_operational_destination.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0",json.dumps(response.result,indent=4))
|
||||
get_standby_account_info()
|
||||
get_operational_account_info()
|
||||
|
||||
|
||||
# Create a new window with the title "Quickstart Module 3"
|
||||
window = tk.Tk()
|
||||
window.title("Quickstart Module 3")
|
||||
|
||||
|
||||
standbyRippling = tk.BooleanVar()
|
||||
operationalRippling = tk.BooleanVar()
|
||||
|
||||
|
||||
# Form frame
|
||||
frm_form = tk.Frame(relief=tk.SUNKEN, borderwidth=3)
|
||||
frm_form.pack()
|
||||
|
||||
# Create the Label and Entry widgets for "Standby Account"
|
||||
lbl_standy_seed = tk.Label(master=frm_form, text="Standby Seed")
|
||||
ent_standby_seed = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standby_account = tk.Label(master=frm_form, text="Standby Account")
|
||||
ent_standby_account = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standy_amount = tk.Label(master=frm_form, text="Amount")
|
||||
ent_standby_amount = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standby_destination = tk.Label(master=frm_form, text="Destination")
|
||||
ent_standby_destination = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standby_balance = tk.Label(master=frm_form, text="XRP Balance")
|
||||
ent_standby_balance = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standby_currency = tk.Label(master=frm_form, text="Currency")
|
||||
ent_standby_currency = tk.Entry(master=frm_form, width=50)
|
||||
cb_standby_allow_rippling = tk.Checkbutton(master=frm_form, text="Allow Rippling", variable=standbyRippling, onvalue=True, offvalue=False)
|
||||
lbl_standby_uri = tk.Label(master=frm_form, text="NFT URI")
|
||||
ent_standby_uri = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standby_flags = tk.Label(master=frm_form, text="Flags")
|
||||
ent_standby_flags = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standby_transfer_fee = tk.Label(master=frm_form, text="Transfer Fee")
|
||||
ent_standby_transfer_fee = tk.Entry(master=frm_form, width="50")
|
||||
lbl_standby_taxon = tk.Label(master=frm_form, text="Taxon")
|
||||
ent_standby_taxon = tk.Entry(master=frm_form, width="50")
|
||||
lbl_standby_nft_id = tk.Label(master=frm_form, text="NFT ID")
|
||||
ent_standby_nft_id = tk.Entry(master=frm_form, width="50")
|
||||
lbl_standby_results = tk.Label(master=frm_form,text='Results')
|
||||
text_standby_results = tk.Text(master=frm_form, height = 20, width = 65)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Place field in a grid.
|
||||
lbl_standy_seed.grid(row=0, column=0, sticky="w")
|
||||
ent_standby_seed.grid(row=0, column=1)
|
||||
lbl_standby_account.grid(row=2, column=0, sticky="e")
|
||||
ent_standby_account.grid(row=2, column=1)
|
||||
lbl_standy_amount.grid(row=3, column=0, sticky="e")
|
||||
ent_standby_amount.grid(row=3, column=1)
|
||||
lbl_standby_destination.grid(row=4, column=0, sticky="e")
|
||||
ent_standby_destination.grid(row=4, column=1)
|
||||
lbl_standby_balance.grid(row=5, column=0, sticky="e")
|
||||
ent_standby_balance.grid(row=5, column=1)
|
||||
lbl_standby_currency.grid(row=6, column=0, sticky="e")
|
||||
ent_standby_currency.grid(row=6, column=1)
|
||||
cb_standby_allow_rippling.grid(row=7,column=1, sticky="w")
|
||||
lbl_standby_uri.grid(row=8, column=0, sticky="e")
|
||||
ent_standby_uri.grid(row=8, column=1, sticky="w")
|
||||
lbl_standby_flags.grid(row=9, column=0, sticky="e")
|
||||
ent_standby_flags.grid(row=9, column=1, sticky="w")
|
||||
lbl_standby_transfer_fee.grid(row=10, column=0, sticky="e")
|
||||
ent_standby_transfer_fee.grid(row=10, column=1, sticky="w")
|
||||
lbl_standby_taxon.grid(row=11, column=0, sticky="e")
|
||||
ent_standby_taxon.grid(row=11, column=1, sticky="w")
|
||||
lbl_standby_nft_id.grid(row=12, column=0, sticky="e")
|
||||
ent_standby_nft_id.grid(row=12, column=1, sticky="w")
|
||||
lbl_standby_results.grid(row=13, column=0, sticky="ne")
|
||||
text_standby_results.grid(row=13, column=1, sticky="nw")
|
||||
cb_standby_allow_rippling.select()
|
||||
|
||||
###############################################
|
||||
## Operational Account ########################
|
||||
###############################################
|
||||
|
||||
# Create the Label and Entry widgets for "Operational Account"
|
||||
lbl_operational_seed = tk.Label(master=frm_form, text="Operational Seed")
|
||||
ent_operational_seed = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_account = tk.Label(master=frm_form, text="Operational Account")
|
||||
ent_operational_account = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_amount = tk.Label(master=frm_form, text="Amount")
|
||||
ent_operational_amount = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_destination = tk.Label(master=frm_form, text="Destination")
|
||||
ent_operational_destination = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_balance = tk.Label(master=frm_form, text="XRP Balance")
|
||||
ent_operational_balance = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_currency = tk.Label(master=frm_form, text="Currency")
|
||||
ent_operational_currency = tk.Entry(master=frm_form, width=50)
|
||||
cb_operational_allow_rippling = tk.Checkbutton(master=frm_form, text="Allow Rippling", variable=operationalRippling, onvalue=True, offvalue=False)
|
||||
lbl_operational_uri = tk.Label(master=frm_form, text="NFT URI")
|
||||
ent_operational_uri = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_flags = tk.Label(master=frm_form, text="Flags")
|
||||
ent_operational_flags = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_transfer_fee = tk.Label(master=frm_form, text="Transfer Fee")
|
||||
ent_operational_transfer_fee = tk.Entry(master=frm_form, width="50")
|
||||
lbl_operational_taxon = tk.Label(master=frm_form, text="Taxon")
|
||||
ent_operational_taxon = tk.Entry(master=frm_form, width="50")
|
||||
lbl_operational_nft_id = tk.Label(master=frm_form, text="NFT ID")
|
||||
ent_operational_nft_id = tk.Entry(master=frm_form, width="50")
|
||||
lbl_operational_results = tk.Label(master=frm_form,text='Results')
|
||||
text_operational_results = tk.Text(master=frm_form, height = 20, width = 65)
|
||||
|
||||
#Place the widgets in a grid
|
||||
lbl_operational_seed.grid(row=0, column=4, sticky="e")
|
||||
ent_operational_seed.grid(row=0, column=5, sticky="w")
|
||||
lbl_operational_account.grid(row=2,column=4, sticky="e")
|
||||
ent_operational_account.grid(row=2,column=5, sticky="w")
|
||||
lbl_operational_amount.grid(row=3, column=4, sticky="e")
|
||||
ent_operational_amount.grid(row=3, column=5, sticky="w")
|
||||
lbl_operational_destination.grid(row=4, column=4, sticky="e")
|
||||
ent_operational_destination.grid(row=4, column=5, sticky="w")
|
||||
lbl_operational_balance.grid(row=5, column=4, sticky="e")
|
||||
ent_operational_balance.grid(row=5, column=5, sticky="w")
|
||||
lbl_operational_currency.grid(row=6, column=4, sticky="e")
|
||||
ent_operational_currency.grid(row=6, column=5)
|
||||
cb_operational_allow_rippling.grid(row=7,column=5, sticky="w")
|
||||
lbl_operational_uri.grid(row=8, column=4, sticky="e")
|
||||
ent_operational_uri.grid(row=8, column=5, sticky="w")
|
||||
lbl_operational_flags.grid(row=9, column=4, sticky="e")
|
||||
ent_operational_flags.grid(row=9, column=5, sticky="w")
|
||||
lbl_operational_transfer_fee.grid(row=10, column=4, sticky="e")
|
||||
ent_operational_transfer_fee.grid(row=10, column=5, sticky="w")
|
||||
lbl_operational_taxon.grid(row=11, column=4, sticky="e")
|
||||
ent_operational_taxon.grid(row=11, column=5, sticky="w")
|
||||
lbl_operational_nft_id.grid(row=12, column=4, sticky="e")
|
||||
ent_operational_nft_id.grid(row=12, column=5, sticky="w")
|
||||
lbl_operational_results.grid(row=13, column=4, sticky="ne")
|
||||
text_operational_results.grid(row=13, column=5, sticky="nw")
|
||||
|
||||
cb_operational_allow_rippling.select()
|
||||
|
||||
#############################################
|
||||
## Buttons ##################################
|
||||
#############################################
|
||||
|
||||
# Create the Standby Account Buttons
|
||||
btn_get_standby_account = tk.Button(master=frm_form, text="Get Standby Account",
|
||||
command = get_standby_account)
|
||||
btn_get_standby_account.grid(row=0, column=2, sticky = "nsew")
|
||||
btn_get_standby_account_info = tk.Button(master=frm_form,
|
||||
text="Get Standby Account Info",
|
||||
command = get_standby_account_info)
|
||||
btn_get_standby_account_info.grid(row=1, column=2, sticky = "nsew")
|
||||
btn_standby_send_xrp = tk.Button(master=frm_form, text="Send XRP >",
|
||||
command = standby_send_xrp)
|
||||
btn_standby_send_xrp.grid(row=2, column = 2, sticky = "nsew")
|
||||
btn_standby_create_trust_line = tk.Button(master=frm_form,
|
||||
text="Create Trust Line",
|
||||
command = standby_create_trust_line)
|
||||
btn_standby_create_trust_line.grid(row=3, column=2, sticky = "nsew")
|
||||
btn_standby_send_currency = tk.Button(master=frm_form, text="Send Currency >",
|
||||
command = standby_send_currency)
|
||||
btn_standby_send_currency.grid(row=4, column=2, sticky = "nsew")
|
||||
btn_standby_send_currency = tk.Button(master=frm_form, text="Get Balances",
|
||||
command = get_balances)
|
||||
btn_standby_send_currency.grid(row=5, column=2, sticky = "nsew")
|
||||
btn_standby_configure_account = tk.Button(master=frm_form,
|
||||
text="Configure Account",
|
||||
command = standby_configure_account)
|
||||
btn_standby_configure_account.grid(row=7,column=0, sticky = "nsew")
|
||||
btn_standby_mint_token = tk.Button(master=frm_form, text="Mint NFT",
|
||||
command = standby_mint_token)
|
||||
btn_standby_mint_token.grid(row=8, column=2, sticky="nsew")
|
||||
btn_standby_get_tokens = tk.Button(master=frm_form, text="Get NFTs",
|
||||
command = standby_get_tokens)
|
||||
btn_standby_get_tokens.grid(row=9, column=2, sticky="nsew")
|
||||
btn_standby_burn_token = tk.Button(master=frm_form, text="Burn NFT",
|
||||
command = standby_burn_token)
|
||||
btn_standby_burn_token.grid(row=10, column=2, sticky="nsew")
|
||||
|
||||
|
||||
# Create the Operational Account Buttons
|
||||
btn_get_operational_account = tk.Button(master=frm_form,
|
||||
text="Get Operational Account",
|
||||
command = get_operational_account)
|
||||
btn_get_operational_account.grid(row=0, column=3, sticky = "nsew")
|
||||
btn_get_op_account_info = tk.Button(master=frm_form, text="Get Op Account Info",
|
||||
command = get_operational_account_info)
|
||||
btn_get_op_account_info.grid(row=1, column=3, sticky = "nsew")
|
||||
btn_op_send_xrp = tk.Button(master=frm_form, text="< Send XRP",
|
||||
command = operational_send_xrp)
|
||||
btn_op_send_xrp.grid(row=2, column = 3, sticky = "nsew")
|
||||
btn_op_create_trust_line = tk.Button(master=frm_form, text="Create Trust Line",
|
||||
command = operational_create_trust_line)
|
||||
btn_op_create_trust_line.grid(row=3, column=3, sticky = "nsew")
|
||||
btn_op_send_currency = tk.Button(master=frm_form, text="< Send Currency",
|
||||
command = operational_send_currency)
|
||||
btn_op_send_currency.grid(row=4, column=3, sticky = "nsew")
|
||||
btn_op_get_balances = tk.Button(master=frm_form, text="Get Balances",
|
||||
command = get_balances)
|
||||
btn_op_get_balances.grid(row=5, column=3, sticky = "nsew")
|
||||
btn_op_configure_account = tk.Button(master=frm_form, text="Configure Account",
|
||||
command = operational_configure_account)
|
||||
btn_op_configure_account.grid(row=7,column=4, sticky = "nsew")
|
||||
btn_op_mint_token = tk.Button(master=frm_form, text="Mint NFT",
|
||||
command = operational_mint_token)
|
||||
btn_op_mint_token.grid(row=8, column=3, sticky="nsew")
|
||||
btn_op_get_tokens = tk.Button(master=frm_form, text="Get NFTs",
|
||||
command = operational_get_tokens)
|
||||
btn_op_get_tokens.grid(row=9, column=3, sticky="nsew")
|
||||
btn_op_burn_token = tk.Button(master=frm_form, text="Burn NFT",
|
||||
command = operational_burn_token)
|
||||
btn_op_burn_token.grid(row=10, column=3, sticky="nsew")
|
||||
|
||||
# Start the application
|
||||
window.mainloop()
|
||||
584
content/_code-samples/quickstart/py/lesson4-transfer-tokens.py
Normal file
@@ -0,0 +1,584 @@
|
||||
import tkinter as tk
|
||||
import xrpl
|
||||
import json
|
||||
|
||||
from mod1 import get_account, get_account_info, send_xrp
|
||||
from mod2 import (
|
||||
create_trust_line,
|
||||
send_currency,
|
||||
get_balance,
|
||||
configure_account,
|
||||
)
|
||||
from mod3 import (
|
||||
mint_token,
|
||||
get_tokens,
|
||||
burn_token,
|
||||
)
|
||||
from mod4 import (
|
||||
create_sell_offer,
|
||||
create_buy_offer,
|
||||
get_offers,
|
||||
cancel_offer,
|
||||
accept_sell_offer,
|
||||
accept_buy_offer,
|
||||
)
|
||||
|
||||
#############################################
|
||||
## Handlers #################################
|
||||
#############################################
|
||||
|
||||
# Module 4 Handlers
|
||||
|
||||
def standby_create_sell_offer():
|
||||
results = create_sell_offer(
|
||||
ent_standby_seed.get(),
|
||||
ent_standby_amount.get(),
|
||||
ent_standby_nft_id.get(),
|
||||
ent_standby_expiration.get(),
|
||||
ent_standby_destination.get()
|
||||
)
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def standby_accept_sell_offer():
|
||||
results = accept_sell_offer (
|
||||
ent_standby_seed.get(),
|
||||
ent_standby_nft_offer_index.get()
|
||||
)
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def standby_create_buy_offer():
|
||||
results = create_buy_offer(
|
||||
ent_standby_seed.get(),
|
||||
ent_standby_amount.get(),
|
||||
ent_standby_nft_id.get(),
|
||||
ent_standby_owner.get(),
|
||||
ent_standby_expiration.get(),
|
||||
ent_standby_destination.get()
|
||||
)
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def standby_accept_buy_offer():
|
||||
results = accept_buy_offer (
|
||||
ent_standby_seed.get(),
|
||||
ent_standby_nft_offer_index.get()
|
||||
)
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def standby_get_offers():
|
||||
results = get_offers(ent_standby_nft_id.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", results)
|
||||
|
||||
|
||||
def standby_cancel_offer():
|
||||
results = cancel_offer(
|
||||
ent_standby_seed.get(),
|
||||
ent_standby_nft_offer_index.get()
|
||||
)
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def op_create_sell_offer():
|
||||
results = create_sell_offer(
|
||||
ent_operational_seed.get(),
|
||||
ent_operational_amount.get(),
|
||||
ent_operational_nft_id.get(),
|
||||
ent_operational_expiration.get(),
|
||||
ent_operational_destination.get()
|
||||
)
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def op_accept_sell_offer():
|
||||
results = accept_sell_offer (
|
||||
ent_operational_seed.get(),
|
||||
ent_operational_nft_offer_index.get()
|
||||
)
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def op_create_buy_offer():
|
||||
results = create_buy_offer(
|
||||
ent_operational_seed.get(),
|
||||
ent_operational_amount.get(),
|
||||
ent_operational_nft_id.get(),
|
||||
ent_operational_owner.get(),
|
||||
ent_operational_expiration.get(),
|
||||
ent_operational_destination.get()
|
||||
)
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def op_accept_buy_offer():
|
||||
results = accept_buy_offer (
|
||||
ent_operational_seed.get(),
|
||||
ent_operational_nft_offer_index.get()
|
||||
)
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def op_get_offers():
|
||||
results = get_offers(ent_operational_nft_id.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", results)
|
||||
|
||||
|
||||
def op_cancel_offer():
|
||||
results = cancel_offer(
|
||||
ent_operational_seed.get(),
|
||||
ent_operational_nft_offer_index.get()
|
||||
)
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
# Module 3 Handlers
|
||||
|
||||
def standby_mint_token():
|
||||
results = mint_token(
|
||||
ent_standby_seed.get(),
|
||||
ent_standby_uri.get(),
|
||||
ent_standby_flags.get(),
|
||||
ent_standby_transfer_fee.get(),
|
||||
ent_standby_taxon.get()
|
||||
)
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def standby_get_tokens():
|
||||
results = get_tokens(ent_standby_account.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def standby_burn_token():
|
||||
results = burn_token(
|
||||
ent_standby_seed.get(),
|
||||
ent_standby_nft_id.get()
|
||||
)
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def operational_mint_token():
|
||||
results = mint_token(
|
||||
ent_operational_seed.get(),
|
||||
ent_operational_uri.get(),
|
||||
ent_operational_flags.get(),
|
||||
ent_operational_transfer_fee.get(),
|
||||
ent_operational_taxon.get()
|
||||
)
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def operational_get_tokens():
|
||||
results = get_tokens(ent_operational_account.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def operational_burn_token():
|
||||
results = burn_token(
|
||||
ent_operational_seed.get(),
|
||||
ent_operational_nft_id.get()
|
||||
)
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
# Module 2 Handlers
|
||||
|
||||
def standby_create_trust_line():
|
||||
results = create_trust_line(ent_standby_seed.get(),
|
||||
ent_standby_destination.get(),
|
||||
ent_standby_currency.get(),
|
||||
ent_standby_amount.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def standby_send_currency():
|
||||
results = send_currency(ent_standby_seed.get(),
|
||||
ent_standby_destination.get(),
|
||||
ent_standby_currency.get(),
|
||||
ent_standby_amount.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def standby_configure_account():
|
||||
results = configure_account(
|
||||
ent_standby_seed.get(),
|
||||
standbyRippling)
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def operational_create_trust_line():
|
||||
results = create_trust_line(ent_operational_seed.get(),
|
||||
ent_operational_destination.get(),
|
||||
ent_operational_currency.get(),
|
||||
ent_operational_amount.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def operational_send_currency():
|
||||
results = send_currency(ent_operational_seed.get(),
|
||||
ent_operational_destination.get(),
|
||||
ent_operational_currency.get(),
|
||||
ent_operational_amount.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def operational_configure_account():
|
||||
results = configure_account(
|
||||
ent_operational_seed.get(),
|
||||
operationalRippling)
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def get_balances():
|
||||
results = get_balance(ent_operational_account.get(), ent_standby_account.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
results = get_balance(ent_standby_account.get(), ent_operational_account.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
# Module 1 Handlers
|
||||
def get_standby_account():
|
||||
new_wallet = get_account(ent_standby_seed.get())
|
||||
ent_standby_account.delete(0, tk.END)
|
||||
ent_standby_seed.delete(0, tk.END)
|
||||
ent_standby_account.insert(0, new_wallet.classic_address)
|
||||
ent_standby_seed.insert(0, new_wallet.seed)
|
||||
|
||||
|
||||
def get_standby_account_info():
|
||||
accountInfo = get_account_info(ent_standby_account.get())
|
||||
ent_standby_balance.delete(0, tk.END)
|
||||
ent_standby_balance.insert(0,accountInfo['Balance'])
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0",json.dumps(accountInfo, indent=4))
|
||||
|
||||
|
||||
def standby_send_xrp():
|
||||
response = send_xrp(ent_standby_seed.get(),ent_standby_amount.get(),
|
||||
ent_standby_destination.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0",json.dumps(response.result, indent=4))
|
||||
get_standby_account_info()
|
||||
get_operational_account_info()
|
||||
|
||||
|
||||
def get_operational_account():
|
||||
new_wallet = get_account(ent_operational_seed.get())
|
||||
ent_operational_account.delete(0, tk.END)
|
||||
ent_operational_account.insert(0, new_wallet.classic_address)
|
||||
ent_operational_seed.delete(0, tk.END)
|
||||
ent_operational_seed.insert(0, new_wallet.seed)
|
||||
|
||||
|
||||
def get_operational_account_info():
|
||||
accountInfo = get_account_info(ent_operational_account.get())
|
||||
ent_operational_balance.delete(0, tk.END)
|
||||
ent_operational_balance.insert(0,accountInfo['Balance'])
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0",json.dumps(accountInfo, indent=4))
|
||||
|
||||
|
||||
def operational_send_xrp():
|
||||
response = send_xrp(ent_operational_seed.get(),ent_operational_amount.get(), ent_operational_destination.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0",json.dumps(response.result,indent=4))
|
||||
get_standby_account_info()
|
||||
get_operational_account_info()
|
||||
|
||||
|
||||
# Create a new window with the title "Quickstart Module 4"
|
||||
window = tk.Tk()
|
||||
window.title("Quickstart Module 4")
|
||||
|
||||
|
||||
standbyRippling = tk.BooleanVar()
|
||||
operationalRippling = tk.BooleanVar()
|
||||
|
||||
|
||||
# Form frame
|
||||
frm_form = tk.Frame(relief=tk.SUNKEN, borderwidth=3)
|
||||
frm_form.pack()
|
||||
|
||||
# Create the Label and Entry widgets for "Standby Account"
|
||||
lbl_standy_seed = tk.Label(master=frm_form, text="Standby Seed")
|
||||
ent_standby_seed = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standby_account = tk.Label(master=frm_form, text="Standby Account")
|
||||
ent_standby_account = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standy_amount = tk.Label(master=frm_form, text="Amount")
|
||||
ent_standby_amount = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standby_destination = tk.Label(master=frm_form, text="Destination")
|
||||
ent_standby_destination = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standby_balance = tk.Label(master=frm_form, text="XRP Balance")
|
||||
ent_standby_balance = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standby_currency = tk.Label(master=frm_form, text="Currency")
|
||||
ent_standby_currency = tk.Entry(master=frm_form, width=50)
|
||||
cb_standby_allow_rippling = tk.Checkbutton(master=frm_form, text="Allow Rippling", variable=standbyRippling, onvalue=True, offvalue=False)
|
||||
lbl_standby_uri = tk.Label(master=frm_form, text="NFT URI")
|
||||
ent_standby_uri = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standby_flags = tk.Label(master=frm_form, text="Flags")
|
||||
ent_standby_flags = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standby_transfer_fee = tk.Label(master=frm_form, text="Transfer Fee")
|
||||
ent_standby_transfer_fee = tk.Entry(master=frm_form, width="50")
|
||||
lbl_standby_taxon = tk.Label(master=frm_form, text="Taxon")
|
||||
ent_standby_taxon = tk.Entry(master=frm_form, width="50")
|
||||
lbl_standby_nft_id = tk.Label(master=frm_form, text="NFT ID")
|
||||
ent_standby_nft_id = tk.Entry(master=frm_form, width="50")
|
||||
lbl_standby_nft_offer_index = tk.Label(master=frm_form, text="NFT Offer Index")
|
||||
ent_standby_nft_offer_index = tk.Entry(master=frm_form, width="50")
|
||||
lbl_standby_owner = tk.Label(master=frm_form, text="Owner")
|
||||
ent_standby_owner = tk.Entry(master=frm_form, width="50")
|
||||
lbl_standby_expiration = tk.Label(master=frm_form, text="Expiration")
|
||||
ent_standby_expiration = tk.Entry(master=frm_form, width="50")
|
||||
lbl_standby_results = tk.Label(master=frm_form,text='Results')
|
||||
text_standby_results = tk.Text(master=frm_form, height = 20, width = 65)
|
||||
|
||||
|
||||
|
||||
|
||||
# Place field in a grid.
|
||||
lbl_standy_seed.grid(row=0, column=0, sticky="w")
|
||||
ent_standby_seed.grid(row=0, column=1)
|
||||
lbl_standby_account.grid(row=2, column=0, sticky="e")
|
||||
ent_standby_account.grid(row=2, column=1)
|
||||
lbl_standy_amount.grid(row=3, column=0, sticky="e")
|
||||
ent_standby_amount.grid(row=3, column=1)
|
||||
lbl_standby_destination.grid(row=4, column=0, sticky="e")
|
||||
ent_standby_destination.grid(row=4, column=1)
|
||||
lbl_standby_balance.grid(row=5, column=0, sticky="e")
|
||||
ent_standby_balance.grid(row=5, column=1)
|
||||
lbl_standby_currency.grid(row=6, column=0, sticky="e")
|
||||
ent_standby_currency.grid(row=6, column=1)
|
||||
cb_standby_allow_rippling.grid(row=7,column=1, sticky="w")
|
||||
lbl_standby_uri.grid(row=8, column=0, sticky="e")
|
||||
ent_standby_uri.grid(row=8, column=1, sticky="w")
|
||||
lbl_standby_flags.grid(row=9, column=0, sticky="e")
|
||||
ent_standby_flags.grid(row=9, column=1, sticky="w")
|
||||
lbl_standby_transfer_fee.grid(row=10, column=0, sticky="e")
|
||||
ent_standby_transfer_fee.grid(row=10, column=1, sticky="w")
|
||||
lbl_standby_taxon.grid(row=11, column=0, sticky="e")
|
||||
ent_standby_taxon.grid(row=11, column=1, sticky="w")
|
||||
lbl_standby_nft_id.grid(row=12, column=0, sticky="e")
|
||||
ent_standby_nft_id.grid(row=12, column=1, sticky="w")
|
||||
lbl_standby_nft_offer_index.grid(row=13, column=0, sticky="ne")
|
||||
ent_standby_nft_offer_index.grid(row=13, column=1, sticky="w")
|
||||
lbl_standby_owner.grid(row=14, column=0, sticky="ne")
|
||||
ent_standby_owner.grid(row=14, column=1, sticky="w")
|
||||
lbl_standby_expiration.grid(row=15, column=0, sticky="ne")
|
||||
ent_standby_expiration.grid(row=15, column=1, sticky="w")
|
||||
lbl_standby_results.grid(row=17, column=0, sticky="ne")
|
||||
text_standby_results.grid(row=17, column=1, sticky="nw")
|
||||
|
||||
cb_standby_allow_rippling.select()
|
||||
|
||||
###############################################
|
||||
## Operational Account ########################
|
||||
###############################################
|
||||
|
||||
# Create the Label and Entry widgets for "Operational Account"
|
||||
lbl_operational_seed = tk.Label(master=frm_form, text="Operational Seed")
|
||||
ent_operational_seed = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_account = tk.Label(master=frm_form, text="Operational Account")
|
||||
ent_operational_account = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_amount = tk.Label(master=frm_form, text="Amount")
|
||||
ent_operational_amount = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_destination = tk.Label(master=frm_form, text="Destination")
|
||||
ent_operational_destination = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_balance = tk.Label(master=frm_form, text="XRP Balance")
|
||||
ent_operational_balance = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_currency = tk.Label(master=frm_form, text="Currency")
|
||||
ent_operational_currency = tk.Entry(master=frm_form, width=50)
|
||||
cb_operational_allow_rippling = tk.Checkbutton(master=frm_form, text="Allow Rippling", variable=operationalRippling, onvalue=True, offvalue=False)
|
||||
lbl_operational_uri = tk.Label(master=frm_form, text="NFT URI")
|
||||
ent_operational_uri = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_flags = tk.Label(master=frm_form, text="Flags")
|
||||
ent_operational_flags = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_transfer_fee = tk.Label(master=frm_form, text="Transfer Fee")
|
||||
ent_operational_transfer_fee = tk.Entry(master=frm_form, width="50")
|
||||
lbl_operational_taxon = tk.Label(master=frm_form, text="Taxon")
|
||||
ent_operational_taxon = tk.Entry(master=frm_form, width="50")
|
||||
lbl_operational_nft_id = tk.Label(master=frm_form, text="NFT ID")
|
||||
ent_operational_nft_id = tk.Entry(master=frm_form, width="50")
|
||||
lbl_operational_nft_offer_index = tk.Label(master=frm_form, text="NFT Offer Index")
|
||||
ent_operational_nft_offer_index = tk.Entry(master=frm_form, width="50")
|
||||
lbl_operational_owner = tk.Label(master=frm_form, text="Owner")
|
||||
ent_operational_owner = tk.Entry(master=frm_form, width="50")
|
||||
lbl_operational_expiration = tk.Label(master=frm_form, text="Expiration")
|
||||
ent_operational_expiration = tk.Entry(master=frm_form, width="50")
|
||||
lbl_operational_results = tk.Label(master=frm_form,text="Results")
|
||||
text_operational_results = tk.Text(master=frm_form, height = 20, width = 65)
|
||||
|
||||
#Place the widgets in a grid
|
||||
lbl_operational_seed.grid(row=0, column=4, sticky="e")
|
||||
ent_operational_seed.grid(row=0, column=5, sticky="w")
|
||||
lbl_operational_account.grid(row=2,column=4, sticky="e")
|
||||
ent_operational_account.grid(row=2,column=5, sticky="w")
|
||||
lbl_operational_amount.grid(row=3, column=4, sticky="e")
|
||||
ent_operational_amount.grid(row=3, column=5, sticky="w")
|
||||
lbl_operational_destination.grid(row=4, column=4, sticky="e")
|
||||
ent_operational_destination.grid(row=4, column=5, sticky="w")
|
||||
lbl_operational_balance.grid(row=5, column=4, sticky="e")
|
||||
ent_operational_balance.grid(row=5, column=5, sticky="w")
|
||||
lbl_operational_currency.grid(row=6, column=4, sticky="e")
|
||||
ent_operational_currency.grid(row=6, column=5)
|
||||
cb_operational_allow_rippling.grid(row=7,column=5, sticky="w")
|
||||
lbl_operational_uri.grid(row=8, column=4, sticky="e")
|
||||
ent_operational_uri.grid(row=8, column=5, sticky="w")
|
||||
lbl_operational_flags.grid(row=9, column=4, sticky="e")
|
||||
ent_operational_flags.grid(row=9, column=5, sticky="w")
|
||||
lbl_operational_transfer_fee.grid(row=10, column=4, sticky="e")
|
||||
ent_operational_transfer_fee.grid(row=10, column=5, sticky="w")
|
||||
lbl_operational_taxon.grid(row=11, column=4, sticky="e")
|
||||
ent_operational_taxon.grid(row=11, column=5, sticky="w")
|
||||
lbl_operational_nft_id.grid(row=12, column=4, sticky="e")
|
||||
ent_operational_nft_id.grid(row=12, column=5, sticky="w")
|
||||
lbl_operational_nft_offer_index.grid(row=13, column=4, sticky="ne")
|
||||
ent_operational_nft_offer_index.grid(row=13, column=5, sticky="w")
|
||||
lbl_operational_owner.grid(row=14, column=4, sticky="ne")
|
||||
ent_operational_owner.grid(row=14, column=5, sticky="w")
|
||||
lbl_operational_expiration.grid(row=15, column=4, sticky="ne")
|
||||
ent_operational_expiration.grid(row=15, column=5, sticky="w")
|
||||
lbl_operational_results.grid(row=17, column=4, sticky="ne")
|
||||
text_operational_results.grid(row=17, column=5, sticky="nw")
|
||||
|
||||
cb_operational_allow_rippling.select()
|
||||
|
||||
#############################################
|
||||
## Buttons ##################################
|
||||
#############################################
|
||||
|
||||
# Create the Standby Account Buttons
|
||||
btn_get_standby_account = tk.Button(master=frm_form, text="Get Standby Account",
|
||||
command = get_standby_account)
|
||||
btn_get_standby_account.grid(row=0, column=2, sticky = "nsew")
|
||||
btn_get_standby_account_info = tk.Button(master=frm_form,
|
||||
text="Get Standby Account Info",
|
||||
command = get_standby_account_info)
|
||||
btn_get_standby_account_info.grid(row=1, column=2, sticky = "nsew")
|
||||
btn_standby_send_xrp = tk.Button(master=frm_form, text="Send XRP >",
|
||||
command = standby_send_xrp)
|
||||
btn_standby_send_xrp.grid(row=2, column = 2, sticky = "nsew")
|
||||
btn_standby_create_trust_line = tk.Button(master=frm_form,
|
||||
text="Create Trust Line",
|
||||
command = standby_create_trust_line)
|
||||
btn_standby_create_trust_line.grid(row=4, column=2, sticky = "nsew")
|
||||
btn_standby_send_currency = tk.Button(master=frm_form, text="Send Currency >",
|
||||
command = standby_send_currency)
|
||||
btn_standby_send_currency.grid(row=5, column=2, sticky = "nsew")
|
||||
btn_standby_send_currency = tk.Button(master=frm_form, text="Get Balances",
|
||||
command = get_balances)
|
||||
btn_standby_send_currency.grid(row=6, column=2, sticky = "nsew")
|
||||
btn_standby_configure_account = tk.Button(master=frm_form,
|
||||
text="Configure Account",
|
||||
command = standby_configure_account)
|
||||
btn_standby_configure_account.grid(row=7,column=0, sticky = "nsew")
|
||||
btn_standby_mint_token = tk.Button(master=frm_form, text="Mint NFT",
|
||||
command = standby_mint_token)
|
||||
btn_standby_mint_token.grid(row=8, column=2, sticky="nsew")
|
||||
btn_standby_get_tokens = tk.Button(master=frm_form, text="Get NFTs",
|
||||
command = standby_get_tokens)
|
||||
btn_standby_get_tokens.grid(row=9, column=2, sticky="nsew")
|
||||
btn_standby_burn_token = tk.Button(master=frm_form, text="Burn NFT",
|
||||
command = standby_burn_token)
|
||||
btn_standby_burn_token.grid(row=10, column=2, sticky="nsew")
|
||||
btn_standby_create_sell_offer = tk.Button(master=frm_form, text="Create Sell Offer",
|
||||
command = standby_create_sell_offer)
|
||||
btn_standby_create_sell_offer.grid(row=11, column=2, sticky="nsew")
|
||||
btn_standby_accept_sell_offer = tk.Button(master=frm_form, text="Accept Sell Offer",
|
||||
command = standby_accept_sell_offer)
|
||||
btn_standby_accept_sell_offer.grid(row=12, column=2, sticky="nsew")
|
||||
btn_standby_create_buy_offer = tk.Button(master=frm_form, text="Create Buy Offer",
|
||||
command = standby_create_buy_offer)
|
||||
btn_standby_create_buy_offer.grid(row=13, column=2, sticky="nsew")
|
||||
btn_standby_accept_buy_offer = tk.Button(master=frm_form, text="Accept Buy Offer",
|
||||
command = standby_accept_buy_offer)
|
||||
btn_standby_accept_buy_offer.grid(row=14, column=2, sticky="nsew")
|
||||
btn_standby_get_offers = tk.Button(master=frm_form, text="Get Offers",
|
||||
command = standby_get_offers)
|
||||
btn_standby_get_offers.grid(row=15, column=2, sticky="nsew")
|
||||
btn_standby_cancel_offer = tk.Button(master=frm_form, text="Cancel Offer",
|
||||
command = standby_cancel_offer)
|
||||
btn_standby_cancel_offer.grid(row=16, column=2, sticky="nsew")
|
||||
|
||||
|
||||
|
||||
# Create the Operational Account Buttons
|
||||
btn_get_operational_account = tk.Button(master=frm_form,
|
||||
text="Get Operational Account",
|
||||
command = get_operational_account)
|
||||
btn_get_operational_account.grid(row=0, column=3, sticky = "nsew")
|
||||
btn_get_op_account_info = tk.Button(master=frm_form, text="Get Op Account Info",
|
||||
command = get_operational_account_info)
|
||||
btn_get_op_account_info.grid(row=1, column=3, sticky = "nsew")
|
||||
btn_op_send_xrp = tk.Button(master=frm_form, text="< Send XRP",
|
||||
command = operational_send_xrp)
|
||||
btn_op_send_xrp.grid(row=2, column = 3, sticky = "nsew")
|
||||
btn_op_create_trust_line = tk.Button(master=frm_form, text="Create Trust Line",
|
||||
command = operational_create_trust_line)
|
||||
btn_op_create_trust_line.grid(row=4, column=3, sticky = "nsew")
|
||||
btn_op_send_currency = tk.Button(master=frm_form, text="< Send Currency",
|
||||
command = operational_send_currency)
|
||||
btn_op_send_currency.grid(row=5, column=3, sticky = "nsew")
|
||||
btn_op_get_balances = tk.Button(master=frm_form, text="Get Balances",
|
||||
command = get_balances)
|
||||
btn_op_get_balances.grid(row=6, column=3, sticky = "nsew")
|
||||
btn_op_configure_account = tk.Button(master=frm_form, text="Configure Account",
|
||||
command = operational_configure_account)
|
||||
btn_op_configure_account.grid(row=7,column=4, sticky = "nsew")
|
||||
btn_op_mint_token = tk.Button(master=frm_form, text="Mint NFT",
|
||||
command = operational_mint_token)
|
||||
btn_op_mint_token.grid(row=8, column=3, sticky="nsew")
|
||||
btn_op_get_tokens = tk.Button(master=frm_form, text="Get NFTs",
|
||||
command = operational_get_tokens)
|
||||
btn_op_get_tokens.grid(row=9, column=3, sticky="nsew")
|
||||
btn_op_burn_token = tk.Button(master=frm_form, text="Burn NFT",
|
||||
command = operational_burn_token)
|
||||
btn_op_burn_token.grid(row=10, column=3, sticky="nsew")
|
||||
btn_op_create_sell_offer = tk.Button(master=frm_form, text="Create Sell Offer",
|
||||
command = op_create_sell_offer)
|
||||
btn_op_create_sell_offer.grid(row=11, column=3, sticky="nsew")
|
||||
btn_op_accept_sell_offer = tk.Button(master=frm_form, text="Accept Sell Offer",
|
||||
command = op_accept_sell_offer)
|
||||
btn_op_accept_sell_offer.grid(row=12, column=3, sticky="nsew")
|
||||
btn_op_create_buy_offer = tk.Button(master=frm_form, text="Create Buy Offer",
|
||||
command = op_create_buy_offer)
|
||||
btn_op_create_buy_offer.grid(row=13, column=3, sticky="nsew")
|
||||
btn_op_accept_buy_offer = tk.Button(master=frm_form, text="Accept Buy Offer",
|
||||
command = op_accept_buy_offer)
|
||||
btn_op_accept_buy_offer.grid(row=14, column=3, sticky="nsew")
|
||||
btn_op_get_offers = tk.Button(master=frm_form, text="Get Offers",
|
||||
command = op_get_offers)
|
||||
btn_op_get_offers.grid(row=15, column=3, sticky="nsew")
|
||||
btn_op_cancel_offer = tk.Button(master=frm_form, text="Cancel Offer",
|
||||
command = op_cancel_offer)
|
||||
btn_op_cancel_offer.grid(row=16, column=3, sticky="nsew")
|
||||
|
||||
# Start the application
|
||||
window.mainloop()
|
||||
696
content/_code-samples/quickstart/py/lesson5-broker-nfts.py
Normal file
@@ -0,0 +1,696 @@
|
||||
import tkinter as tk
|
||||
import xrpl
|
||||
import json
|
||||
|
||||
from mod1 import get_account, get_account_info, send_xrp
|
||||
from mod2 import (
|
||||
create_trust_line,
|
||||
send_currency,
|
||||
get_balance,
|
||||
configure_account,
|
||||
)
|
||||
from mod3 import (
|
||||
mint_token,
|
||||
get_tokens,
|
||||
burn_token,
|
||||
)
|
||||
from mod4 import (
|
||||
create_sell_offer,
|
||||
create_buy_offer,
|
||||
get_offers,
|
||||
cancel_offer,
|
||||
accept_sell_offer,
|
||||
accept_buy_offer,
|
||||
)
|
||||
from mod5 import broker_sale
|
||||
|
||||
#############################################
|
||||
## Handlers #################################
|
||||
#############################################
|
||||
|
||||
# Module 5 Handlers
|
||||
|
||||
def get_broker_account():
|
||||
new_wallet = get_account(ent_broker_seed.get())
|
||||
ent_broker_account.delete(0, tk.END)
|
||||
ent_broker_seed.delete(0, tk.END)
|
||||
ent_broker_account.insert(0, new_wallet.classic_address)
|
||||
ent_broker_seed.insert(0, new_wallet.seed)
|
||||
|
||||
|
||||
def get_broker_account_info():
|
||||
accountInfo = get_account_info(ent_broker_account.get())
|
||||
ent_broker_balance.delete(0, tk.END)
|
||||
ent_broker_balance.insert(0,accountInfo['Balance'])
|
||||
text_broker_results.delete("1.0", tk.END)
|
||||
text_broker_results.insert("1.0",json.dumps(accountInfo, indent=4))
|
||||
|
||||
|
||||
def broker_broker_sale():
|
||||
results = broker_sale(
|
||||
ent_broker_seed.get(),
|
||||
ent_broker_sell_nft_idx.get(),
|
||||
ent_broker_buy_nft_idx.get(),
|
||||
ent_broker_fee.get()
|
||||
)
|
||||
text_broker_results.delete("1.0", tk.END)
|
||||
text_broker_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def broker_get_offers():
|
||||
results = get_offers(ent_broker_nft_id.get())
|
||||
text_broker_results.delete("1.0", tk.END)
|
||||
text_broker_results.insert("1.0", results)
|
||||
|
||||
|
||||
def broker_cancel_offer():
|
||||
results = cancel_offer(
|
||||
ent_broker_seed.get(),
|
||||
ent_broker_buy_nft_idx.get()
|
||||
)
|
||||
text_broker_results.delete("1.0", tk.END)
|
||||
text_broker_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
# Module 4 Handlers
|
||||
|
||||
def standby_create_sell_offer():
|
||||
results = create_sell_offer(
|
||||
ent_standby_seed.get(),
|
||||
ent_standby_amount.get(),
|
||||
ent_standby_nft_id.get(),
|
||||
ent_standby_expiration.get(),
|
||||
ent_standby_destination.get()
|
||||
)
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def standby_accept_sell_offer():
|
||||
results = accept_sell_offer (
|
||||
ent_standby_seed.get(),
|
||||
ent_standby_nft_offer_index.get()
|
||||
)
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def standby_create_buy_offer():
|
||||
results = create_buy_offer(
|
||||
ent_standby_seed.get(),
|
||||
ent_standby_amount.get(),
|
||||
ent_standby_nft_id.get(),
|
||||
ent_standby_owner.get(),
|
||||
ent_standby_expiration.get(),
|
||||
ent_standby_destination.get()
|
||||
)
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def standby_accept_buy_offer():
|
||||
results = accept_buy_offer (
|
||||
ent_standby_seed.get(),
|
||||
ent_standby_nft_offer_index.get()
|
||||
)
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def standby_get_offers():
|
||||
results = get_offers(ent_standby_nft_id.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", results)
|
||||
|
||||
|
||||
def standby_cancel_offer():
|
||||
results = cancel_offer(
|
||||
ent_standby_seed.get(),
|
||||
ent_standby_nft_offer_index.get()
|
||||
)
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def op_create_sell_offer():
|
||||
results = create_sell_offer(
|
||||
ent_operational_seed.get(),
|
||||
ent_operational_amount.get(),
|
||||
ent_operational_nft_id.get(),
|
||||
ent_operational_expiration.get(),
|
||||
ent_operational_destination.get()
|
||||
)
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def op_accept_sell_offer():
|
||||
results = accept_sell_offer (
|
||||
ent_operational_seed.get(),
|
||||
ent_operational_nft_offer_index.get()
|
||||
)
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def op_create_buy_offer():
|
||||
results = create_buy_offer(
|
||||
ent_operational_seed.get(),
|
||||
ent_operational_amount.get(),
|
||||
ent_operational_nft_id.get(),
|
||||
ent_operational_owner.get(),
|
||||
ent_operational_expiration.get(),
|
||||
ent_operational_destination.get()
|
||||
)
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def op_accept_buy_offer():
|
||||
results = accept_buy_offer (
|
||||
ent_operational_seed.get(),
|
||||
ent_operational_nft_offer_index.get()
|
||||
)
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def op_get_offers():
|
||||
results = get_offers(ent_operational_nft_id.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", results)
|
||||
|
||||
|
||||
def op_cancel_offer():
|
||||
results = cancel_offer(
|
||||
ent_operational_seed.get(),
|
||||
ent_operational_nft_offer_index.get()
|
||||
)
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
|
||||
# Module 3 Handlers
|
||||
|
||||
def standby_mint_token():
|
||||
results = mint_token(
|
||||
ent_standby_seed.get(),
|
||||
ent_standby_uri.get(),
|
||||
ent_standby_flags.get(),
|
||||
ent_standby_transfer_fee.get(),
|
||||
ent_standby_taxon.get()
|
||||
)
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def standby_get_tokens():
|
||||
results = get_tokens(ent_standby_account.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def standby_burn_token():
|
||||
results = burn_token(
|
||||
ent_standby_seed.get(),
|
||||
ent_standby_nft_id.get()
|
||||
)
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def operational_mint_token():
|
||||
results = mint_token(
|
||||
ent_operational_seed.get(),
|
||||
ent_operational_uri.get(),
|
||||
ent_operational_flags.get(),
|
||||
ent_operational_transfer_fee.get(),
|
||||
ent_operational_taxon.get()
|
||||
)
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def operational_get_tokens():
|
||||
results = get_tokens(ent_operational_account.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def operational_burn_token():
|
||||
results = burn_token(
|
||||
ent_operational_seed.get(),
|
||||
ent_operational_nft_id.get()
|
||||
)
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
# Module 2 Handlers
|
||||
|
||||
def standby_create_trust_line():
|
||||
results = create_trust_line(ent_standby_seed.get(),
|
||||
ent_standby_destination.get(),
|
||||
ent_standby_currency.get(),
|
||||
ent_standby_amount.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def standby_send_currency():
|
||||
results = send_currency(ent_standby_seed.get(),
|
||||
ent_standby_destination.get(),
|
||||
ent_standby_currency.get(),
|
||||
ent_standby_amount.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def standby_configure_account():
|
||||
results = configure_account(
|
||||
ent_standby_seed.get(),
|
||||
standbyRippling)
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def operational_create_trust_line():
|
||||
results = create_trust_line(ent_operational_seed.get(),
|
||||
ent_operational_destination.get(),
|
||||
ent_operational_currency.get(),
|
||||
ent_operational_amount.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def operational_send_currency():
|
||||
results = send_currency(ent_operational_seed.get(),
|
||||
ent_operational_destination.get(),
|
||||
ent_operational_currency.get(),
|
||||
ent_operational_amount.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def operational_configure_account():
|
||||
results = configure_account(
|
||||
ent_operational_seed.get(),
|
||||
operationalRippling)
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def get_balances():
|
||||
results = get_balance(ent_operational_account.get(), ent_standby_account.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
results = get_balance(ent_standby_account.get(), ent_operational_account.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
# Module 1 Handlers
|
||||
def get_standby_account():
|
||||
new_wallet = get_account(ent_standby_seed.get())
|
||||
ent_standby_account.delete(0, tk.END)
|
||||
ent_standby_seed.delete(0, tk.END)
|
||||
ent_standby_account.insert(0, new_wallet.classic_address)
|
||||
ent_standby_seed.insert(0, new_wallet.seed)
|
||||
|
||||
|
||||
def get_standby_account_info():
|
||||
accountInfo = get_account_info(ent_standby_account.get())
|
||||
ent_standby_balance.delete(0, tk.END)
|
||||
ent_standby_balance.insert(0,accountInfo['Balance'])
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0",json.dumps(accountInfo, indent=4))
|
||||
|
||||
|
||||
def standby_send_xrp():
|
||||
response = send_xrp(ent_standby_seed.get(),ent_standby_amount.get(),
|
||||
ent_standby_destination.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0",json.dumps(response.result, indent=4))
|
||||
get_standby_account_info()
|
||||
get_operational_account_info()
|
||||
|
||||
|
||||
def get_operational_account():
|
||||
new_wallet = get_account(ent_operational_seed.get())
|
||||
ent_operational_account.delete(0, tk.END)
|
||||
ent_operational_account.insert(0, new_wallet.classic_address)
|
||||
ent_operational_seed.delete(0, tk.END)
|
||||
ent_operational_seed.insert(0, new_wallet.seed)
|
||||
|
||||
|
||||
def get_operational_account_info():
|
||||
accountInfo = get_account_info(ent_operational_account.get())
|
||||
ent_operational_balance.delete(0, tk.END)
|
||||
ent_operational_balance.insert(0,accountInfo['Balance'])
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0",json.dumps(accountInfo, indent=4))
|
||||
|
||||
|
||||
def operational_send_xrp():
|
||||
response = send_xrp(ent_operational_seed.get(),ent_operational_amount.get(), ent_operational_destination.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0",json.dumps(response.result,indent=4))
|
||||
get_standby_account_info()
|
||||
get_operational_account_info()
|
||||
|
||||
# Create a new window with the title "Quickstart - Broker Sale"
|
||||
window = tk.Tk()
|
||||
window.title("Quickstart - Broker Sale")
|
||||
|
||||
myscrollbar=tk.Scrollbar(window,orient="vertical")
|
||||
myscrollbar.pack(side="right",fill="y")
|
||||
|
||||
|
||||
standbyRippling = tk.BooleanVar()
|
||||
operationalRippling = tk.BooleanVar()
|
||||
|
||||
# Broker frame
|
||||
|
||||
frm_broker = tk.Frame(relief=tk.SUNKEN, borderwidth=3)
|
||||
frm_broker.pack()
|
||||
|
||||
lbl_broker_seed = tk.Label(master=frm_broker, text="Broker Seed")
|
||||
ent_broker_seed = tk.Entry(master=frm_broker, width=50)
|
||||
lbl_broker_account = tk.Label(master=frm_broker, text="Broker Account")
|
||||
ent_broker_account = tk.Entry(master=frm_broker, width=50)
|
||||
lbl_broker_balance = tk.Label(master=frm_broker, text="XRP Balance")
|
||||
ent_broker_balance = tk.Entry(master=frm_broker, width=50)
|
||||
lbl_broker_amount = tk.Label(master=frm_broker, text="Amount")
|
||||
ent_broker_amount = tk.Entry(master=frm_broker, width=50)
|
||||
lbl_broker_nft_id = tk.Label(master=frm_broker, text="NFT ID")
|
||||
ent_broker_nft_id = tk.Entry(master=frm_broker, width=50)
|
||||
lbl_broker_sell_nft_idx = tk.Label(master=frm_broker, text="Sell NFT Offer Index")
|
||||
ent_broker_sell_nft_idx = tk.Entry(master=frm_broker, width=50)
|
||||
lbl_broker_buy_nft_idx = tk.Label(master=frm_broker, text="Buy NFT Offer Index")
|
||||
ent_broker_buy_nft_idx = tk.Entry(master=frm_broker, width=50)
|
||||
lbl_broker_owner = tk.Label(master=frm_broker, text="Owner")
|
||||
ent_broker_owner = tk.Entry(master=frm_broker, width=50)
|
||||
lbl_broker_fee = tk.Label(master=frm_broker, text="Broker Fee")
|
||||
ent_broker_fee = tk.Entry(master=frm_broker, width=50)
|
||||
lbl_broker_results=tk.Label(master=frm_broker, text="Results")
|
||||
text_broker_results = tk.Text(master=frm_broker, height=10, width=65)
|
||||
|
||||
lbl_broker_seed.grid(row=0, column=0, sticky="w")
|
||||
ent_broker_seed.grid(row=0, column=1)
|
||||
lbl_broker_account.grid(row=1, column=0, sticky="w")
|
||||
ent_broker_account.grid(row=1, column=1)
|
||||
lbl_broker_balance.grid(row=2, column=0, sticky="w")
|
||||
ent_broker_balance.grid(row=2, column=1)
|
||||
lbl_broker_amount.grid(row=3, column=0, sticky="w")
|
||||
ent_broker_amount.grid(row=3, column=1)
|
||||
lbl_broker_nft_id.grid(row=4, column=0, sticky="w")
|
||||
ent_broker_nft_id.grid(row=4, column=1)
|
||||
lbl_broker_sell_nft_idx.grid(row=5, column=0, sticky="w")
|
||||
ent_broker_sell_nft_idx.grid(row=5, column=1)
|
||||
lbl_broker_buy_nft_idx.grid(row=6, column=0, sticky="w")
|
||||
ent_broker_buy_nft_idx.grid(row=6, column=1)
|
||||
lbl_broker_owner.grid(row=7, column=0, sticky="w")
|
||||
ent_broker_owner.grid(row=7, column=1)
|
||||
lbl_broker_fee.grid(row=8, column=0, sticky="w")
|
||||
ent_broker_fee.grid(row=8, column=1)
|
||||
lbl_broker_results.grid(row=9, column=0)
|
||||
text_broker_results.grid(row=9, column=1)
|
||||
|
||||
# Broker Buttons
|
||||
btn_broker_get_account = tk.Button(master=frm_broker, text="Get Broker Account",
|
||||
command = get_broker_account)
|
||||
btn_broker_get_account.grid(row=0, column=2, sticky = "nsew")
|
||||
btn_broker_get_account_info = tk.Button(master=frm_broker, text="Get Broker Account Info",
|
||||
command = get_broker_account_info)
|
||||
btn_broker_get_account_info.grid(row=1, column=2, sticky = "nsew")
|
||||
btn_broker_sale = tk.Button(master=frm_broker, text="Broker Sale",
|
||||
command = broker_broker_sale)
|
||||
btn_broker_sale.grid(row=2, column=2, sticky = "nsew")
|
||||
btn_broker_get_offers = tk.Button(master=frm_broker, text="Get Offers",
|
||||
command = broker_get_offers)
|
||||
btn_broker_get_offers.grid(row=3, column=2, sticky = "nsew")
|
||||
btn_broker_cancel_offer = tk.Button(master=frm_broker, text="Cancel Offer",
|
||||
command = broker_cancel_offer)
|
||||
btn_broker_cancel_offer.grid(row=4, column=2, sticky="nsew")
|
||||
|
||||
# Form frame
|
||||
frm_form = tk.Frame(relief=tk.SUNKEN, borderwidth=3)
|
||||
frm_form.pack()
|
||||
|
||||
# Create the Label and Entry widgets for "Standby Account"
|
||||
lbl_standy_seed = tk.Label(master=frm_form, text="Standby Seed")
|
||||
ent_standby_seed = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standby_account = tk.Label(master=frm_form, text="Standby Account")
|
||||
ent_standby_account = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standy_amount = tk.Label(master=frm_form, text="Amount")
|
||||
ent_standby_amount = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standby_destination = tk.Label(master=frm_form, text="Destination")
|
||||
ent_standby_destination = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standby_balance = tk.Label(master=frm_form, text="XRP Balance")
|
||||
ent_standby_balance = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standby_currency = tk.Label(master=frm_form, text="Currency")
|
||||
ent_standby_currency = tk.Entry(master=frm_form, width=50)
|
||||
cb_standby_allow_rippling = tk.Checkbutton(master=frm_form, text="Allow Rippling", variable=standbyRippling, onvalue=True, offvalue=False)
|
||||
lbl_standby_uri = tk.Label(master=frm_form, text="NFT URI")
|
||||
ent_standby_uri = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standby_flags = tk.Label(master=frm_form, text="Flags")
|
||||
ent_standby_flags = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standby_transfer_fee = tk.Label(master=frm_form, text="Transfer Fee")
|
||||
ent_standby_transfer_fee = tk.Entry(master=frm_form, width="50")
|
||||
lbl_standby_taxon = tk.Label(master=frm_form, text="Taxon")
|
||||
ent_standby_taxon = tk.Entry(master=frm_form, width="50")
|
||||
lbl_standby_nft_id = tk.Label(master=frm_form, text="NFT ID")
|
||||
ent_standby_nft_id = tk.Entry(master=frm_form, width="50")
|
||||
lbl_standby_nft_offer_index = tk.Label(master=frm_form, text="NFT Offer Index")
|
||||
ent_standby_nft_offer_index = tk.Entry(master=frm_form, width="50")
|
||||
lbl_standby_owner = tk.Label(master=frm_form, text="Owner")
|
||||
ent_standby_owner = tk.Entry(master=frm_form, width="50")
|
||||
lbl_standby_expiration = tk.Label(master=frm_form, text="Expiration")
|
||||
ent_standby_expiration = tk.Entry(master=frm_form, width="50")
|
||||
lbl_standby_results = tk.Label(master=frm_form,text='Results')
|
||||
text_standby_results = tk.Text(master=frm_form, height = 10, width = 65)
|
||||
|
||||
|
||||
|
||||
|
||||
# Place field in a grid.
|
||||
lbl_standy_seed.grid(row=0, column=0, sticky="w")
|
||||
ent_standby_seed.grid(row=0, column=1)
|
||||
lbl_standby_account.grid(row=2, column=0, sticky="e")
|
||||
ent_standby_account.grid(row=2, column=1)
|
||||
lbl_standy_amount.grid(row=3, column=0, sticky="e")
|
||||
ent_standby_amount.grid(row=3, column=1)
|
||||
lbl_standby_destination.grid(row=4, column=0, sticky="e")
|
||||
ent_standby_destination.grid(row=4, column=1)
|
||||
lbl_standby_balance.grid(row=5, column=0, sticky="e")
|
||||
ent_standby_balance.grid(row=5, column=1)
|
||||
lbl_standby_currency.grid(row=6, column=0, sticky="e")
|
||||
ent_standby_currency.grid(row=6, column=1)
|
||||
cb_standby_allow_rippling.grid(row=7,column=1, sticky="w")
|
||||
lbl_standby_uri.grid(row=8, column=0, sticky="e")
|
||||
ent_standby_uri.grid(row=8, column=1, sticky="w")
|
||||
lbl_standby_flags.grid(row=9, column=0, sticky="e")
|
||||
ent_standby_flags.grid(row=9, column=1, sticky="w")
|
||||
lbl_standby_transfer_fee.grid(row=10, column=0, sticky="e")
|
||||
ent_standby_transfer_fee.grid(row=10, column=1, sticky="w")
|
||||
lbl_standby_taxon.grid(row=11, column=0, sticky="e")
|
||||
ent_standby_taxon.grid(row=11, column=1, sticky="w")
|
||||
lbl_standby_nft_id.grid(row=12, column=0, sticky="e")
|
||||
ent_standby_nft_id.grid(row=12, column=1, sticky="w")
|
||||
lbl_standby_nft_offer_index.grid(row=13, column=0, sticky="ne")
|
||||
ent_standby_nft_offer_index.grid(row=13, column=1, sticky="w")
|
||||
lbl_standby_owner.grid(row=14, column=0, sticky="ne")
|
||||
ent_standby_owner.grid(row=14, column=1, sticky="w")
|
||||
lbl_standby_expiration.grid(row=15, column=0, sticky="ne")
|
||||
ent_standby_expiration.grid(row=15, column=1, sticky="w")
|
||||
lbl_standby_results.grid(row=17, column=0, sticky="ne")
|
||||
text_standby_results.grid(row=17, column=1, sticky="nw")
|
||||
|
||||
cb_standby_allow_rippling.select()
|
||||
|
||||
###############################################
|
||||
## Operational Account ########################
|
||||
###############################################
|
||||
|
||||
# Create the Label and Entry widgets for "Operational Account"
|
||||
lbl_operational_seed = tk.Label(master=frm_form, text="Operational Seed")
|
||||
ent_operational_seed = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_account = tk.Label(master=frm_form, text="Operational Account")
|
||||
ent_operational_account = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_amount = tk.Label(master=frm_form, text="Amount")
|
||||
ent_operational_amount = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_destination = tk.Label(master=frm_form, text="Destination")
|
||||
ent_operational_destination = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_balance = tk.Label(master=frm_form, text="XRP Balance")
|
||||
ent_operational_balance = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_currency = tk.Label(master=frm_form, text="Currency")
|
||||
ent_operational_currency = tk.Entry(master=frm_form, width=50)
|
||||
cb_operational_allow_rippling = tk.Checkbutton(master=frm_form, text="Allow Rippling", variable=operationalRippling, onvalue=True, offvalue=False)
|
||||
lbl_operational_uri = tk.Label(master=frm_form, text="NFT URI")
|
||||
ent_operational_uri = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_flags = tk.Label(master=frm_form, text="Flags")
|
||||
ent_operational_flags = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_transfer_fee = tk.Label(master=frm_form, text="Transfer Fee")
|
||||
ent_operational_transfer_fee = tk.Entry(master=frm_form, width="50")
|
||||
lbl_operational_taxon = tk.Label(master=frm_form, text="Taxon")
|
||||
ent_operational_taxon = tk.Entry(master=frm_form, width="50")
|
||||
lbl_operational_nft_id = tk.Label(master=frm_form, text="NFT ID")
|
||||
ent_operational_nft_id = tk.Entry(master=frm_form, width="50")
|
||||
lbl_operational_nft_offer_index = tk.Label(master=frm_form, text="NFT Offer Index")
|
||||
ent_operational_nft_offer_index = tk.Entry(master=frm_form, width="50")
|
||||
lbl_operational_owner = tk.Label(master=frm_form, text="Owner")
|
||||
ent_operational_owner = tk.Entry(master=frm_form, width="50")
|
||||
lbl_operational_expiration = tk.Label(master=frm_form, text="Expiration")
|
||||
ent_operational_expiration = tk.Entry(master=frm_form, width="50")
|
||||
lbl_operational_results = tk.Label(master=frm_form,text="Results")
|
||||
text_operational_results = tk.Text(master=frm_form, height = 10, width = 65)
|
||||
|
||||
#Place the widgets in a grid
|
||||
lbl_operational_seed.grid(row=0, column=4, sticky="e")
|
||||
ent_operational_seed.grid(row=0, column=5, sticky="w")
|
||||
lbl_operational_account.grid(row=2,column=4, sticky="e")
|
||||
ent_operational_account.grid(row=2,column=5, sticky="w")
|
||||
lbl_operational_amount.grid(row=3, column=4, sticky="e")
|
||||
ent_operational_amount.grid(row=3, column=5, sticky="w")
|
||||
lbl_operational_destination.grid(row=4, column=4, sticky="e")
|
||||
ent_operational_destination.grid(row=4, column=5, sticky="w")
|
||||
lbl_operational_balance.grid(row=5, column=4, sticky="e")
|
||||
ent_operational_balance.grid(row=5, column=5, sticky="w")
|
||||
lbl_operational_currency.grid(row=6, column=4, sticky="e")
|
||||
ent_operational_currency.grid(row=6, column=5)
|
||||
cb_operational_allow_rippling.grid(row=7,column=5, sticky="w")
|
||||
lbl_operational_uri.grid(row=8, column=4, sticky="e")
|
||||
ent_operational_uri.grid(row=8, column=5, sticky="w")
|
||||
lbl_operational_flags.grid(row=9, column=4, sticky="e")
|
||||
ent_operational_flags.grid(row=9, column=5, sticky="w")
|
||||
lbl_operational_transfer_fee.grid(row=10, column=4, sticky="e")
|
||||
ent_operational_transfer_fee.grid(row=10, column=5, sticky="w")
|
||||
lbl_operational_taxon.grid(row=11, column=4, sticky="e")
|
||||
ent_operational_taxon.grid(row=11, column=5, sticky="w")
|
||||
lbl_operational_nft_id.grid(row=12, column=4, sticky="e")
|
||||
ent_operational_nft_id.grid(row=12, column=5, sticky="w")
|
||||
lbl_operational_nft_offer_index.grid(row=13, column=4, sticky="ne")
|
||||
ent_operational_nft_offer_index.grid(row=13, column=5, sticky="w")
|
||||
lbl_operational_owner.grid(row=14, column=4, sticky="ne")
|
||||
ent_operational_owner.grid(row=14, column=5, sticky="w")
|
||||
lbl_operational_expiration.grid(row=15, column=4, sticky="ne")
|
||||
ent_operational_expiration.grid(row=15, column=5, sticky="w")
|
||||
lbl_operational_results.grid(row=17, column=4, sticky="ne")
|
||||
text_operational_results.grid(row=17, column=5, sticky="nw")
|
||||
|
||||
cb_operational_allow_rippling.select()
|
||||
|
||||
#############################################
|
||||
## Buttons ##################################
|
||||
#############################################
|
||||
|
||||
# Create the Standby Account Buttons
|
||||
btn_get_standby_account = tk.Button(master=frm_form, text="Get Standby Account",
|
||||
command = get_standby_account)
|
||||
btn_get_standby_account.grid(row=0, column=2, sticky = "nsew")
|
||||
btn_get_standby_account_info = tk.Button(master=frm_form,
|
||||
text="Get Standby Account Info",
|
||||
command = get_standby_account_info)
|
||||
btn_get_standby_account_info.grid(row=1, column=2, sticky = "nsew")
|
||||
btn_standby_send_xrp = tk.Button(master=frm_form, text="Send XRP >",
|
||||
command = standby_send_xrp)
|
||||
btn_standby_send_xrp.grid(row=2, column = 2, sticky = "nsew")
|
||||
btn_standby_create_trust_line = tk.Button(master=frm_form,
|
||||
text="Create Trust Line",
|
||||
command = standby_create_trust_line)
|
||||
btn_standby_create_trust_line.grid(row=4, column=2, sticky = "nsew")
|
||||
btn_standby_send_currency = tk.Button(master=frm_form, text="Send Currency >",
|
||||
command = standby_send_currency)
|
||||
btn_standby_send_currency.grid(row=5, column=2, sticky = "nsew")
|
||||
btn_standby_send_currency = tk.Button(master=frm_form, text="Get Balances",
|
||||
command = get_balances)
|
||||
btn_standby_send_currency.grid(row=6, column=2, sticky = "nsew")
|
||||
btn_standby_configure_account = tk.Button(master=frm_form,
|
||||
text="Configure Account",
|
||||
command = standby_configure_account)
|
||||
btn_standby_configure_account.grid(row=7,column=0, sticky = "nsew")
|
||||
btn_standby_mint_token = tk.Button(master=frm_form, text="Mint NFT",
|
||||
command = standby_mint_token)
|
||||
btn_standby_mint_token.grid(row=8, column=2, sticky="nsew")
|
||||
btn_standby_get_tokens = tk.Button(master=frm_form, text="Get NFTs",
|
||||
command = standby_get_tokens)
|
||||
btn_standby_get_tokens.grid(row=9, column=2, sticky="nsew")
|
||||
btn_standby_burn_token = tk.Button(master=frm_form, text="Burn NFT",
|
||||
command = standby_burn_token)
|
||||
btn_standby_burn_token.grid(row=10, column=2, sticky="nsew")
|
||||
btn_standby_create_sell_offer = tk.Button(master=frm_form, text="Create Sell Offer",
|
||||
command = standby_create_sell_offer)
|
||||
btn_standby_create_sell_offer.grid(row=11, column=2, sticky="nsew")
|
||||
btn_standby_accept_sell_offer = tk.Button(master=frm_form, text="Accept Sell Offer",
|
||||
command = standby_accept_sell_offer)
|
||||
btn_standby_accept_sell_offer.grid(row=12, column=2, sticky="nsew")
|
||||
btn_standby_create_buy_offer = tk.Button(master=frm_form, text="Create Buy Offer",
|
||||
command = standby_create_buy_offer)
|
||||
btn_standby_create_buy_offer.grid(row=13, column=2, sticky="nsew")
|
||||
btn_standby_accept_buy_offer = tk.Button(master=frm_form, text="Accept Buy Offer",
|
||||
command = standby_accept_buy_offer)
|
||||
btn_standby_accept_buy_offer.grid(row=14, column=2, sticky="nsew")
|
||||
btn_standby_get_offers = tk.Button(master=frm_form, text="Get Offers",
|
||||
command = standby_get_offers)
|
||||
btn_standby_get_offers.grid(row=15, column=2, sticky="nsew")
|
||||
btn_standby_cancel_offer = tk.Button(master=frm_form, text="Cancel Offer",
|
||||
command = standby_cancel_offer)
|
||||
btn_standby_cancel_offer.grid(row=16, column=2, sticky="nsew")
|
||||
|
||||
|
||||
|
||||
# Create the Operational Account Buttons
|
||||
btn_get_operational_account = tk.Button(master=frm_form,
|
||||
text="Get Operational Account",
|
||||
command = get_operational_account)
|
||||
btn_get_operational_account.grid(row=0, column=3, sticky = "nsew")
|
||||
btn_get_op_account_info = tk.Button(master=frm_form, text="Get Op Account Info",
|
||||
command = get_operational_account_info)
|
||||
btn_get_op_account_info.grid(row=1, column=3, sticky = "nsew")
|
||||
btn_op_send_xrp = tk.Button(master=frm_form, text="< Send XRP",
|
||||
command = operational_send_xrp)
|
||||
btn_op_send_xrp.grid(row=2, column = 3, sticky = "nsew")
|
||||
btn_op_create_trust_line = tk.Button(master=frm_form, text="Create Trust Line",
|
||||
command = operational_create_trust_line)
|
||||
btn_op_create_trust_line.grid(row=4, column=3, sticky = "nsew")
|
||||
btn_op_send_currency = tk.Button(master=frm_form, text="< Send Currency",
|
||||
command = operational_send_currency)
|
||||
btn_op_send_currency.grid(row=5, column=3, sticky = "nsew")
|
||||
btn_op_get_balances = tk.Button(master=frm_form, text="Get Balances",
|
||||
command = get_balances)
|
||||
btn_op_get_balances.grid(row=6, column=3, sticky = "nsew")
|
||||
btn_op_configure_account = tk.Button(master=frm_form, text="Configure Account",
|
||||
command = operational_configure_account)
|
||||
btn_op_configure_account.grid(row=7,column=4, sticky = "nsew")
|
||||
btn_op_mint_token = tk.Button(master=frm_form, text="Mint NFT",
|
||||
command = operational_mint_token)
|
||||
btn_op_mint_token.grid(row=8, column=3, sticky="nsew")
|
||||
btn_op_get_tokens = tk.Button(master=frm_form, text="Get NFTs",
|
||||
command = operational_get_tokens)
|
||||
btn_op_get_tokens.grid(row=9, column=3, sticky="nsew")
|
||||
btn_op_burn_token = tk.Button(master=frm_form, text="Burn NFT",
|
||||
command = operational_burn_token)
|
||||
btn_op_burn_token.grid(row=10, column=3, sticky="nsew")
|
||||
btn_op_create_sell_offer = tk.Button(master=frm_form, text="Create Sell Offer",
|
||||
command = op_create_sell_offer)
|
||||
btn_op_create_sell_offer.grid(row=11, column=3, sticky="nsew")
|
||||
btn_op_accept_sell_offer = tk.Button(master=frm_form, text="Accept Sell Offer",
|
||||
command = op_accept_sell_offer)
|
||||
btn_op_accept_sell_offer.grid(row=12, column=3, sticky="nsew")
|
||||
btn_op_create_buy_offer = tk.Button(master=frm_form, text="Create Buy Offer",
|
||||
command = op_create_buy_offer)
|
||||
btn_op_create_buy_offer.grid(row=13, column=3, sticky="nsew")
|
||||
btn_op_accept_buy_offer = tk.Button(master=frm_form, text="Accept Buy Offer",
|
||||
command = op_accept_buy_offer)
|
||||
btn_op_accept_buy_offer.grid(row=14, column=3, sticky="nsew")
|
||||
btn_op_get_offers = tk.Button(master=frm_form, text="Get Offers",
|
||||
command = op_get_offers)
|
||||
btn_op_get_offers.grid(row=15, column=3, sticky="nsew")
|
||||
btn_op_cancel_offer = tk.Button(master=frm_form, text="Cancel Offer",
|
||||
command = op_cancel_offer)
|
||||
btn_op_cancel_offer.grid(row=16, column=3, sticky="nsew")
|
||||
|
||||
|
||||
# Start the application
|
||||
window.mainloop()
|
||||
654
content/_code-samples/quickstart/py/lesson6-auth-minter.py
Normal file
@@ -0,0 +1,654 @@
|
||||
import tkinter as tk
|
||||
import xrpl
|
||||
import json
|
||||
|
||||
from mod1 import get_account, get_account_info, send_xrp
|
||||
from mod2 import (
|
||||
create_trust_line,
|
||||
send_currency,
|
||||
get_balance,
|
||||
configure_account,
|
||||
)
|
||||
from mod3 import (
|
||||
mint_token,
|
||||
get_tokens,
|
||||
burn_token,
|
||||
)
|
||||
from mod4 import (
|
||||
create_sell_offer,
|
||||
create_buy_offer,
|
||||
get_offers,
|
||||
cancel_offer,
|
||||
accept_sell_offer,
|
||||
accept_buy_offer,
|
||||
)
|
||||
from mod5 import broker_sale
|
||||
from mod6 import set_minter, mint_other
|
||||
|
||||
#############################################
|
||||
## Handlers #################################
|
||||
#############################################
|
||||
|
||||
# Module 6 Handlers
|
||||
|
||||
def standby_set_minter():
|
||||
results = set_minter(ent_standby_seed.get(),ent_standby_auth_minter.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def standby_mint_other():
|
||||
results = mint_other(
|
||||
ent_standby_seed.get(),
|
||||
ent_standby_uri.get(),
|
||||
ent_standby_flags.get(),
|
||||
ent_standby_transfer_fee.get(),
|
||||
ent_standby_taxon.get(),
|
||||
ent_standby_issuer.get()
|
||||
)
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def operational_set_minter():
|
||||
results = set_minter(ent_operational_seed.get(),ent_operational_auth_minter.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def operational_mint_other():
|
||||
results = mint_other(
|
||||
ent_operational_seed.get(),
|
||||
ent_operational_uri.get(),
|
||||
ent_operational_flags.get(),
|
||||
ent_operational_transfer_fee.get(),
|
||||
ent_operational_taxon.get(),
|
||||
ent_operational_issuer.get()
|
||||
)
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
# Module 4 Handlers
|
||||
|
||||
def standby_create_sell_offer():
|
||||
results = create_sell_offer(
|
||||
ent_standby_seed.get(),
|
||||
ent_standby_amount.get(),
|
||||
ent_standby_nft_id.get(),
|
||||
ent_standby_expiration.get(),
|
||||
ent_standby_destination.get()
|
||||
)
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def standby_accept_sell_offer():
|
||||
results = accept_sell_offer (
|
||||
ent_standby_seed.get(),
|
||||
ent_standby_nft_offer_index.get()
|
||||
)
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def standby_create_buy_offer():
|
||||
results = create_buy_offer(
|
||||
ent_standby_seed.get(),
|
||||
ent_standby_amount.get(),
|
||||
ent_standby_nft_id.get(),
|
||||
ent_standby_owner.get(),
|
||||
ent_standby_expiration.get(),
|
||||
ent_standby_destination.get()
|
||||
)
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def standby_accept_buy_offer():
|
||||
results = accept_buy_offer (
|
||||
ent_standby_seed.get(),
|
||||
ent_standby_nft_offer_index.get()
|
||||
)
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def standby_get_offers():
|
||||
results = get_offers(ent_standby_nft_id.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", results)
|
||||
|
||||
|
||||
def standby_cancel_offer():
|
||||
results = cancel_offer(
|
||||
ent_standby_seed.get(),
|
||||
ent_standby_nft_offer_index.get()
|
||||
)
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def op_create_sell_offer():
|
||||
results = create_sell_offer(
|
||||
ent_operational_seed.get(),
|
||||
ent_operational_amount.get(),
|
||||
ent_operational_nft_id.get(),
|
||||
ent_operational_expiration.get(),
|
||||
ent_operational_destination.get()
|
||||
)
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def op_accept_sell_offer():
|
||||
results = accept_sell_offer (
|
||||
ent_operational_seed.get(),
|
||||
ent_operational_nft_offer_index.get()
|
||||
)
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def op_create_buy_offer():
|
||||
results = create_buy_offer(
|
||||
ent_operational_seed.get(),
|
||||
ent_operational_amount.get(),
|
||||
ent_operational_nft_id.get(),
|
||||
ent_operational_owner.get(),
|
||||
ent_operational_expiration.get(),
|
||||
ent_operational_destination.get()
|
||||
)
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def op_accept_buy_offer():
|
||||
results = accept_buy_offer (
|
||||
ent_operational_seed.get(),
|
||||
ent_operational_nft_offer_index.get()
|
||||
)
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def op_get_offers():
|
||||
results = get_offers(ent_operational_nft_id.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", results)
|
||||
|
||||
|
||||
def op_cancel_offer():
|
||||
results = cancel_offer(
|
||||
ent_operational_seed.get(),
|
||||
ent_operational_nft_offer_index.get()
|
||||
)
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
|
||||
# Module 3 Handlers
|
||||
|
||||
def standby_mint_token():
|
||||
results = mint_token(
|
||||
ent_standby_seed.get(),
|
||||
ent_standby_uri.get(),
|
||||
ent_standby_flags.get(),
|
||||
ent_standby_transfer_fee.get(),
|
||||
ent_standby_taxon.get()
|
||||
)
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def standby_get_tokens():
|
||||
results = get_tokens(ent_standby_account.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def standby_burn_token():
|
||||
results = burn_token(
|
||||
ent_standby_seed.get(),
|
||||
ent_standby_nft_id.get()
|
||||
)
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def operational_mint_token():
|
||||
results = mint_token(
|
||||
ent_operational_seed.get(),
|
||||
ent_operational_uri.get(),
|
||||
ent_operational_flags.get(),
|
||||
ent_operational_transfer_fee.get(),
|
||||
ent_operational_taxon.get()
|
||||
)
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def operational_get_tokens():
|
||||
results = get_tokens(ent_operational_account.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def operational_burn_token():
|
||||
results = burn_token(
|
||||
ent_operational_seed.get(),
|
||||
ent_operational_nft_id.get()
|
||||
)
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
# Module 2 Handlers
|
||||
|
||||
def standby_create_trust_line():
|
||||
results = create_trust_line(ent_standby_seed.get(),
|
||||
ent_standby_destination.get(),
|
||||
ent_standby_currency.get(),
|
||||
ent_standby_amount.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def standby_send_currency():
|
||||
results = send_currency(ent_standby_seed.get(),
|
||||
ent_standby_destination.get(),
|
||||
ent_standby_currency.get(),
|
||||
ent_standby_amount.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def standby_configure_account():
|
||||
results = configure_account(
|
||||
ent_standby_seed.get(),
|
||||
standbyRippling)
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def operational_create_trust_line():
|
||||
results = create_trust_line(ent_operational_seed.get(),
|
||||
ent_operational_destination.get(),
|
||||
ent_operational_currency.get(),
|
||||
ent_operational_amount.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def operational_send_currency():
|
||||
results = send_currency(ent_operational_seed.get(),
|
||||
ent_operational_destination.get(),
|
||||
ent_operational_currency.get(),
|
||||
ent_operational_amount.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def operational_configure_account():
|
||||
results = configure_account(
|
||||
ent_operational_seed.get(),
|
||||
operationalRippling)
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def get_balances():
|
||||
results = get_balance(ent_operational_account.get(), ent_standby_account.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
results = get_balance(ent_standby_account.get(), ent_operational_account.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
# Module 1 Handlers
|
||||
def get_standby_account():
|
||||
new_wallet = get_account(ent_standby_seed.get())
|
||||
ent_standby_account.delete(0, tk.END)
|
||||
ent_standby_seed.delete(0, tk.END)
|
||||
ent_standby_account.insert(0, new_wallet.classic_address)
|
||||
ent_standby_seed.insert(0, new_wallet.seed)
|
||||
|
||||
|
||||
def get_standby_account_info():
|
||||
accountInfo = get_account_info(ent_standby_account.get())
|
||||
ent_standby_balance.delete(0, tk.END)
|
||||
ent_standby_balance.insert(0,accountInfo['Balance'])
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0",json.dumps(accountInfo, indent=4))
|
||||
|
||||
|
||||
def standby_send_xrp():
|
||||
response = send_xrp(ent_standby_seed.get(),ent_standby_amount.get(),
|
||||
ent_standby_destination.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0",json.dumps(response.result, indent=4))
|
||||
get_standby_account_info()
|
||||
get_operational_account_info()
|
||||
|
||||
|
||||
def get_operational_account():
|
||||
new_wallet = get_account(ent_operational_seed.get())
|
||||
ent_operational_account.delete(0, tk.END)
|
||||
ent_operational_account.insert(0, new_wallet.classic_address)
|
||||
ent_operational_seed.delete(0, tk.END)
|
||||
ent_operational_seed.insert(0, new_wallet.seed)
|
||||
|
||||
|
||||
def get_operational_account_info():
|
||||
accountInfo = get_account_info(ent_operational_account.get())
|
||||
ent_operational_balance.delete(0, tk.END)
|
||||
ent_operational_balance.insert(0,accountInfo['Balance'])
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0",json.dumps(accountInfo, indent=4))
|
||||
|
||||
|
||||
def operational_send_xrp():
|
||||
response = send_xrp(ent_operational_seed.get(),ent_operational_amount.get(), ent_operational_destination.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0",json.dumps(response.result,indent=4))
|
||||
get_standby_account_info()
|
||||
get_operational_account_info()
|
||||
|
||||
|
||||
# Create a new window with the title "Quickstart - Authorized Minter"
|
||||
window = tk.Tk()
|
||||
window.title("Quickstart - Authorized Minter")
|
||||
|
||||
myscrollbar=tk.Scrollbar(window,orient="vertical")
|
||||
myscrollbar.pack(side="right",fill="y")
|
||||
|
||||
standbyRippling = tk.BooleanVar()
|
||||
operationalRippling = tk.BooleanVar()
|
||||
|
||||
# Form frame
|
||||
frm_form = tk.Frame(relief=tk.SUNKEN, borderwidth=3)
|
||||
frm_form.pack()
|
||||
|
||||
# Create the Label and Entry widgets for "Standby Account"
|
||||
lbl_standy_seed = tk.Label(master=frm_form, text="Standby Seed")
|
||||
ent_standby_seed = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standby_account = tk.Label(master=frm_form, text="Standby Account")
|
||||
ent_standby_account = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standy_amount = tk.Label(master=frm_form, text="Amount")
|
||||
ent_standby_amount = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standby_destination = tk.Label(master=frm_form, text="Destination")
|
||||
ent_standby_destination = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standby_balance = tk.Label(master=frm_form, text="XRP Balance")
|
||||
ent_standby_balance = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standby_currency = tk.Label(master=frm_form, text="Currency")
|
||||
ent_standby_currency = tk.Entry(master=frm_form, width=50)
|
||||
cb_standby_allow_rippling = tk.Checkbutton(master=frm_form, text="Allow Rippling", variable=standbyRippling, onvalue=True, offvalue=False)
|
||||
lbl_standby_uri = tk.Label(master=frm_form, text="NFT URI")
|
||||
ent_standby_uri = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standby_flags = tk.Label(master=frm_form, text="Flags")
|
||||
ent_standby_flags = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standby_transfer_fee = tk.Label(master=frm_form, text="Transfer Fee")
|
||||
ent_standby_transfer_fee = tk.Entry(master=frm_form, width="50")
|
||||
lbl_standby_taxon = tk.Label(master=frm_form, text="Taxon")
|
||||
ent_standby_taxon = tk.Entry(master=frm_form, width="50")
|
||||
lbl_standby_nft_id = tk.Label(master=frm_form, text="NFT ID")
|
||||
ent_standby_nft_id = tk.Entry(master=frm_form, width="50")
|
||||
lbl_standby_nft_offer_index = tk.Label(master=frm_form, text="NFT Offer Index")
|
||||
ent_standby_nft_offer_index = tk.Entry(master=frm_form, width="50")
|
||||
lbl_standby_owner = tk.Label(master=frm_form, text="Owner")
|
||||
ent_standby_owner = tk.Entry(master=frm_form, width="50")
|
||||
lbl_standby_expiration = tk.Label(master=frm_form, text="Expiration")
|
||||
ent_standby_expiration = tk.Entry(master=frm_form, width="50")
|
||||
lbl_standby_auth_minter = tk.Label(master=frm_form, text="Authorized Minter")
|
||||
ent_standby_auth_minter = tk.Entry(master=frm_form, width="50")
|
||||
lbl_standby_issuer = tk.Label(master=frm_form, text="Issuer")
|
||||
ent_standby_issuer = tk.Entry(master=frm_form, width="50")
|
||||
lbl_standby_results = tk.Label(master=frm_form,text='Results')
|
||||
text_standby_results = tk.Text(master=frm_form, height = 50, width = 65)
|
||||
|
||||
|
||||
# Place field in a grid.
|
||||
lbl_standy_seed.grid(row=0, column=0, sticky="w")
|
||||
ent_standby_seed.grid(row=0, column=1)
|
||||
lbl_standby_account.grid(row=2, column=0, sticky="e")
|
||||
ent_standby_account.grid(row=2, column=1)
|
||||
lbl_standy_amount.grid(row=3, column=0, sticky="e")
|
||||
ent_standby_amount.grid(row=3, column=1)
|
||||
lbl_standby_destination.grid(row=4, column=0, sticky="e")
|
||||
ent_standby_destination.grid(row=4, column=1)
|
||||
lbl_standby_balance.grid(row=5, column=0, sticky="e")
|
||||
ent_standby_balance.grid(row=5, column=1)
|
||||
lbl_standby_currency.grid(row=6, column=0, sticky="e")
|
||||
ent_standby_currency.grid(row=6, column=1)
|
||||
cb_standby_allow_rippling.grid(row=7,column=1, sticky="w")
|
||||
lbl_standby_uri.grid(row=8, column=0, sticky="e")
|
||||
ent_standby_uri.grid(row=8, column=1, sticky="w")
|
||||
lbl_standby_flags.grid(row=9, column=0, sticky="e")
|
||||
ent_standby_flags.grid(row=9, column=1, sticky="w")
|
||||
lbl_standby_transfer_fee.grid(row=10, column=0, sticky="e")
|
||||
ent_standby_transfer_fee.grid(row=10, column=1, sticky="w")
|
||||
lbl_standby_taxon.grid(row=11, column=0, sticky="e")
|
||||
ent_standby_taxon.grid(row=11, column=1, sticky="w")
|
||||
lbl_standby_nft_id.grid(row=12, column=0, sticky="e")
|
||||
ent_standby_nft_id.grid(row=12, column=1, sticky="w")
|
||||
lbl_standby_nft_offer_index.grid(row=13, column=0, sticky="ne")
|
||||
ent_standby_nft_offer_index.grid(row=13, column=1, sticky="w")
|
||||
lbl_standby_owner.grid(row=14, column=0, sticky="ne")
|
||||
ent_standby_owner.grid(row=14, column=1, sticky="w")
|
||||
lbl_standby_expiration.grid(row=15, column=0, sticky="ne")
|
||||
ent_standby_expiration.grid(row=15, column=1, sticky="w")
|
||||
lbl_standby_auth_minter.grid(row=16,column=0, sticky="ne")
|
||||
ent_standby_auth_minter.grid(row=16,column=1, sticky="w")
|
||||
lbl_standby_issuer.grid(row=17,column=0, sticky="ne")
|
||||
ent_standby_issuer.grid(row=17,column=1, sticky="w")
|
||||
lbl_standby_results.grid(row=18, column=0, sticky="ne")
|
||||
text_standby_results.grid(row=18, column=1, sticky="nw")
|
||||
|
||||
cb_standby_allow_rippling.select()
|
||||
|
||||
###############################################
|
||||
## Operational Account ########################
|
||||
###############################################
|
||||
|
||||
# Create the Label and Entry widgets for "Operational Account"
|
||||
lbl_operational_seed = tk.Label(master=frm_form, text="Operational Seed")
|
||||
ent_operational_seed = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_account = tk.Label(master=frm_form, text="Operational Account")
|
||||
ent_operational_account = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_amount = tk.Label(master=frm_form, text="Amount")
|
||||
ent_operational_amount = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_destination = tk.Label(master=frm_form, text="Destination")
|
||||
ent_operational_destination = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_balance = tk.Label(master=frm_form, text="XRP Balance")
|
||||
ent_operational_balance = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_currency = tk.Label(master=frm_form, text="Currency")
|
||||
ent_operational_currency = tk.Entry(master=frm_form, width=50)
|
||||
cb_operational_allow_rippling = tk.Checkbutton(master=frm_form, text="Allow Rippling", variable=operationalRippling, onvalue=True, offvalue=False)
|
||||
lbl_operational_uri = tk.Label(master=frm_form, text="NFT URI")
|
||||
ent_operational_uri = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_flags = tk.Label(master=frm_form, text="Flags")
|
||||
ent_operational_flags = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_transfer_fee = tk.Label(master=frm_form, text="Transfer Fee")
|
||||
ent_operational_transfer_fee = tk.Entry(master=frm_form, width="50")
|
||||
lbl_operational_taxon = tk.Label(master=frm_form, text="Taxon")
|
||||
ent_operational_taxon = tk.Entry(master=frm_form, width="50")
|
||||
lbl_operational_nft_id = tk.Label(master=frm_form, text="NFT ID")
|
||||
ent_operational_nft_id = tk.Entry(master=frm_form, width="50")
|
||||
lbl_operational_nft_offer_index = tk.Label(master=frm_form, text="NFT Offer Index")
|
||||
ent_operational_nft_offer_index = tk.Entry(master=frm_form, width="50")
|
||||
lbl_operational_owner = tk.Label(master=frm_form, text="Owner")
|
||||
ent_operational_owner = tk.Entry(master=frm_form, width="50")
|
||||
lbl_operational_expiration = tk.Label(master=frm_form, text="Expiration")
|
||||
ent_operational_expiration = tk.Entry(master=frm_form, width="50")
|
||||
lbl_operational_auth_minter = tk.Label(master=frm_form, text="Authorized Minter")
|
||||
ent_operational_auth_minter = tk.Entry(master=frm_form, width="50")
|
||||
lbl_operational_issuer = tk.Label(master=frm_form, text="Issuer")
|
||||
ent_operational_issuer = tk.Entry(master=frm_form, width="50")
|
||||
lbl_operational_results = tk.Label(master=frm_form,text="Results")
|
||||
text_operational_results = tk.Text(master=frm_form, height = 50, width = 65)
|
||||
|
||||
#Place the widgets in a grid
|
||||
lbl_operational_seed.grid(row=0, column=4, sticky="e")
|
||||
ent_operational_seed.grid(row=0, column=5, sticky="w")
|
||||
lbl_operational_account.grid(row=2,column=4, sticky="e")
|
||||
ent_operational_account.grid(row=2,column=5, sticky="w")
|
||||
lbl_operational_amount.grid(row=3, column=4, sticky="e")
|
||||
ent_operational_amount.grid(row=3, column=5, sticky="w")
|
||||
lbl_operational_destination.grid(row=4, column=4, sticky="e")
|
||||
ent_operational_destination.grid(row=4, column=5, sticky="w")
|
||||
lbl_operational_balance.grid(row=5, column=4, sticky="e")
|
||||
ent_operational_balance.grid(row=5, column=5, sticky="w")
|
||||
lbl_operational_currency.grid(row=6, column=4, sticky="e")
|
||||
ent_operational_currency.grid(row=6, column=5)
|
||||
cb_operational_allow_rippling.grid(row=7,column=5, sticky="w")
|
||||
lbl_operational_uri.grid(row=8, column=4, sticky="e")
|
||||
ent_operational_uri.grid(row=8, column=5, sticky="w")
|
||||
lbl_operational_flags.grid(row=9, column=4, sticky="e")
|
||||
ent_operational_flags.grid(row=9, column=5, sticky="w")
|
||||
lbl_operational_transfer_fee.grid(row=10, column=4, sticky="e")
|
||||
ent_operational_transfer_fee.grid(row=10, column=5, sticky="w")
|
||||
lbl_operational_taxon.grid(row=11, column=4, sticky="e")
|
||||
ent_operational_taxon.grid(row=11, column=5, sticky="w")
|
||||
lbl_operational_nft_id.grid(row=12, column=4, sticky="e")
|
||||
ent_operational_nft_id.grid(row=12, column=5, sticky="w")
|
||||
lbl_operational_nft_offer_index.grid(row=13, column=4, sticky="ne")
|
||||
ent_operational_nft_offer_index.grid(row=13, column=5, sticky="w")
|
||||
lbl_operational_owner.grid(row=14, column=4, sticky="ne")
|
||||
ent_operational_owner.grid(row=14, column=5, sticky="w")
|
||||
lbl_operational_expiration.grid(row=15, column=4, sticky="ne")
|
||||
ent_operational_expiration.grid(row=15, column=5, sticky="w")
|
||||
lbl_operational_auth_minter.grid(row=16, column=4, sticky="ne")
|
||||
ent_operational_auth_minter.grid(row=16, column=5, sticky="w")
|
||||
lbl_operational_issuer.grid(row=17, column=4, sticky="ne")
|
||||
ent_operational_issuer.grid(row=17, column=5, sticky="w")
|
||||
lbl_operational_results.grid(row=18, column=4, sticky="ne")
|
||||
text_operational_results.grid(row=18, column=5, sticky="nw")
|
||||
|
||||
cb_operational_allow_rippling.select()
|
||||
|
||||
#############################################
|
||||
## Buttons ##################################
|
||||
#############################################
|
||||
|
||||
# Create the Standby Account Buttons
|
||||
btn_get_standby_account = tk.Button(master=frm_form, text="Get Standby Account",
|
||||
command = get_standby_account)
|
||||
btn_get_standby_account.grid(row=0, column=2, sticky = "nsew")
|
||||
btn_get_standby_account_info = tk.Button(master=frm_form,
|
||||
text="Get Standby Account Info",
|
||||
command = get_standby_account_info)
|
||||
btn_get_standby_account_info.grid(row=1, column=2, sticky = "nsew")
|
||||
btn_standby_send_xrp = tk.Button(master=frm_form, text="Send XRP >",
|
||||
command = standby_send_xrp)
|
||||
btn_standby_send_xrp.grid(row=2, column = 2, sticky = "nsew")
|
||||
btn_standby_create_trust_line = tk.Button(master=frm_form,
|
||||
text="Create Trust Line",
|
||||
command = standby_create_trust_line)
|
||||
btn_standby_create_trust_line.grid(row=4, column=2, sticky = "nsew")
|
||||
btn_standby_send_currency = tk.Button(master=frm_form, text="Send Currency >",
|
||||
command = standby_send_currency)
|
||||
btn_standby_send_currency.grid(row=5, column=2, sticky = "nsew")
|
||||
btn_standby_send_currency = tk.Button(master=frm_form, text="Get Balances",
|
||||
command = get_balances)
|
||||
btn_standby_send_currency.grid(row=6, column=2, sticky = "nsew")
|
||||
btn_standby_configure_account = tk.Button(master=frm_form,
|
||||
text="Configure Account",
|
||||
command = standby_configure_account)
|
||||
btn_standby_configure_account.grid(row=7,column=0, sticky = "nsew")
|
||||
btn_standby_mint_token = tk.Button(master=frm_form, text="Mint NFT",
|
||||
command = standby_mint_token)
|
||||
btn_standby_mint_token.grid(row=8, column=2, sticky="nsew")
|
||||
btn_standby_get_tokens = tk.Button(master=frm_form, text="Get NFTs",
|
||||
command = standby_get_tokens)
|
||||
btn_standby_get_tokens.grid(row=9, column=2, sticky="nsew")
|
||||
btn_standby_burn_token = tk.Button(master=frm_form, text="Burn NFT",
|
||||
command = standby_burn_token)
|
||||
btn_standby_burn_token.grid(row=10, column=2, sticky="nsew")
|
||||
btn_standby_create_sell_offer = tk.Button(master=frm_form, text="Create Sell Offer",
|
||||
command = standby_create_sell_offer)
|
||||
btn_standby_create_sell_offer.grid(row=11, column=2, sticky="nsew")
|
||||
btn_standby_accept_sell_offer = tk.Button(master=frm_form, text="Accept Sell Offer",
|
||||
command = standby_accept_sell_offer)
|
||||
btn_standby_accept_sell_offer.grid(row=12, column=2, sticky="nsew")
|
||||
btn_standby_create_buy_offer = tk.Button(master=frm_form, text="Create Buy Offer",
|
||||
command = standby_create_buy_offer)
|
||||
btn_standby_create_buy_offer.grid(row=13, column=2, sticky="nsew")
|
||||
btn_standby_accept_buy_offer = tk.Button(master=frm_form, text="Accept Buy Offer",
|
||||
command = standby_accept_buy_offer)
|
||||
btn_standby_accept_buy_offer.grid(row=14, column=2, sticky="nsew")
|
||||
btn_standby_get_offers = tk.Button(master=frm_form, text="Get Offers",
|
||||
command = standby_get_offers)
|
||||
btn_standby_get_offers.grid(row=15, column=2, sticky="nsew")
|
||||
btn_standby_cancel_offer = tk.Button(master=frm_form, text="Cancel Offer",
|
||||
command = standby_cancel_offer)
|
||||
btn_standby_cancel_offer.grid(row=16, column=2, sticky="nsew")
|
||||
btn_standby_set_minter = tk.Button(master=frm_form, text="Set Minter",
|
||||
command = standby_set_minter)
|
||||
btn_standby_set_minter.grid(row=17, column=2, sticky="nsew")
|
||||
btn_standby_mint_other = tk.Button(master=frm_form, text="Mint Other",
|
||||
command = standby_mint_other)
|
||||
btn_standby_mint_other.grid(row=18, column=2, sticky="new")
|
||||
|
||||
|
||||
|
||||
# Create the Operational Account Buttons
|
||||
btn_get_operational_account = tk.Button(master=frm_form,
|
||||
text="Get Operational Account",
|
||||
command = get_operational_account)
|
||||
btn_get_operational_account.grid(row=0, column=3, sticky = "nsew")
|
||||
btn_get_op_account_info = tk.Button(master=frm_form, text="Get Op Account Info",
|
||||
command = get_operational_account_info)
|
||||
btn_get_op_account_info.grid(row=1, column=3, sticky = "nsew")
|
||||
btn_op_send_xrp = tk.Button(master=frm_form, text="< Send XRP",
|
||||
command = operational_send_xrp)
|
||||
btn_op_send_xrp.grid(row=2, column = 3, sticky = "nsew")
|
||||
btn_op_create_trust_line = tk.Button(master=frm_form, text="Create Trust Line",
|
||||
command = operational_create_trust_line)
|
||||
btn_op_create_trust_line.grid(row=4, column=3, sticky = "nsew")
|
||||
btn_op_send_currency = tk.Button(master=frm_form, text="< Send Currency",
|
||||
command = operational_send_currency)
|
||||
btn_op_send_currency.grid(row=5, column=3, sticky = "nsew")
|
||||
btn_op_get_balances = tk.Button(master=frm_form, text="Get Balances",
|
||||
command = get_balances)
|
||||
btn_op_get_balances.grid(row=6, column=3, sticky = "nsew")
|
||||
btn_op_configure_account = tk.Button(master=frm_form, text="Configure Account",
|
||||
command = operational_configure_account)
|
||||
btn_op_configure_account.grid(row=7,column=4, sticky = "nsew")
|
||||
btn_op_mint_token = tk.Button(master=frm_form, text="Mint NFT",
|
||||
command = operational_mint_token)
|
||||
btn_op_mint_token.grid(row=8, column=3, sticky="nsew")
|
||||
btn_op_get_tokens = tk.Button(master=frm_form, text="Get NFTs",
|
||||
command = operational_get_tokens)
|
||||
btn_op_get_tokens.grid(row=9, column=3, sticky="nsew")
|
||||
btn_op_burn_token = tk.Button(master=frm_form, text="Burn NFT",
|
||||
command = operational_burn_token)
|
||||
btn_op_burn_token.grid(row=10, column=3, sticky="nsew")
|
||||
btn_op_create_sell_offer = tk.Button(master=frm_form, text="Create Sell Offer",
|
||||
command = op_create_sell_offer)
|
||||
btn_op_create_sell_offer.grid(row=11, column=3, sticky="nsew")
|
||||
btn_op_accept_sell_offer = tk.Button(master=frm_form, text="Accept Sell Offer",
|
||||
command = op_accept_sell_offer)
|
||||
btn_op_accept_sell_offer.grid(row=12, column=3, sticky="nsew")
|
||||
btn_op_create_buy_offer = tk.Button(master=frm_form, text="Create Buy Offer",
|
||||
command = op_create_buy_offer)
|
||||
btn_op_create_buy_offer.grid(row=13, column=3, sticky="nsew")
|
||||
btn_op_accept_buy_offer = tk.Button(master=frm_form, text="Accept Buy Offer",
|
||||
command = op_accept_buy_offer)
|
||||
btn_op_accept_buy_offer.grid(row=14, column=3, sticky="nsew")
|
||||
btn_op_get_offers = tk.Button(master=frm_form, text="Get Offers",
|
||||
command = op_get_offers)
|
||||
btn_op_get_offers.grid(row=15, column=3, sticky="nsew")
|
||||
btn_op_cancel_offer = tk.Button(master=frm_form, text="Cancel Offer",
|
||||
command = op_cancel_offer)
|
||||
btn_op_cancel_offer.grid(row=16, column=3, sticky="nsew")
|
||||
btn_op_set_minter = tk.Button(master=frm_form, text="Set Minter",
|
||||
command = operational_set_minter)
|
||||
btn_op_set_minter.grid(row=17, column=3, sticky="nsew")
|
||||
btn_op_mint_other = tk.Button(master=frm_form, text="Mint Other",
|
||||
command = operational_mint_other)
|
||||
btn_op_mint_other.grid(row=18, column=3, sticky="new")
|
||||
|
||||
# Start the application
|
||||
window.mainloop()
|
||||
44
content/_code-samples/quickstart/py/mod1.py
Normal file
@@ -0,0 +1,44 @@
|
||||
import xrpl
|
||||
import json
|
||||
import xrpl.clients
|
||||
import xrpl.wallet
|
||||
|
||||
def get_account(seed):
|
||||
"""get_account"""
|
||||
JSON_RPC_URL = "https://s.altnet.rippletest.net:51234/"
|
||||
client = xrpl.clients.JsonRpcClient(JSON_RPC_URL)
|
||||
if (seed == ''):
|
||||
new_wallet = xrpl.wallet.generate_faucet_wallet(client)
|
||||
else:
|
||||
new_wallet = xrpl.wallet.Wallet(seed, sequence = 79396029)
|
||||
return(new_wallet)
|
||||
|
||||
def get_account_info(accountId):
|
||||
"""get_account_info"""
|
||||
JSON_RPC_URL = 'wss://s.altnet.rippletest.net:51234'
|
||||
client = xrpl.clients.JsonRpcClient(JSON_RPC_URL)
|
||||
acct_info = xrpl.models.requests.account_info.AccountInfo(
|
||||
account=accountId,
|
||||
ledger_index="validated"
|
||||
)
|
||||
response = client.request(acct_info)
|
||||
return response.result['account_data']
|
||||
|
||||
def send_xrp(seed, amount, destination):
|
||||
sending_wallet = xrpl.wallet.Wallet(seed, sequence = 16237283)
|
||||
testnet_url = "https://s.altnet.rippletest.net:51234"
|
||||
client = xrpl.clients.JsonRpcClient(testnet_url)
|
||||
payment = xrpl.models.transactions.Payment(
|
||||
account=sending_wallet.classic_address,
|
||||
amount=xrpl.utils.xrp_to_drops(int(amount)),
|
||||
destination=destination,
|
||||
)
|
||||
signed_tx = xrpl.transaction.safe_sign_and_autofill_transaction(
|
||||
payment, sending_wallet, client)
|
||||
try:
|
||||
tx_response = xrpl.transaction.send_reliable_submission(signed_tx,client)
|
||||
response = tx_response
|
||||
except xrpl.transaction.XRPLReliableSubmissionException as e:
|
||||
response = f"Submit failed: {e}"
|
||||
return response
|
||||
|
||||
119
content/_code-samples/quickstart/py/mod2.py
Normal file
@@ -0,0 +1,119 @@
|
||||
import xrpl
|
||||
import json
|
||||
from xrpl.clients import JsonRpcClient
|
||||
from xrpl.wallet import Wallet
|
||||
from xrpl.models.requests.account_info import AccountInfo
|
||||
|
||||
|
||||
testnet_url = "https://s.altnet.rippletest.net:51234"
|
||||
|
||||
#####################
|
||||
# create_trust_line #
|
||||
#####################
|
||||
|
||||
def create_trust_line(seed, issuer, currency, amount):
|
||||
"""create_trust_line"""
|
||||
# Get the client
|
||||
receiving_wallet = Wallet(seed, sequence = 16237283)
|
||||
client = JsonRpcClient(testnet_url)
|
||||
# Define the trust line transaction
|
||||
trustline_tx=xrpl.models.transactions.TrustSet(
|
||||
account=receiving_wallet.classic_address,
|
||||
limit_amount=xrpl.models.amounts.IssuedCurrencyAmount(
|
||||
currency=currency,
|
||||
issuer=issuer,
|
||||
value=int(amount)
|
||||
)
|
||||
)
|
||||
# Sign and fill the transaction
|
||||
signed_tx = xrpl.transaction.safe_sign_and_autofill_transaction(
|
||||
trustline_tx, receiving_wallet, client)
|
||||
# Submit the transaction and get results
|
||||
reply = ""
|
||||
try:
|
||||
response = xrpl.transaction.send_reliable_submission(signed_tx,client)
|
||||
reply = response.result
|
||||
except xrpl.transaction.XRPLReliableSubmissionException as e:
|
||||
reply = f"Submit failed: {e}"
|
||||
return reply
|
||||
|
||||
#################
|
||||
# send_currency #
|
||||
#################
|
||||
|
||||
def send_currency(seed, destination, currency, amount):
|
||||
"""send_currency"""
|
||||
# Get the client
|
||||
sending_wallet=Wallet(seed, sequence=16237283)
|
||||
client=JsonRpcClient(testnet_url)
|
||||
# Define the payment transaction.
|
||||
send_currency_tx=xrpl.models.transactions.Payment(
|
||||
account=sending_wallet.classic_address,
|
||||
amount=xrpl.models.amounts.IssuedCurrencyAmount(
|
||||
currency=currency,
|
||||
value=int(amount),
|
||||
issuer=sending_wallet.classic_address
|
||||
),
|
||||
destination=destination
|
||||
)
|
||||
# Sign and fill the transaction
|
||||
signed_tx=xrpl.transaction.safe_sign_and_autofill_transaction(
|
||||
send_currency_tx, sending_wallet, client)
|
||||
# Submit the transaction and get results
|
||||
reply = ""
|
||||
try:
|
||||
response=xrpl.transaction.send_reliable_submission(signed_tx,client)
|
||||
reply = response.result
|
||||
except xrpl.transaction.XRPLReliableSubmissionException as e:
|
||||
reply = f"Submit failed: {e}"
|
||||
return reply
|
||||
|
||||
###############
|
||||
# get_balance #
|
||||
###############
|
||||
|
||||
def get_balance(sb_account_id, op_account_id):
|
||||
"""get_balance"""
|
||||
JSON_RPC_URL='wss://s.altnet.rippletest.net:51234'
|
||||
client=JsonRpcClient(JSON_RPC_URL)
|
||||
balance=xrpl.models.requests.GatewayBalances(
|
||||
account=sb_account_id,
|
||||
ledger_index="validated",
|
||||
hotwallet=[op_account_id]
|
||||
)
|
||||
response = client.request(balance)
|
||||
return response.result
|
||||
|
||||
#####################
|
||||
# configure_account #
|
||||
#####################
|
||||
|
||||
def configure_account(seed, default_setting):
|
||||
"""configure_account"""
|
||||
# Get the client
|
||||
wallet=Wallet(seed, sequence = 16237283)
|
||||
client=JsonRpcClient(testnet_url)
|
||||
# Create transaction
|
||||
if (default_setting):
|
||||
setting_tx=xrpl.models.transactions.AccountSet(
|
||||
account=wallet.classic_address,
|
||||
set_flag=xrpl.models.transactions.AccountSetFlag.ASF_DEFAULT_RIPPLE
|
||||
)
|
||||
else:
|
||||
setting_tx=xrpl.models.transactions.AccountSet(
|
||||
account=wallet.classic_address,
|
||||
clear_flag=xrpl.models.transactions.AccountSetFlag.ASF_DEFAULT_RIPPLE
|
||||
)
|
||||
|
||||
# Sign and fill the transaction
|
||||
signed_tx=xrpl.transaction.safe_sign_and_autofill_transaction(
|
||||
setting_tx, wallet, client)
|
||||
# Submit the transaction and get results
|
||||
reply = ""
|
||||
try:
|
||||
response = xrpl.transaction.send_reliable_submission(signed_tx,client)
|
||||
reply = response.result
|
||||
except xrpl.transaction.XRPLReliableSubmissionException as e:
|
||||
reply = f"Submit failed: {e}"
|
||||
return reply
|
||||
|
||||
64
content/_code-samples/quickstart/py/mod3.py
Normal file
@@ -0,0 +1,64 @@
|
||||
import xrpl
|
||||
import json
|
||||
from xrpl.clients import JsonRpcClient
|
||||
from xrpl.wallet import Wallet
|
||||
from xrpl.models.requests import AccountNFTs
|
||||
|
||||
testnet_url = "https://s.altnet.rippletest.net:51234"
|
||||
|
||||
def mint_token(seed, uri, flags, transfer_fee, taxon):
|
||||
"""mint_token"""
|
||||
# Get the client
|
||||
mint_wallet=Wallet(seed, sequence=16237283)
|
||||
client=JsonRpcClient(testnet_url)
|
||||
# Define the mint transaction
|
||||
mint_tx=xrpl.models.transactions.NFTokenMint(
|
||||
account=mint_wallet.classic_address,
|
||||
uri=xrpl.utils.str_to_hex(uri),
|
||||
flags=int(flags),
|
||||
transfer_fee=int(transfer_fee),
|
||||
nftoken_taxon=int(taxon)
|
||||
)
|
||||
# Sign and fill the transaction
|
||||
signed_tx = xrpl.transaction.safe_sign_and_autofill_transaction(
|
||||
mint_tx, mint_wallet, client)
|
||||
# Submit the transaction and get results
|
||||
reply=""
|
||||
try:
|
||||
response=xrpl.transaction.send_reliable_submission(signed_tx,client)
|
||||
reply=response.result
|
||||
except xrpl.transaction.XRPLReliableSubmissionException as e:
|
||||
reply=f"Submit failed: {e}"
|
||||
return reply
|
||||
|
||||
|
||||
def get_tokens(account):
|
||||
"""get_tokens"""
|
||||
client=JsonRpcClient(testnet_url)
|
||||
acct_nfts=AccountNFTs(
|
||||
account=account
|
||||
)
|
||||
response=client.request(acct_nfts)
|
||||
return response.result
|
||||
|
||||
|
||||
def burn_token(seed, nftoken_id):
|
||||
"""burn_token"""
|
||||
# Get the client
|
||||
owner_wallet=Wallet(seed, sequence=16237283)
|
||||
client=JsonRpcClient(testnet_url)
|
||||
burn_tx=xrpl.models.transactions.NFTokenBurn(
|
||||
account=owner_wallet.classic_address,
|
||||
nftoken_id=nftoken_id
|
||||
)
|
||||
# Sign and fill the transaction
|
||||
signed_tx=xrpl.transaction.safe_sign_and_autofill_transaction(
|
||||
burn_tx, owner_wallet, client)
|
||||
# Submit the transaction and get results
|
||||
reply=""
|
||||
try:
|
||||
response=xrpl.transaction.send_reliable_submission(signed_tx,client)
|
||||
reply=response.result
|
||||
except xrpl.transaction.XRPLReliableSubmissionException as e:
|
||||
reply=f"Submit failed: {e}"
|
||||
return reply
|
||||
149
content/_code-samples/quickstart/py/mod4.py
Normal file
@@ -0,0 +1,149 @@
|
||||
import xrpl
|
||||
import json
|
||||
from xrpl.clients import JsonRpcClient
|
||||
from xrpl.wallet import Wallet
|
||||
from datetime import datetime
|
||||
from datetime import timedelta
|
||||
from xrpl.models.requests import NFTSellOffers
|
||||
from xrpl.models.requests import NFTBuyOffers
|
||||
from xrpl.models.transactions import NFTokenAcceptOffer
|
||||
testnet_url = "https://s.altnet.rippletest.net:51234"
|
||||
|
||||
def create_sell_offer(seed, amount, nftoken_id, expiration, destination):
|
||||
"""create_sell_offer"""
|
||||
# Get the client
|
||||
owner_wallet = Wallet(seed, sequence=16237283)
|
||||
client = JsonRpcClient(testnet_url)
|
||||
expiration_date = datetime.now()
|
||||
if expiration != '':
|
||||
expiration_date = xrpl.utils.datetime_to_ripple_time(expiration_date)
|
||||
expiration_date = expiration_date + int(expiration)
|
||||
# Define the sell offer
|
||||
sell_offer_tx=xrpl.models.transactions.NFTokenCreateOffer(
|
||||
account=owner_wallet.classic_address,
|
||||
nftoken_id=nftoken_id,
|
||||
amount=amount,
|
||||
destination=destination if destination != '' else None,
|
||||
expiration=expiration_date if expiration != '' else None,
|
||||
flags=1
|
||||
)
|
||||
# Sign and fill the transaction
|
||||
signed_tx=xrpl.transaction.safe_sign_and_autofill_transaction(
|
||||
sell_offer_tx, owner_wallet, client)
|
||||
# Submit the transaction and report the results
|
||||
reply=""
|
||||
try:
|
||||
response=xrpl.transaction.send_reliable_submission(signed_tx,client)
|
||||
reply=response.result
|
||||
except xrpl.transaction.XRPLReliableSubmissionException as e:
|
||||
reply=f"Submit failed: {e}"
|
||||
return reply
|
||||
|
||||
|
||||
def accept_sell_offer(seed, offer_index):
|
||||
"""accept_sell_offer"""
|
||||
buyer_wallet=Wallet(seed, sequence=16237283)
|
||||
client=JsonRpcClient(testnet_url)
|
||||
accept_offer_tx=xrpl.models.transactions.NFTokenAcceptOffer(
|
||||
account=buyer_wallet.classic_address,
|
||||
nftoken_sell_offer=offer_index
|
||||
)
|
||||
# Sign and fill the transaction
|
||||
signed_tx=xrpl.transaction.safe_sign_and_autofill_transaction(
|
||||
accept_offer_tx, buyer_wallet, client)
|
||||
# Submit the transaction and report the results
|
||||
reply=""
|
||||
try:
|
||||
response=xrpl.transaction.send_reliable_submission(signed_tx,client)
|
||||
reply=response.result
|
||||
except xrpl.transaction.XRPLReliableSubmissionException as e:
|
||||
reply=f"Submit failed: {e}"
|
||||
return reply
|
||||
|
||||
|
||||
def create_buy_offer(seed, amount, nft_id, owner, expiration, destination):
|
||||
"""create_buy_offer"""
|
||||
# Get the client
|
||||
buyer_wallet=Wallet(seed, sequence=16237283)
|
||||
client=JsonRpcClient(testnet_url)
|
||||
expiration_date=datetime.now()
|
||||
if (expiration!=''):
|
||||
expiration_date=xrpl.utils.datetime_to_ripple_time(expiration_date)
|
||||
expiration_date=expiration_date + int(expiration)
|
||||
# Define the buy offer transaction with an expiration date
|
||||
buy_offer_tx=xrpl.models.transactions.NFTokenCreateOffer(
|
||||
account=buyer_wallet.classic_address,
|
||||
nftoken_id=nft_id,
|
||||
amount=amount,
|
||||
owner=owner,
|
||||
expiration=expiration_date if expiration!='' else None,
|
||||
destination=destination if destination!='' else None,
|
||||
flags=0
|
||||
)
|
||||
# Sign and fill the transaction
|
||||
signed_tx=xrpl.transaction.safe_sign_and_autofill_transaction(
|
||||
buy_offer_tx, buyer_wallet, client)
|
||||
# Submit the transaction and report the results
|
||||
reply=""
|
||||
try:
|
||||
response=xrpl.transaction.send_reliable_submission(signed_tx,client)
|
||||
reply=response.result
|
||||
except xrpl.transaction.XRPLReliableSubmissionException as e:
|
||||
reply=f"Submit failed: {e}"
|
||||
return reply
|
||||
|
||||
|
||||
def accept_buy_offer(seed, offer_index):
|
||||
"""accept_buy_offer"""
|
||||
buyer_wallet=Wallet(seed, sequence=16237283)
|
||||
client=JsonRpcClient(testnet_url)
|
||||
accept_offer_tx=xrpl.models.transactions.NFTokenAcceptOffer(
|
||||
account=buyer_wallet.classic_address,
|
||||
nftoken_buy_offer=offer_index
|
||||
)
|
||||
# Sign and fill the transaction
|
||||
signed_tx=xrpl.transaction.safe_sign_and_autofill_transaction(
|
||||
accept_offer_tx, buyer_wallet, client)
|
||||
# Submit the transaction and report the results
|
||||
reply=""
|
||||
try:
|
||||
response=xrpl.transaction.send_reliable_submission(signed_tx,client)
|
||||
reply=response.result
|
||||
except xrpl.transaction.XRPLReliableSubmissionException as e:
|
||||
reply=f"Submit failed: {e}"
|
||||
return reply
|
||||
|
||||
def get_offers(nft_id):
|
||||
"""get_offers"""
|
||||
client=JsonRpcClient(testnet_url)
|
||||
offers=NFTBuyOffers(
|
||||
nft_id=nft_id
|
||||
)
|
||||
response=client.request(offers)
|
||||
allOffers="Buy Offers:\n"+json.dumps(response.result, indent=4)
|
||||
offers=NFTSellOffers(
|
||||
nft_id=nft_id
|
||||
)
|
||||
response=client.request(offers)
|
||||
allOffers+="\n\nSell Offers:\n"+json.dumps(response.result, indent=4)
|
||||
return allOffers
|
||||
|
||||
def cancel_offer(seed, nftoken_offer_ids):
|
||||
"""cancel_offer"""
|
||||
owner_wallet=Wallet(seed, sequence=16237283)
|
||||
client=JsonRpcClient(testnet_url)
|
||||
tokenOfferIDs=[nftoken_offer_ids]
|
||||
nftSellOffers="No sell offers"
|
||||
cancel_offer_tx=xrpl.models.transactions.NFTokenCancelOffer(
|
||||
account=owner_wallet.classic_address,
|
||||
nftoken_offers=tokenOfferIDs
|
||||
)
|
||||
signed_tx = xrpl.transaction.safe_sign_and_autofill_transaction(
|
||||
cancel_offer_tx, owner_wallet, client)
|
||||
reply=""
|
||||
try:
|
||||
response=xrpl.transaction.send_reliable_submission(signed_tx,client)
|
||||
reply=response.result
|
||||
except xrpl.transaction.XRPLReliableSubmissionException as e:
|
||||
reply=f"Submit failed: {e}"
|
||||
return reply
|
||||
28
content/_code-samples/quickstart/py/mod5.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import xrpl
|
||||
import json
|
||||
from xrpl.clients import JsonRpcClient
|
||||
from xrpl.wallet import Wallet
|
||||
testnet_url = "https://s.altnet.rippletest.net:51234"
|
||||
|
||||
|
||||
def broker_sale(seed, sell_offer_index, buy_offer_index, broker_fee):
|
||||
"""broker_sale"""
|
||||
broker_wallet=Wallet(seed, sequence=16237283)
|
||||
client=JsonRpcClient(testnet_url)
|
||||
accept_offer_tx=xrpl.models.transactions.NFTokenAcceptOffer(
|
||||
account=broker_wallet.classic_address,
|
||||
nftoken_sell_offer=sell_offer_index,
|
||||
nftoken_buy_offer=buy_offer_index,
|
||||
nftoken_broker_fee=broker_fee
|
||||
)
|
||||
# Sign and fill the transaction
|
||||
signed_tx=xrpl.transaction.safe_sign_and_autofill_transaction(
|
||||
accept_offer_tx, broker_wallet, client)
|
||||
# Submit the transaction and report the results
|
||||
reply=""
|
||||
try:
|
||||
response=xrpl.transaction.send_reliable_submission(signed_tx,client)
|
||||
reply=response.result
|
||||
except xrpl.transaction.XRPLReliableSubmissionException as e:
|
||||
reply=f"Submit failed: {e}"
|
||||
return reply
|
||||
47
content/_code-samples/quickstart/py/mod6.py
Normal file
@@ -0,0 +1,47 @@
|
||||
import xrpl
|
||||
import json
|
||||
from xrpl.clients import JsonRpcClient
|
||||
from xrpl.wallet import Wallet
|
||||
testnet_url="https://s.altnet.rippletest.net:51234"
|
||||
|
||||
def set_minter(seed, minter):
|
||||
"""set_minter"""
|
||||
granter_wallet=Wallet(seed, sequence = 16237283)
|
||||
client=JsonRpcClient(testnet_url)
|
||||
|
||||
set_minter_tx=xrpl.models.transactions.AccountSet(
|
||||
account=granter_wallet.classic_address,
|
||||
nftoken_minter=minter,
|
||||
set_flag=xrpl.models.transactions.AccountSetFlag.ASF_AUTHORIZED_NFTOKEN_MINTER
|
||||
)
|
||||
# Sign and fill the transaction
|
||||
signed_tx=xrpl.transaction.safe_sign_and_autofill_transaction(
|
||||
set_minter_tx, granter_wallet, client)
|
||||
# Submit the transaction and report the results
|
||||
try:
|
||||
response=xrpl.transaction.send_reliable_submission(signed_tx,client)
|
||||
except xrpl.transaction.XRPLReliableSubmissionException as e:
|
||||
response=f"Submit failed: {e}"
|
||||
return response.result
|
||||
|
||||
def mint_other(seed, uri, flags, transfer_fee, taxon, issuer):
|
||||
"""mint_other"""
|
||||
minter_wallet=Wallet(seed, sequence=16237283)
|
||||
client=JsonRpcClient(testnet_url)
|
||||
mint_other_tx=xrpl.models.transactions.NFTokenMint(
|
||||
account=minter_wallet.classic_address,
|
||||
uri=xrpl.utils.str_to_hex(uri),
|
||||
flags=int(flags),
|
||||
transfer_fee=int(transfer_fee),
|
||||
nftoken_taxon=int(taxon),
|
||||
issuer=issuer
|
||||
)
|
||||
# Sign and fill the transaction
|
||||
signed_tx=xrpl.transaction.safe_sign_and_autofill_transaction(
|
||||
mint_other_tx, minter_wallet, client)
|
||||
# Submit the transaction and report the results
|
||||
try:
|
||||
response=xrpl.transaction.send_reliable_submission(signed_tx,client)
|
||||
except xrpl.transaction.XRPLReliableSubmissionException as e:
|
||||
response=f"Submit failed: {e}"
|
||||
return response.result
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
html: authorize-minter.html
|
||||
parent: xrpl-quickstart.html
|
||||
blurb: Authorize another account to mint NFTokens for you.
|
||||
parent: quickstart-javascript.html
|
||||
blurb: Authorize another account to mint NFTs for you.
|
||||
labels:
|
||||
- Accounts
|
||||
- Quickstart
|
||||
@@ -11,12 +11,12 @@ labels:
|
||||
|
||||
# Assign an Authorized Minter
|
||||
|
||||
You can assign another account permission to mint NFTokens for you.
|
||||
You can assign another account permission to mint NFTs for you.
|
||||
|
||||
This example shows how to:
|
||||
|
||||
1. Authorize an account to create NFTokens for your account.
|
||||
2. Mint a NFToken for another account, when authorized.
|
||||
1. Authorize an account to create NFTs for your account.
|
||||
2. Mint an NFT for another account, when authorized.
|
||||
|
||||
[](img/quickstart28.png)
|
||||
|
||||
@@ -35,9 +35,9 @@ You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-port
|
||||
1. Click **Get New Standby Account**.
|
||||
2. Click **Get New Operational Account**.
|
||||
|
||||
## Authorize an Account to Create NFTokens
|
||||
## Authorize an Account to Create NFTs
|
||||
|
||||
To authorize another account to create NFTokens for your account:
|
||||
To authorize another account to create NFTs for your account:
|
||||
|
||||
1. Copy the **Operational Account** value.
|
||||
2. Paste the **Operational Account** value in the **Authorized Minter** field.
|
||||
@@ -45,45 +45,45 @@ To authorize another account to create NFTokens for your account:
|
||||
|
||||
[](img/quickstart29.png)
|
||||
|
||||
## Mint a NFToken for Another Account
|
||||
## Mint an NFT for Another Account
|
||||
|
||||
This example uses the Operational account, which was authorized in the previous step, to mint a token on behalf of the Standby account.
|
||||
|
||||
To mint a non-fungible token for another account:
|
||||
|
||||
1. Set the **Flags** field. For testing purposes, we recommend setting the value to _8_.
|
||||
2. Enter the **NFToken URL**. This is a URI that points to the data or metadata associated with the NFToken object. You can use the sample URI provided if you do not have one of your own.
|
||||
3. Enter the **Transfer Fee**, a percentage of the proceeds that the original creator receives from future sales of the NFToken. This is a value of 0-50000 inclusive, allowing transfer rates between 0.000% and 50.000% in increments of 0.001%. If you do not set the **Flags** field to allow the NFToken to be transferrable, set this field to 0.
|
||||
2. Enter the **NFT URL**. This is a URI that points to the data or metadata associated with the NFT object. You can use the sample URI provided if you do not have one of your own.
|
||||
3. Enter the **Transfer Fee**, a percentage of the proceeds that the original creator receives from future sales of the NFT. This is a value of 0-50000 inclusive, allowing transfer rates between 0.000% and 50.000% in increments of 0.001%. If you do not set the **Flags** field to allow the NFT to be transferrable, set this field to 0.
|
||||
4. Copy the **Standby Account** value.
|
||||
5. Paste the **Standby Account** value in the Operational account **Issuer** field.
|
||||
6. Click the Operational account **Mint Other** button.
|
||||
|
||||
[](img/quickstart30.png)
|
||||
[](img/quickstart30.png)
|
||||
|
||||
Once the item is minted, the authorized minter can sell the NFToken normally. The proceeds go to the authorized minter, less the transfer fee. The minter and the issuer can settle up on a division of the price separately.
|
||||
Once the item is minted, the authorized minter can sell the NFT normally. The proceeds go to the authorized minter, less the transfer fee. The minter and the issuer can settle up on a division of the price separately.
|
||||
|
||||
## Create a Sell Offer
|
||||
|
||||
To create a NFToken sell offer:
|
||||
To create an NFT sell offer:
|
||||
|
||||
1. On the Operational account side, enter the **Amount** of the sell offer in drops (millionths of an XRP), for example 100000000 (100 XRP
|
||||
2. Set the **Flags** field to _1_.
|
||||
3. Enter the **NFToken ID** of the minted NFToken you want to sell.
|
||||
3. Enter the **NFT ID** of the minted NFT you want to sell.
|
||||
4. Optionally, enter a number of days until **Expiration**.
|
||||
5. Click **Create Sell Offer**.
|
||||
|
||||
The important piece of information in the response is the NFToken Offer Index, labeled as `nft_offer_index`, which is used to accept the sell offer.
|
||||
The important piece of information in the response is the NFT Offer Index, labeled as `nft_offer_index`, which is used to accept the sell offer.
|
||||
|
||||
[](img/quickstart31.png)
|
||||
[](img/quickstart31.png)
|
||||
|
||||
## Accept Sell Offer
|
||||
|
||||
Once a sell offer is available, you can create a new account to accept the offer and buy the NFToken.
|
||||
Once a sell offer is available, you can create a new account to accept the offer and buy the NFT.
|
||||
|
||||
To accept an available sell offer:
|
||||
|
||||
1. Click **Get New Standby Account**.
|
||||
1. Enter the **NFToken Offer Index** (labeled as `nft_offer_index` in the NFToken offer results. This is different from the `nft_id`).
|
||||
1. Enter the **NFT Offer Index** (labeled as `nft_offer_index` in the NFT offer results. This is different from the `nft_id`).
|
||||
2. Click **Accept Sell Offer**.
|
||||
|
||||
The results show that the Issuer account has been credited 25 XRP. The Buyer account was debited the 100 XRP price plus 12 drops as the transaction cost. The Seller (Authorized Minter) account is credited 75 XRP. the Issuer and the Seller can divide the proceeds per their agreement in a separate transaction.
|
||||
@@ -95,7 +95,7 @@ You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-port
|
||||
|
||||
## Set Minter
|
||||
|
||||
This function sets the authorized minter for an account. Each account can have 0 or 1 authorized minter that can mint NFTokens in its stead.
|
||||
This function sets the authorized minter for an account. Each account can have 0 or 1 authorized minter that can mint NFTs in its stead.
|
||||
|
||||
```javascript
|
||||
// *******************************************************
|
||||
@@ -201,11 +201,11 @@ Connect to the ledger and get the account.
|
||||
Report success
|
||||
|
||||
```javascript
|
||||
results += '\nConnected. Minting NFToken.'
|
||||
results += '\nConnected. Minting NFT.'
|
||||
standbyResultField.value = results
|
||||
```
|
||||
|
||||
This transaction blob is the same as the one used for the previous [`mintToken()` function](mint-and-burn-nftokens.html#mint-token), with the addition of the `Issuer` field.
|
||||
This transaction blob is the same as the one used for the previous [`mintToken()` function](mint-and-burn-nfts.html#mint-token), with the addition of the `Issuer` field.
|
||||
|
||||
```javascript
|
||||
const tx_json = {
|
||||
@@ -213,13 +213,13 @@ This transaction blob is the same as the one used for the previous [`mintToken()
|
||||
"Account": standby_wallet.classicAddress,
|
||||
```
|
||||
|
||||
The URI is a link to a data file represented by the NFToken.
|
||||
The URI is a link to a data file represented by the NFT.
|
||||
|
||||
```javascript
|
||||
"URI": xrpl.convertStringToHex(standbyTokenUrlField.value),
|
||||
```
|
||||
|
||||
At a minimum, we recommend that you set the `tfTransferable` flag (8) to enable accounts to sell and resell the NFToken for testing purposes.
|
||||
At a minimum, we recommend that you set the `tfTransferable` flag (8) to enable accounts to sell and resell the NFT for testing purposes.
|
||||
|
||||
```javascript
|
||||
"Flags": parseInt(standbyFlagsField.value),
|
||||
@@ -231,7 +231,7 @@ Transfer fee is a value 0-50000 representing .001% of the price for a resale to
|
||||
"TransferFee": parseInt(standbyTransferFeeField.value),
|
||||
```
|
||||
|
||||
The **Issuer** is the original creator of the object represented by the NFToken.
|
||||
The **Issuer** is the original creator of the object represented by the NFT.
|
||||
|
||||
```javascript
|
||||
"Issuer": standbyIssuerField.value,
|
||||
@@ -328,7 +328,7 @@ async function oPmintOther() {
|
||||
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
|
||||
const client = new xrpl.Client(net)
|
||||
await client.connect()
|
||||
results += '\nConnected. Minting NFToken.'
|
||||
results += '\nConnected. Minting NFT.'
|
||||
operationalResultField.value = results
|
||||
|
||||
// This version adds the "Issuer" field.
|
||||
@@ -489,7 +489,7 @@ Update the form with fields and buttons to support the new functions.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFToken URL</td>
|
||||
<td align="right">NFT URL</td>
|
||||
<td><input type="text" id="standbyTokenUrlField"
|
||||
value = "ipfs://bafybeigdyrzt5sfp7udm7hu76uh7y26nf4dfuylqabf3oclgtqy55fbzdi" size="80"/>
|
||||
</td>
|
||||
@@ -499,11 +499,11 @@ Update the form with fields and buttons to support the new functions.
|
||||
<td><input type="text" id="standbyFlagsField" value="1" size="10"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFToken ID</td>
|
||||
<td align="right">NFT ID</td>
|
||||
<td><input type="text" id="standbyTokenIdField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFToken Offer Index</td>
|
||||
<td align="right">NFT Offer Index</td>
|
||||
<td><input type="text" id="standbyTokenOfferIndexField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -548,11 +548,11 @@ Update the form with fields and buttons to support the new functions.
|
||||
<br/>
|
||||
<button type="button" onClick="getBalances()">Get Balances</button>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="mintToken()">Mint NFToken</button>
|
||||
<button type="button" onClick="mintToken()">Mint NFT</button>
|
||||
<br/>
|
||||
<button type="button" onClick="getTokens()">Get NFTokens</button>
|
||||
<button type="button" onClick="getTokens()">Get NFTs</button>
|
||||
<br/>
|
||||
<button type="button" onClick="burnToken()">Burn NFToken</button>
|
||||
<button type="button" onClick="burnToken()">Burn NFT</button>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="setMinter('standby')">Set Minter</button>
|
||||
<br/>
|
||||
@@ -594,11 +594,11 @@ Update the form with fields and buttons to support the new functions.
|
||||
<br/>
|
||||
<button type="button" onClick="getBalances()">Get Balances</button>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="oPmintToken()">Mint NFToken</button>
|
||||
<button type="button" onClick="oPmintToken()">Mint NFT</button>
|
||||
<br/>
|
||||
<button type="button" onClick="oPgetTokens()">Get NFTokens</button>
|
||||
<button type="button" onClick="oPgetTokens()">Get NFTs</button>
|
||||
<br/>
|
||||
<button type="button" onClick="oPburnToken()">Burn NFToken</button>
|
||||
<button type="button" onClick="oPburnToken()">Burn NFT</button>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="oPsetMinter()">Set Minter</button>
|
||||
<br/>
|
||||
@@ -690,7 +690,7 @@ Update the form with fields and buttons to support the new functions.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFToken URL</td>
|
||||
<td align="right">NFT URL</td>
|
||||
<td><input type="text" id="operationalTokenUrlField"
|
||||
value = "ipfs://bafybeigdyrzt5sfp7udm7hu76uh7y26nf4dfuylqabf3oclgtqy55fbzdi" size="80"/>
|
||||
</td>
|
||||
@@ -700,11 +700,11 @@ Update the form with fields and buttons to support the new functions.
|
||||
<td><input type="text" id="operationalFlagsField" value="1" size="10"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFToken ID</td>
|
||||
<td align="right">NFT ID</td>
|
||||
<td><input type="text" id="operationalTokenIdField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFToken Offer Index</td>
|
||||
<td align="right">NFT Offer Index</td>
|
||||
<td><input type="text" id="operationalTokenOfferIndexField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
html: batch-minting.html
|
||||
parent: xrpl-quickstart.html
|
||||
parent: quickstart-javascript.html
|
||||
blurb: Broker a sale between a sell offer and a buy offer.
|
||||
labels:
|
||||
- Accounts
|
||||
@@ -9,11 +9,11 @@ labels:
|
||||
- XRP
|
||||
---
|
||||
|
||||
# Batch Mint NFTokens
|
||||
# Batch Mint NFTs
|
||||
|
||||
You can create an application that mints multiple NFTokens at one time. You can use a `for` loop to send one transaction after another.
|
||||
You can create an application that mints multiple NFTs at one time. You can use a `for` loop to send one transaction after another.
|
||||
|
||||
A best practice is to use `Tickets` to reserve the transaction sequence numbers. If you create an application that creates NFTokens without using tickets, if any transaction fails for any reason, the application stops with an error. If you use tickets, the application continues to send transactions, and you can look into the reason for the failure afterward.
|
||||
A best practice is to use `Tickets` to reserve the transaction sequence numbers. If you create an application that creates NFTs without using tickets, if any transaction fails for any reason, the application stops with an error. If you use tickets, the application continues to send transactions, and you can look into the reason for the failure afterward.
|
||||
|
||||
[](img/quickstart33-batch-mint.png)
|
||||
|
||||
@@ -32,21 +32,21 @@ You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-port
|
||||
|
||||
**Note:** Running this command throws an error in the JavaScript console because the `getAccountsFromSeeds` function in `ripplex1-send-xrp.js` looks for the operational seed field, which is not included in this form. You can ignore the error (or fix it in your own implementation).
|
||||
|
||||
## Batch Mint NFTokens
|
||||
## Batch Mint NFTs
|
||||
|
||||
This example lets you mint multiple NFTokens for a single unique item. The NFToken might represent "prints" of an original artwork, tickets to an event, or another limited set of unique items.
|
||||
This example lets you mint multiple NFTs for a single unique item. The NFT might represent "prints" of an original artwork, tickets to an event, or another limited set of unique items.
|
||||
|
||||
To batch mint a non-fungible token objects:
|
||||
|
||||
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 [NFTokenMint](nftokenmint.html) 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.
|
||||
3. Enter a **Token Count** of up to 200 NFTokens to create in one batch.
|
||||
4. Enter the **Transfer Fee**, a percentage of the proceeds that the original creator receives from future sales of the NFToken. This is a value of 0-50000 inclusive, allowing transfer fees between 0.000% and 50.000% in increments of 0.001%. If you do not set the **Flags** field to allow the NFToken to be transferrable, set this field to 0.
|
||||
1. Set the **Flags** field. For testing purposes, we recommend setting the value to _8_. This sets the _tsTransferable_ flag, meaning that the NFT object can be transferred to another account. Otherwise, the NFT object can only be transferred back to the issuing account. See [NFTokenMint](nftokenmint.html) for information about all of the available flags for minting NFTs.
|
||||
2. Enter the **Token URL**. This is a URI that points to the data or metadata associated with the NFT object. You can use the sample URI provided if you do not have one of your own.
|
||||
3. Enter a **Token Count** of up to 200 NFTs to create in one batch.
|
||||
4. Enter the **Transfer Fee**, a percentage of the proceeds that the original creator receives from future sales of the NFT. This is a value of 0-50000 inclusive, allowing transfer fees between 0.000% and 50.000% in increments of 0.001%. If you do not set the **Flags** field to allow the NFT to be transferrable, set this field to 0.
|
||||
5. Click **Batch Mint**.
|
||||
|
||||
## Get Batch NFTokens
|
||||
## Get Batch NFTs
|
||||
|
||||
Click **Get Batch NFTokens** to get the current list of NFTokens for your account.
|
||||
Click **Get Batch NFTs** to get the current list of NFTs for your account.
|
||||
|
||||
The difference between this function and the `getTokens()` function used earlier is that it allows for larger lists of tokens, and sends multiple requests if the tokens exceed the number of objects allowed in a single request.
|
||||
|
||||
@@ -104,16 +104,16 @@ Disconnect from the XRP Ledger.
|
||||
}
|
||||
```
|
||||
|
||||
## Get Batch NFTokens
|
||||
## Get Batch NFTs
|
||||
|
||||
This version of `getTokens()` allows for a larger set of NFTokens by watching for a `marker` at the end of each batch of NFTokens.
|
||||
This version of `getTokens()` allows for a larger set of NFTs by watching for a `marker` at the end of each batch of NFTs.
|
||||
|
||||
```javascript
|
||||
// *******************************************************
|
||||
// **************** Get Batch Tokens *********************
|
||||
// *******************************************************
|
||||
|
||||
async function getBatchNFTokens() {
|
||||
async function getBatchNFTs() {
|
||||
```
|
||||
|
||||
Connect to the XRP Ledger and get the account.
|
||||
@@ -125,7 +125,7 @@ Connect to the XRP Ledger and get the account.
|
||||
results = 'Connecting to ' + net + '...'
|
||||
standbyResultField.value = results
|
||||
await client.connect()
|
||||
results += '\nConnected. Getting NFTokens...'
|
||||
results += '\nConnected. Getting NFTs...'
|
||||
standbyResultField.value = results
|
||||
```
|
||||
|
||||
@@ -141,7 +141,7 @@ Request the `account_nfts`. Set the `limit` to 400, the maximum amount, to retri
|
||||
results += JSON.stringify(nfts,null,2)
|
||||
```
|
||||
|
||||
If the list of `NFTokens` exceeds your limit, the result includes a `marker` field that you can use as a parameter for the next `account_nfts` request. The `marker` indicates where the next batch of records starts. While the `marker` field is present, continue to request another batch of NFToken records.
|
||||
If the list of `NFTs` exceeds your limit, the result includes a `marker` field that you can use as a parameter for the next `account_nfts` request. The `marker` indicates where the next batch of records starts. While the `marker` field is present, continue to request another batch of NFT records.
|
||||
|
||||
```javascript
|
||||
while (nfts.result.marker)
|
||||
@@ -171,7 +171,7 @@ Disconnect from the XRP Ledger.
|
||||
|
||||
## Batch Mint
|
||||
|
||||
This script mints multiple copies of the same NFToken.
|
||||
This script mints multiple copies of the same NFT.
|
||||
|
||||
```javascript
|
||||
// *******************************************************
|
||||
@@ -210,10 +210,10 @@ Get the account information, particularly the `Sequence` number.
|
||||
|
||||
Next, create ticket numbers for the batch. Without tickets, if one transaction fails, all others in the batch fail. With tickets, there can be failures, but the rest can still succeed, and you can investigate any problems afterward.
|
||||
|
||||
Parse the NFToken Count field value to an integer.
|
||||
Parse the NFT Count field value to an integer.
|
||||
|
||||
```javascript
|
||||
const nftokenCount = parseInt(standbyNFTokenCountField.value)
|
||||
const nftCount = parseInt(standbyNFTCountField.value)
|
||||
```
|
||||
|
||||
Create the `TicketCreate` transaction hash, automatically filling default values. Provide the `Sequence` number to indicate a starting point for the XRP Ledger.
|
||||
@@ -222,7 +222,7 @@ Create the `TicketCreate` transaction hash, automatically filling default values
|
||||
const ticketTransaction = await client.autofill({
|
||||
"TransactionType": "TicketCreate",
|
||||
"Account": standby_wallet.address,
|
||||
"TicketCount": nftokenCount,
|
||||
"TicketCount": nftCount,
|
||||
"Sequence": my_sequence
|
||||
})
|
||||
```
|
||||
@@ -249,7 +249,7 @@ Populate the `tickets` array variable.
|
||||
```javascript
|
||||
let tickets = []
|
||||
|
||||
for (let i=0; i < nftokenCount; i++) {
|
||||
for (let i=0; i < nftCount; i++) {
|
||||
tickets[i] = response.result.account_objects[i].TicketSequence
|
||||
}
|
||||
```
|
||||
@@ -257,14 +257,14 @@ Populate the `tickets` array variable.
|
||||
Report the function progress.
|
||||
|
||||
```javascript
|
||||
results += "Tickets generated, minting NFTokens.\n\n"
|
||||
results += "Tickets generated, minting NFTs.\n\n"
|
||||
standbyResultField.value = results
|
||||
```
|
||||
|
||||
Use a `for` loop to create the NFTokens one at a time, up to the number you specified.
|
||||
Use a `for` loop to create the NFTs one at a time, up to the number you specified.
|
||||
|
||||
```javascript
|
||||
for (let i=0; i < nftokenCount; i++) {
|
||||
for (let i=0; i < nftCount; i++) {
|
||||
const transactionBlob = {
|
||||
"TransactionType": "NFTokenMint",
|
||||
"Account": standby_wallet.classicAddress,
|
||||
@@ -290,7 +290,7 @@ Submit the signed transaction hash.
|
||||
}
|
||||
```
|
||||
|
||||
Use the same logic as `getBatchNFTokens`, above, to get the list of current NFTokens.
|
||||
Use the same logic as `getBatchNFTs`, above, to get the list of current NFTs.
|
||||
|
||||
```javascript
|
||||
results += "\n\nNFTs:\n"
|
||||
@@ -317,7 +317,7 @@ Report the results.
|
||||
|
||||
```javascript
|
||||
results += '\n\nTransaction result: '+ tx.result.meta.TransactionResult
|
||||
results += '\n\nnftokens: ' + JSON.stringify(nfts, null, 2)
|
||||
results += '\n\nnfts: ' + JSON.stringify(nfts, null, 2)
|
||||
standbyBalanceField.value = (await client.getXrpBalance(standby_wallet.address))
|
||||
standbyResultField.value = results
|
||||
```
|
||||
@@ -447,7 +447,7 @@ For this form:
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFToken URL</td>
|
||||
<td align="right">NFT URL</td>
|
||||
<td><input type="text" id="standbyTokenUrlField"
|
||||
value = "ipfs://bafybeigdyrzt5sfp7udm7hu76uh7y26nf4dfuylqabf3oclgtqy55fbzdi" size="80"/>
|
||||
</td>
|
||||
@@ -457,15 +457,15 @@ For this form:
|
||||
<td><input type="text" id="standbyFlagsField" value="8" size="10"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFToken ID</td>
|
||||
<td align="right">NFT ID</td>
|
||||
<td><input type="text" id="standbyTokenIdField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
NFToken Count
|
||||
NFT Count
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="standbyNFTokenCountField" size="40"></input>
|
||||
<input type="text" id="standbyNFTCountField" size="40"></input>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -480,11 +480,11 @@ For this form:
|
||||
<td align="left" valign="top">
|
||||
<button type="button" onClick="batchMint()">Batch Mint</button>
|
||||
<br/>
|
||||
<button type="button" onClick="getBatchNFTokens()">Get Batch NFTokens</button>
|
||||
<button type="button" onClick="getBatchNFTs()">Get Batch NFTs</button>
|
||||
<br/>
|
||||
<p align="left">
|
||||
|
||||
<!-- Note the increased maxlength to hold the most possible NFToken info. -->
|
||||
<!-- Note the increased maxlength to hold the most possible NFT info. -->
|
||||
|
||||
<textarea id="standbyResultField" cols="80" rows="20" maxlength="524288"></textarea>
|
||||
</p>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
html: broker-sale.html
|
||||
parent: xrpl-quickstart.html
|
||||
parent: quickstart-javascript.html
|
||||
blurb: Broker a sale between a sell offer and a buy offer.
|
||||
labels:
|
||||
- Accounts
|
||||
@@ -9,9 +9,9 @@ labels:
|
||||
- XRP
|
||||
---
|
||||
|
||||
# Broker a NFToken Sale
|
||||
# Broker an NFT Sale
|
||||
|
||||
Earlier examples showed how to make buy and sell offers directly between two accounts. Another option is to use a third account as a broker for the sale. The broker acts on behalf of the NFToken owner. The seller creates an offer with the broker account as its destination. The broker gathers and evaluates buy offers and chooses which one to accept, adding an agreed-upon fee for arranging the sale. When the broker account accepts a sell offer with a buy offer, the funds and ownership of the NFToken are transferred simultaneously, completing the deal. This allows an account to act as a marketplace or personal agent for NFToken creators and traders.
|
||||
Earlier examples showed how to make buy and sell offers directly between two accounts. Another option is to use a third account as a broker for the sale. The broker acts on behalf of the NFT owner. The seller creates an offer with the broker account as its destination. The broker gathers and evaluates buy offers and chooses which one to accept, adding an agreed-upon fee for arranging the sale. When the broker account accepts a sell offer with a buy offer, the funds and ownership of the NFT are transferred simultaneously, completing the deal. This allows an account to act as a marketplace or personal agent for NFT creators and traders.
|
||||
|
||||
# Usage
|
||||
|
||||
@@ -42,10 +42,10 @@ You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-port
|
||||
|
||||
## Prepare a Brokered Transaction
|
||||
|
||||
1. Use the Standby account to create a NFToken Sell Offer with the Broker account as the destination.
|
||||
1. Use the Standby account to create an NFT Sell Offer with the Broker account as the destination.
|
||||
1. Enter the **Amount** of the sell offer in drops (millionths of an XRP).
|
||||
2. Set the **Flags** field to _1_.
|
||||
3. Enter the **NFToken ID** of the NFToken you want to sell.
|
||||
3. Enter the **NFT ID** of the NFT you want to sell.
|
||||
4. Optionally, enter a number of days until **Expiration**.
|
||||
5. Enter the Broker account number as the **Destination**.
|
||||
6. Click **Create Sell Offer**.
|
||||
@@ -53,9 +53,9 @@ You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-port
|
||||
|
||||
[](img/quickstart23.png)
|
||||
|
||||
2. Use the Operational account to create a NFToken Buy Offer.
|
||||
2. Use the Operational account to create an NFT Buy Offer.
|
||||
1. Enter the **Amount** of your offer.
|
||||
2. Enter the **NFToken ID**.
|
||||
2. Enter the **NFT ID**.
|
||||
3. Enter the owner’s account string in the **Owner** field.
|
||||
4. Optionally enter the number of days until **Expiration**.
|
||||
5. Click **Create Buy Offer**.
|
||||
@@ -64,15 +64,15 @@ You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-port
|
||||
|
||||
## Get Offers
|
||||
|
||||
1. Enter the **NFToken ID**.
|
||||
1. Enter the **NFT ID**.
|
||||
2. Click **Get Offers**.
|
||||
|
||||
[](img/quickstart25.png)
|
||||
|
||||
## Broker the Sale
|
||||
|
||||
1. Copy the _nft_offer_index_ of the sell offer and paste it in the **Sell NFToken Offer Index** field.
|
||||
2. Copy the _nft_offer_index_ of the buy offer and paste it in the **Buy NFToken Offer Index** field.
|
||||
1. Copy the _nft_offer_index_ of the sell offer and paste it in the **Sell NFT Offer Index** field.
|
||||
2. Copy the _nft_offer_index_ of the buy offer and paste it in the **Buy NFT Offer Index** field.
|
||||
3. Enter a **Broker Fee**, in drops.
|
||||
4. Click **Broker Sale**.
|
||||
|
||||
@@ -83,7 +83,7 @@ You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-port
|
||||
|
||||
After accepting a buy offer, a best practice for the broker is to cancel all other offers, if the broker has permissions to do so. Use **Get Offers** to get the full list of buy offers. To cancel an offer:
|
||||
|
||||
1. Enter the _nft_offer_index_ of the buy offer you want to cancel in the **Buy NFToken Offer Index** field.
|
||||
1. Enter the _nft_offer_index_ of the buy offer you want to cancel in the **Buy NFT Offer Index** field.
|
||||
2. Click **Cancel Offer**.
|
||||
|
||||
[](img/quickstart27.png)
|
||||
@@ -724,15 +724,15 @@ Revise the HTML form to add a new Broker section at the top.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFToken ID</td>
|
||||
<td align="right">NFT ID</td>
|
||||
<td><input type="text" id="brokerTokenIdField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">Sell NFToken Offer Index</td>
|
||||
<td align="right">Sell NFT Offer Index</td>
|
||||
<td><input type="text" id="brokerTokenSellOfferIndexField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">Buy NFToken Offer Index</td>
|
||||
<td align="right">Buy NFT Offer Index</td>
|
||||
<td><input type="text" id="brokerTokenBuyOfferIndexField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -824,7 +824,7 @@ Revise the HTML form to add a new Broker section at the top.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFToken URL</td>
|
||||
<td align="right">NFT URL</td>
|
||||
<td><input type="text" id="standbyTokenUrlField"
|
||||
value = "ipfs://bafybeigdyrzt5sfp7udm7hu76uh7y26nf4dfuylqabf3oclgtqy55fbzdi" size="80"/>
|
||||
</td>
|
||||
@@ -834,11 +834,11 @@ Revise the HTML form to add a new Broker section at the top.
|
||||
<td><input type="text" id="standbyFlagsField" value="1" size="10"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFToken ID</td>
|
||||
<td align="right">NFT ID</td>
|
||||
<td><input type="text" id="standbyTokenIdField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFToken Offer Index</td>
|
||||
<td align="right">NFT Offer Index</td>
|
||||
<td><input type="text" id="standbyTokenOfferIndexField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -875,11 +875,11 @@ Revise the HTML form to add a new Broker section at the top.
|
||||
<br/>
|
||||
<button type="button" onClick="getBalances()">Get Balances</button>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="mintToken()">Mint NFToken</button>
|
||||
<button type="button" onClick="mintToken()">Mint NFT</button>
|
||||
<br/>
|
||||
<button type="button" onClick="getTokens()">Get NFTokens</button>
|
||||
<button type="button" onClick="getTokens()">Get NFTs</button>
|
||||
<br/>
|
||||
<button type="button" onClick="burnToken()">Burn NFToken</button>
|
||||
<button type="button" onClick="burnToken()">Burn NFT</button>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="createSellOffer()">Create Sell Offer</button>
|
||||
<br/>
|
||||
@@ -917,11 +917,11 @@ Revise the HTML form to add a new Broker section at the top.
|
||||
<br/>
|
||||
<button type="button" onClick="getBalances()">Get Balances</button>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="oPmintToken()">Mint NFToken</button>
|
||||
<button type="button" onClick="oPmintToken()">Mint NFT</button>
|
||||
<br/>
|
||||
<button type="button" onClick="oPgetTokens()">Get NFTokens</button>
|
||||
<button type="button" onClick="oPgetTokens()">Get NFTs</button>
|
||||
<br/>
|
||||
<button type="button" onClick="oPburnToken()">Burn NFToken</button>
|
||||
<button type="button" onClick="oPburnToken()">Burn NFT</button>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="oPcreateSellOffer()">Create Sell Offer</button>
|
||||
<br/>
|
||||
@@ -1009,7 +1009,7 @@ Revise the HTML form to add a new Broker section at the top.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFToken URL</td>
|
||||
<td align="right">NFT URL</td>
|
||||
<td><input type="text" id="operationalTokenUrlField"
|
||||
value = "ipfs://bafybeigdyrzt5sfp7udm7hu76uh7y26nf4dfuylqabf3oclgtqy55fbzdi" size="80"/>
|
||||
</td>
|
||||
@@ -1019,11 +1019,11 @@ Revise the HTML form to add a new Broker section at the top.
|
||||
<td><input type="text" id="operationalFlagsField" value="1" size="10"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFToken ID</td>
|
||||
<td align="right">NFT ID</td>
|
||||
<td><input type="text" id="operationalTokenIdField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFToken Offer Index</td>
|
||||
<td align="right">NFT Offer Index</td>
|
||||
<td><input type="text" id="operationalTokenOfferIndexField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
html: create-accounts-send-xrp.html
|
||||
parent: xrpl-quickstart.html
|
||||
parent: quickstart-javascript.html
|
||||
blurb: Quickstart 1, create two accounts and transfer XRP between them.
|
||||
labels:
|
||||
- Accounts
|
||||
@@ -55,7 +55,7 @@ To transfer XRP from the Standby account to the Operational account:
|
||||
To transfer XRP from the Operational account to the Standby account:
|
||||
|
||||
1. On the Operational (right) side of the form, enter the **Amount** of XRP to send.
|
||||
2. Copy and paste the **Standby Account** field to the Standby **Destination** field.
|
||||
2. Copy and paste the **Standby Account** field to the Operational **Destination** field.
|
||||
3. Click **<Send XRP** to transfer XRP from the Operational account to the Standby account.
|
||||
|
||||
[](img/quickstart4.png)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
html: create-trustline-send-currency.html
|
||||
parent: xrpl-quickstart.html
|
||||
parent: quickstart-javascript.html
|
||||
blurb: Quickstart step 2, create trust lines and send currency.
|
||||
labels:
|
||||
- Cross-Currency
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
---
|
||||
html: mint-and-burn-nftokens.html
|
||||
parent: xrpl-quickstart.html
|
||||
blurb: Quickstart step 3, mint and burn NFTokens.
|
||||
html: mint-and-burn-nfts.html
|
||||
parent: quickstart-javascript.html
|
||||
blurb: Quickstart step 3, mint and burn NFTs.
|
||||
labels:
|
||||
- Quickstart
|
||||
- Tokens
|
||||
- Non-fungible tokens, NFTs
|
||||
---
|
||||
|
||||
# 3. Mint and Burn NFTokens
|
||||
# 3. Mint and Burn NFTs
|
||||
|
||||
This example shows how to:
|
||||
|
||||
1. Mint new Non-fungible Tokens (NFTokens).
|
||||
2. Get a list of existing NFTokens.
|
||||
3. Delete (Burn) a NFToken.
|
||||
1. Mint new Non-fungible Tokens (NFTs).
|
||||
2. Get a list of existing NFTs.
|
||||
3. Delete (Burn) an NFT.
|
||||
|
||||
[](img/quickstart8.png)
|
||||
[](img/quickstart8.png)
|
||||
|
||||
# Usage
|
||||
|
||||
@@ -35,34 +35,34 @@ You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-port
|
||||
|
||||
[](img/quickstart9.png)
|
||||
|
||||
## Mint a NFToken
|
||||
## Mint an NFT
|
||||
|
||||
To mint a non-fungible token object:
|
||||
|
||||
1. Set the **Flags** field. For testing purposes, we recommend setting the value to _8_. This sets the _tsTransferable_ flag, meaning that the 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.
|
||||
3. Enter the **Transfer Fee**, a percentage of the proceeds from future sales of the NFToken that will be returned to the original creator. This is a value of 0-50000 inclusive, allowing transfer rates between 0.000% and 50.000% in increments of 0.001%. If you do not set the **Flags** field to allow the NFToken to be transferrable, set this field to 0.
|
||||
4. Click **Mint NFToken**.
|
||||
1. Set the **Flags** field. For testing purposes, we recommend setting the value to _8_. This sets the _tsTransferable_ flag, meaning that the NFT object can be transferred to another account. Otherwise, the NFT object can only be transferred back to the issuing account. 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 NFTs.
|
||||
2. Enter the **Token URL**. This is a URI that points to the data or metadata associated with the NFT object. You can use the sample URI provided if you do not have one of your own.
|
||||
3. Enter the **Transfer Fee**, a percentage of the proceeds from future sales of the NFT that will be returned to the original creator. This is a value of 0-50000 inclusive, allowing transfer rates between 0.000% and 50.000% in increments of 0.001%. If you do not set the **Flags** field to allow the NFT to be transferrable, set this field to 0.
|
||||
4. Click **Mint NFT**.
|
||||
|
||||
[](img/quickstart10.png)
|
||||
[](img/quickstart10.png)
|
||||
|
||||
|
||||
## Get Tokens
|
||||
|
||||
Click **Get NFTokens** to get a list of NFTokens owned by the account.
|
||||
Click **Get NFTs** to get a list of NFTs owned by the account.
|
||||
|
||||
[](img/quickstart11.png)
|
||||
[](img/quickstart11.png)
|
||||
|
||||
## Burn a Token
|
||||
|
||||
The current owner of a NFToken can always destroy (or _burn_) a NFToken object.
|
||||
The current owner of an NFT can always destroy (or _burn_) an NFT object.
|
||||
|
||||
To permanently destroy a NFToken:
|
||||
To permanently destroy an NFT:
|
||||
|
||||
1. Enter the **Token ID**.
|
||||
2. Click **Burn NFToken**.
|
||||
2. Click **Burn NFT**.
|
||||
|
||||
[](img/quickstart12.png)
|
||||
[](img/quickstart12.png)
|
||||
|
||||
# Code Walkthrough
|
||||
|
||||
@@ -90,7 +90,7 @@ Connect to the ledger and get the account wallets.
|
||||
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
|
||||
const client = new xrpl.Client(net)
|
||||
await client.connect()
|
||||
results += '\nConnected. Minting NFToken.'
|
||||
results += '\nConnected. Minting NFT.'
|
||||
standbyResultField.value = results
|
||||
```
|
||||
|
||||
@@ -109,7 +109,7 @@ Note that the URI field expects a hexadecimal value rather than the literal URI
|
||||
"URI": xrpl.convertStringToHex(standbyTokenUrlField.value),
|
||||
```
|
||||
|
||||
If you want the NFToken to be transferable to third parties, set the **Flags** field to _8_.
|
||||
If you want the NFT to be transferable to third parties, set the **Flags** field to _8_.
|
||||
|
||||
|
||||
```javascript
|
||||
@@ -182,7 +182,7 @@ Connect to the ledger and get the account.
|
||||
results = 'Connecting to ' + net + '...'
|
||||
standbyResultField.value = results
|
||||
await client.connect()
|
||||
results += '\nConnected. Getting NFTokens...'
|
||||
results += '\nConnected. Getting NFTs...'
|
||||
standbyResultField.value = results
|
||||
```
|
||||
|
||||
@@ -228,7 +228,7 @@ Connect to the ledger and get the account wallets.
|
||||
results = 'Connecting to ' + net + '...'
|
||||
standbyResultField.value = results
|
||||
await client.connect()
|
||||
results += '\nConnected. Burning NFToken...'
|
||||
results += '\nConnected. Burning NFT...'
|
||||
standbyResultField.value = results
|
||||
```
|
||||
|
||||
@@ -248,7 +248,7 @@ Submit the transaction and wait for the results.
|
||||
const tx = await client.submitAndWait(transactionBlob,{wallet: standby_wallet})
|
||||
```
|
||||
|
||||
Request a list of NFTokens owned by the client.
|
||||
Request a list of NFTs owned by the client.
|
||||
|
||||
```javascript
|
||||
const nfts = await client.request({
|
||||
@@ -289,7 +289,7 @@ async function oPmintToken() {
|
||||
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
|
||||
const client = new xrpl.Client(net)
|
||||
await client.connect()
|
||||
results += '\nConnected. Minting NFToken.'
|
||||
results += '\nConnected. Minting NFT.'
|
||||
operationalResultField.value = results
|
||||
|
||||
// Note that you must convert the token URL to a hexadecimal
|
||||
@@ -330,7 +330,7 @@ async function oPgetTokens() {
|
||||
results = 'Connecting to ' + getNet() + '...'
|
||||
operationalResultField.value = results
|
||||
await client.connect()
|
||||
results += '\nConnected. Getting NFTokens...'
|
||||
results += '\nConnected. Getting NFTs...'
|
||||
operationalResultField.value = results
|
||||
const nfts = await client.request({
|
||||
method: "account_nfts",
|
||||
@@ -352,7 +352,7 @@ async function oPburnToken() {
|
||||
results = 'Connecting to ' + getNet() + '...'
|
||||
operationalResultField.value = results
|
||||
await client.connect()
|
||||
results += '\nConnected. Burning NFToken...'
|
||||
results += '\nConnected. Burning NFT...'
|
||||
operationalResultField.value = results
|
||||
|
||||
// ------------------------------------------------------- Prepare transaction
|
||||
@@ -515,7 +515,7 @@ async function oPburnToken() {
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFToken URL</td>
|
||||
<td align="right">NFT URL</td>
|
||||
<td><input type="text" id="standbyTokenUrlField"
|
||||
value = "ipfs://bafybeigdyrzt5sfp7udm7hu76uh7y26nf4dfuylqabf3oclgtqy55fbzdi" size="80"/>
|
||||
</td>
|
||||
@@ -525,7 +525,7 @@ async function oPburnToken() {
|
||||
<td><input type="text" id="standbyFlagsField" value="1" size="10"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFToken ID</td>
|
||||
<td align="right">NFT ID</td>
|
||||
<td><input type="text" id="standbyTokenIdField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -550,11 +550,11 @@ async function oPburnToken() {
|
||||
<br/>
|
||||
<button type="button" onClick="getBalances()">Get Balances</button>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="mintToken()">Mint NFToken</button>
|
||||
<button type="button" onClick="mintToken()">Mint NFT</button>
|
||||
<br/>
|
||||
<button type="button" onClick="getTokens()">Get NFTokens</button>
|
||||
<button type="button" onClick="getTokens()">Get NFTs</button>
|
||||
<br/>
|
||||
<button type="button" onClick="burnToken()">Burn NFToken</button>
|
||||
<button type="button" onClick="burnToken()">Burn NFT</button>
|
||||
</td>
|
||||
</tr>
|
||||
</td>
|
||||
@@ -580,11 +580,11 @@ async function oPburnToken() {
|
||||
<br/>
|
||||
<button type="button" onClick="getBalances()">Get Balances</button>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="oPmintToken()">Mint NFToken</button>
|
||||
<button type="button" onClick="oPmintToken()">Mint NFT</button>
|
||||
<br/>
|
||||
<button type="button" onClick="oPgetTokens()">Get NFTokens</button>
|
||||
<button type="button" onClick="oPgetTokens()">Get NFTs</button>
|
||||
<br/>
|
||||
<button type="button" onClick="oPburnToken()">Burn NFToken</button>
|
||||
<button type="button" onClick="oPburnToken()">Burn NFT</button>
|
||||
<td valign="top" align="right">
|
||||
<button type="button" onClick="getAccount('operational')">Get New Operational Account</button>
|
||||
<table>
|
||||
@@ -668,7 +668,7 @@ async function oPburnToken() {
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFToken URL</td>
|
||||
<td align="right">NFT URL</td>
|
||||
<td><input type="text" id="operationalTokenUrlField"
|
||||
value = "ipfs://bafybeigdyrzt5sfp7udm7hu76uh7y26nf4dfuylqabf3oclgtqy55fbzdi" size="80"/>
|
||||
</td>
|
||||
@@ -678,7 +678,7 @@ async function oPburnToken() {
|
||||
<td><input type="text" id="operationalFlagsField" value="1" size="10"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFToken ID</td>
|
||||
<td align="right">NFT ID</td>
|
||||
<td><input type="text" id="operationalTokenIdField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
205
content/tutorials/quickstart/py-authorize-minter.md
Normal file
@@ -0,0 +1,205 @@
|
||||
---
|
||||
html: py-authorize-minter.html
|
||||
parent: quickstart-python.html
|
||||
blurb: Authorize another account to mint NFTs for you.
|
||||
labels:
|
||||
- Accounts
|
||||
- Quickstart
|
||||
- XRP
|
||||
- NFTs, NFTokens
|
||||
---
|
||||
|
||||
# Assign an Authorized Minter (Python)
|
||||
|
||||
You can assign another account permission to mint NFTs for you.
|
||||
|
||||
This example shows how to:
|
||||
|
||||
1. Authorize an account to create NFTs for your account.
|
||||
2. Mint an NFT for another account, when authorized.
|
||||
|
||||
[](img/quickstart-py30.png)
|
||||
|
||||
# Usage
|
||||
|
||||
You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/quickstart/js/quickstart.zip){.github-code-download} archive to try the sample in your own browser.
|
||||
|
||||
## Get Accounts
|
||||
|
||||
1. Open and run `py-authorize-minter.md`.
|
||||
2. Get accounts.
|
||||
1. If you have existing test account seeds:
|
||||
1. Paste a seed in the **Standby Seed** field.
|
||||
2. Click **Get Standby Account**.
|
||||
3. Click **Get Standby Account Info**.
|
||||
4. Paste a seed in the **Operational Seed** field.
|
||||
5. Click **Get Operational Account**.
|
||||
6. Click **Get Operational Account** info.
|
||||
2. If you do not have existing test accounts:
|
||||
1. Click **Get Standby Account**.
|
||||
2. Click **Get Standby Account Info**.
|
||||
3. Click **Get Operational Account**.
|
||||
4. Click **Get Operational Account Info**.
|
||||
|
||||
## Authorize an Account to Create NFTs
|
||||
|
||||
To authorize another account to create NFTs for your account (for example, allow the operational account to mint NFTs for the standby account):
|
||||
|
||||
1. Copy the **Operational Account** value.
|
||||
2. Paste the **Operational Account** value in the standby **Authorized Minter** field.
|
||||
3. Click **Set Minter**.
|
||||
|
||||
[](img/quickstart-py31.png)
|
||||
|
||||
## Mint an NFT for Another Account
|
||||
|
||||
This example uses the Operational account, which was authorized in the previous step, to mint a token on behalf of the Standby account.
|
||||
|
||||
To mint a non-fungible token for another account:
|
||||
|
||||
1. Set the **Flags** field. For testing purposes, we recommend setting the value to _8_.
|
||||
2. Enter the **NFT URI**. This is a URI that points to the data or metadata associated with the NFT. You can use the sample URI provided if you do not have one of your own.
|
||||
3. Enter the **Transfer Fee**, a percentage of the proceeds that the original creator receives from future sales of the NFT. This is a value of 0-50000 inclusive, allowing transfer rates between 0.000% and 50.000% in increments of 0.001%. If you do not set the **Flags** field to allow the NFT to be transferrable, set this field to 0.
|
||||
4. Enter a **Taxon** for the NFT. If you don't have a use for the field, set it to _0_.
|
||||
4. Copy the **Standby Account** value.
|
||||
5. Paste the **Standby Account** value in the Operational account **Issuer** field.
|
||||
6. Click the Operational account **Mint Other** button.
|
||||
|
||||
[](img/quickstart-py32.png)
|
||||
|
||||
Once the item is minted, the authorized minter can sell the NFT normally. The proceeds go to the authorized minter, less the transfer fee. The minter and the issuer can settle up on a division of the price separately.
|
||||
|
||||
## Create a Sell Offer
|
||||
|
||||
To create a NFT sell offer:
|
||||
|
||||
1. On the Operational account side, enter the **Amount** of the sell offer in drops (millionths of an XRP), for example 100000000 (100 XRP).
|
||||
2. Set the **Flags** field to _1_.
|
||||
3. Enter the **NFT ID** of the minted NFT you want to sell.
|
||||
4. Optionally, enter a number of seconds until **Expiration**.
|
||||
5. Click **Create Sell Offer**.
|
||||
|
||||
The important piece of information in the response is the NFT Offer Index, labeled as `nft_offer_index`, which is used to accept the sell offer.
|
||||
|
||||
[](img/quickstart-py33.png)
|
||||
|
||||
## Accept Sell Offer
|
||||
|
||||
Once a sell offer is available, you can create a new account to accept the offer and buy the NFT.
|
||||
|
||||
To accept an available sell offer:
|
||||
|
||||
1. Clear the **Standby Seed** field.
|
||||
2. Click **Get Standby Account**.
|
||||
3. Click **Get Standby Account Info**.
|
||||
4. Enter the **NFT Offer Index** (labeled as `nft_offer_index` in the NFT offer results. This is different from the `nft_id`).
|
||||
5. Click **Accept Sell Offer**.
|
||||
|
||||
[](img/quickstart-py34.png)
|
||||
|
||||
The Buyer account was debited the 100 XRP price plus 10 drops as the transaction cost. The Seller (Authorized Minter) account is credited 90 XRP. the Issuer and the Seller can divide the proceeds per their agreement in a separate transaction. The original Standby account receives a transfer fee of 10 XRP.
|
||||
|
||||
[](img/quickstart-py35.png)
|
||||
|
||||
# Code Walkthrough
|
||||
|
||||
You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/quickstart/js/quickstart.zip){.github-code-download} archive to try each of the samples.
|
||||
|
||||
## mod6.py
|
||||
|
||||
`mod6.py` contains the new business logic for this example, the `set_minter` and `mint_other` methods.
|
||||
|
||||
Import dependencies and define the `testnet_url` global variable.
|
||||
|
||||
```python
|
||||
import xrpl
|
||||
import json
|
||||
from xrpl.clients import JsonRpcClient
|
||||
from xrpl.wallet import Wallet
|
||||
testnet_url = "https://s.altnet.rippletest.net:51234"
|
||||
```
|
||||
|
||||
### Set Minter
|
||||
|
||||
This function sets the authorized minter for an account. Each account can have 0 or 1 authorized minter that can mint NFTs in its stead.
|
||||
|
||||
Get the wallet of the account granting permission and instantiate a client.
|
||||
|
||||
```python
|
||||
def set_minter(seed, minter):
|
||||
"""set_minter"""
|
||||
granter_wallet=Wallet(seed, sequence = 16237283)
|
||||
client=JsonRpcClient(testnet_url)
|
||||
```
|
||||
|
||||
Define the AccountSet transaction that grants permission to another account to mint tokens on behalf of the granter account.
|
||||
|
||||
```python
|
||||
set_minter_tx=xrpl.models.transactions.AccountSet(
|
||||
account=granter_wallet.classic_address,
|
||||
nftoken_minter=minter,
|
||||
set_flag=xrpl.models.transactions.AccountSetFlag.ASF_AUTHORIZED_NFTOKEN_MINTER
|
||||
)
|
||||
```
|
||||
|
||||
Sign the transaction
|
||||
|
||||
```python
|
||||
signed_tx=xrpl.transaction.safe_sign_and_autofill_transaction(
|
||||
set_minter_tx, granter_wallet, client)
|
||||
```
|
||||
|
||||
Submit the transaction and return the results.
|
||||
|
||||
```python
|
||||
reply=""
|
||||
try:
|
||||
response=xrpl.transaction.send_reliable_submission(signed_tx,client)
|
||||
reply=response.result
|
||||
except xrpl.transaction.XRPLReliableSubmissionException as e:
|
||||
reply=f"Submit failed: {e}"
|
||||
return reply
|
||||
```
|
||||
|
||||
### mint_other
|
||||
|
||||
Get the minter wallet and instantiate a client connection to the XRP ledger.
|
||||
|
||||
``` python
|
||||
def mint_other(seed, uri, flags, transfer_fee, taxon, issuer):
|
||||
"""mint_other"""
|
||||
minter_wallet=Wallet(seed, sequence=16237283)
|
||||
client=JsonRpcClient(testnet_url)
|
||||
```
|
||||
|
||||
Define the `NFTokenMint` transaction. The new parameter in this method is the _issuer_ field, identifying the account on whose behalf the token is being minted.
|
||||
|
||||
```python
|
||||
mint_other_tx=xrpl.models.transactions.NFTokenMint(
|
||||
account=minter_wallet.classic_address,
|
||||
uri=xrpl.utils.str_to_hex(uri),
|
||||
flags=int(flags),
|
||||
transfer_fee=int(transfer_fee),
|
||||
nftoken_taxon=int(taxon),
|
||||
issuer=issuer
|
||||
)
|
||||
```
|
||||
|
||||
Sign and fill the transaction.
|
||||
|
||||
```python
|
||||
signed_tx=xrpl.transaction.safe_sign_and_autofill_transaction(
|
||||
mint_other_tx, minter_wallet, client)
|
||||
```
|
||||
|
||||
Submit the transaction and report the results.
|
||||
|
||||
```python
|
||||
reply=""
|
||||
try:
|
||||
response=xrpl.transaction.send_reliable_submission(signed_tx,client)
|
||||
reply=response.result
|
||||
except xrpl.transaction.XRPLReliableSubmissionException as e:
|
||||
reply=f"Submit failed: {e}"
|
||||
return reply
|
||||
```
|
||||
885
content/tutorials/quickstart/py-broker-sale.md
Normal file
@@ -0,0 +1,885 @@
|
||||
---
|
||||
html: py-broker-sale.html
|
||||
parent: quickstart-python.html
|
||||
blurb: Broker a sale between a sell offer and a buy offer.
|
||||
labels:
|
||||
- Accounts
|
||||
- Quickstart
|
||||
- Broker
|
||||
- XRP
|
||||
---
|
||||
|
||||
# Broker an NFT Sale (Python)
|
||||
|
||||
Earlier examples showed how to make buy and sell offers directly between two accounts. Another option is to use a third account as a broker for the sale. The broker acts on behalf of the NFT owner. The seller creates an offer with the broker account as its destination. The broker gathers and evaluates buy offers and chooses which one to accept, adding an agreed-upon fee for arranging the sale. When the broker account accepts a sell offer with a buy offer, the funds and ownership of the NFT are transferred simultaneously, completing the deal. This allows an account to act as a marketplace or personal agent for NFT creators and traders.
|
||||
|
||||
# Usage
|
||||
|
||||
This example shows how to:
|
||||
|
||||
1. Create a brokered sell offer.
|
||||
2. Get a list of offers for the brokered item.
|
||||
3. Broker a sale between two different accounts.
|
||||
|
||||
[](img/quickstart-py23.png)
|
||||
|
||||
You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/quickstart/js/quickstart.zip){.github-code-download} archive to try each of the samples in your own browser.
|
||||
|
||||
## Get Accounts
|
||||
|
||||
1. Open and run `broker-nfts.py`.
|
||||
2. Get test accounts.
|
||||
1. If you have existing account seeds:
|
||||
1. Paste account seed in the **Broker Seed** field.
|
||||
2. Click **Get Broker Account**.
|
||||
3. Paste account seed in the **Standby Seed** field.
|
||||
4. Click **Get Standby Account**.
|
||||
5. Paste account seed in the **Operational Seed** field.
|
||||
6. Click **Get Operational Account**.
|
||||
2. If you do not have account seeds:
|
||||
1. Click **Get Broker Account**.
|
||||
2. Click **Get Standby Account**.
|
||||
2. Click **Get Operational Account**.
|
||||
3. Click **Get Broker Account Info**.
|
||||
4. Click **Get Standby Account Info**.
|
||||
5. Click **Get Operational Account Info**.
|
||||
|
||||
[](img/quickstart-py24.png)
|
||||
|
||||
## Prepare a Brokered Transaction
|
||||
|
||||
1. Use the Standby account to create an NFT Sell Offer with the Broker account as the destination.
|
||||
1. Enter the **Amount** of the sell offer in drops (millionths of an XRP).
|
||||
2. Enter the **NFT ID** of the NFT you want to sell.
|
||||
3. Optionally, enter a number of seconds until **Expiration**.
|
||||
4. Enter the Broker account number as the **Destination**.
|
||||
5. Click **Create Sell Offer**.
|
||||
6. Click **Get Offers** to see the new offer.
|
||||
|
||||
|
||||
[](img/quickstart25.png)
|
||||
|
||||
2. Use the Operational account to create a NFT Buy Offer.
|
||||
1. Enter the **Amount** of your offer.
|
||||
2. Enter the **NFT ID**.
|
||||
3. Enter the owner’s account string in the **Owner** field.
|
||||
4. Optionally enter the number of seconds until **Expiration**.
|
||||
5. Click **Create Buy Offer**.
|
||||
|
||||
[](img/quickstart-py26.png)
|
||||
|
||||
## Get Offers
|
||||
|
||||
1. Enter the **NFT ID**.
|
||||
2. Click **Get Offers**.
|
||||
|
||||
[](img/quickstart-py27.png)
|
||||
|
||||
## Broker the Sale
|
||||
|
||||
1. Copy the _nft_offer_index_ of the sell offer and paste it in the **Sell NFT Offer Index** field.
|
||||
2. Copy the _nft_offer_index_ of the buy offer and paste it in the **Buy NFT Offer Index** field.
|
||||
3. Enter a **Broker Fee**, in drops.
|
||||
4. Click **Broker Sale**.
|
||||
|
||||
[](img/quickstart-py28.png)
|
||||
|
||||
|
||||
## Cancel Offer
|
||||
|
||||
After accepting a buy offer, a best practice for the broker is to cancel all other offers, if the broker has permissions to do so. Use **Get Offers** to get the full list of buy offers. To cancel an offer:
|
||||
|
||||
1. Enter the _nft_offer_index_ of the buy offer you want to cancel in the **Buy NFT Offer Index** field.
|
||||
2. Click **Cancel Offer**.
|
||||
|
||||
[](img/quickstart-py29.png)
|
||||
|
||||
# Code Walkthrough
|
||||
|
||||
You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/quickstart/js/quickstart.zip){.github-code-download} archive to examine the code samples.
|
||||
|
||||
## ripplex5-broker-nfts.js
|
||||
<!-- SPELLING_IGNORE: ripplex5 -->
|
||||
|
||||
Four of the five buttons for the Broker are supported by existing methods. The only new method required is the Broker Sale method.
|
||||
|
||||
Import dependencies and create a global variable for `testnet_url`.
|
||||
|
||||
```python
|
||||
import xrpl
|
||||
import json
|
||||
from xrpl.clients import JsonRpcClient
|
||||
from xrpl.wallet import Wallet
|
||||
testnet_url = "https://s.altnet.rippletest.net:51234"
|
||||
```
|
||||
|
||||
## Broker Sale
|
||||
|
||||
Pass the _seed_, _sell___offer___index_, _buy___offer___index_, and _broker___fee_.
|
||||
|
||||
```python
|
||||
def broker_sale(seed, sell_offer_index, buy_offer_index, broker_fee):
|
||||
"""broker_sale"""
|
||||
```
|
||||
|
||||
Get the broker wallet and establish a client connection.
|
||||
|
||||
```python
|
||||
broker_wallet=Wallet(seed, sequence=16237283)
|
||||
client=JsonRpcClient(testnet_url)
|
||||
```
|
||||
|
||||
Define the accept offer transaction, matching a sell offer with the selected buy offer.
|
||||
|
||||
```python
|
||||
accept_offer_tx=xrpl.models.transactions.NFTokenAcceptOffer(
|
||||
account=broker_wallet.classic_address,
|
||||
nftoken_sell_offer=sell_offer_index,
|
||||
nftoken_buy_offer=buy_offer_index,
|
||||
nftoken_broker_fee=broker_fee
|
||||
)
|
||||
```
|
||||
|
||||
Sign and fill the transaction.
|
||||
|
||||
```python
|
||||
signed_tx=xrpl.transaction.safe_sign_and_autofill_transaction(
|
||||
accept_offer_tx, broker_wallet, client)
|
||||
```
|
||||
|
||||
Submit the transaction and report the results.
|
||||
|
||||
```python
|
||||
reply=""
|
||||
try:
|
||||
response=xrpl.transaction.send_reliable_submission(signed_tx,client)
|
||||
reply=response.result
|
||||
except xrpl.transaction.XRPLReliableSubmissionException as e:
|
||||
reply=f"Submit failed: {e}"
|
||||
```
|
||||
|
||||
## lesson5-broker-nfts.py
|
||||
|
||||
Revise the form from lesson 4 to add a new Broker section at the top. Changes are highlighted below.
|
||||
|
||||
```python
|
||||
import tkinter as tk
|
||||
import xrpl
|
||||
import json
|
||||
```
|
||||
|
||||
Import the `broker_sale` method.
|
||||
|
||||
```python
|
||||
from mod1 import get_account, get_account_info, send_xrp
|
||||
from mod2 import (
|
||||
create_trust_line,
|
||||
send_currency,
|
||||
get_balance,
|
||||
configure_account,
|
||||
)
|
||||
from mod3 import (
|
||||
mint_token,
|
||||
get_tokens,
|
||||
burn_token,
|
||||
)
|
||||
from mod4 import (
|
||||
create_sell_offer,
|
||||
create_buy_offer,
|
||||
get_offers,
|
||||
cancel_offer,
|
||||
accept_sell_offer,
|
||||
accept_buy_offer,
|
||||
)
|
||||
from mod5 import broker_sale
|
||||
|
||||
#############################################
|
||||
## Handlers #################################
|
||||
#############################################
|
||||
```
|
||||
|
||||
Add handlers for the broker account buttons.
|
||||
|
||||
```python
|
||||
# Module 5 Handlers
|
||||
|
||||
def get_broker_account():
|
||||
new_wallet = get_account(ent_broker_seed.get())
|
||||
ent_broker_account.delete(0, tk.END)
|
||||
ent_broker_seed.delete(0, tk.END)
|
||||
ent_broker_account.insert(0, new_wallet.classic_address)
|
||||
ent_broker_seed.insert(0, new_wallet.seed)
|
||||
|
||||
|
||||
def get_broker_account_info():
|
||||
accountInfo = get_account_info(ent_broker_account.get())
|
||||
ent_broker_balance.delete(0, tk.END)
|
||||
ent_broker_balance.insert(0,accountInfo['Balance'])
|
||||
text_broker_results.delete("1.0", tk.END)
|
||||
text_broker_results.insert("1.0",json.dumps(accountInfo, indent=4))
|
||||
|
||||
|
||||
def broker_broker_sale():
|
||||
results = broker_sale(
|
||||
ent_broker_seed.get(),
|
||||
ent_broker_sell_nft_idx.get(),
|
||||
ent_broker_buy_nft_idx.get(),
|
||||
ent_broker_fee.get()
|
||||
)
|
||||
text_broker_results.delete("1.0", tk.END)
|
||||
text_broker_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def broker_get_offers():
|
||||
results = get_offers(ent_broker_nft_id.get())
|
||||
text_broker_results.delete("1.0", tk.END)
|
||||
text_broker_results.insert("1.0", results)
|
||||
|
||||
|
||||
def broker_cancel_offer():
|
||||
results = cancel_offer(
|
||||
ent_broker_seed.get(),
|
||||
ent_broker_buy_nft_idx.get()
|
||||
)
|
||||
text_broker_results.delete("1.0", tk.END)
|
||||
text_broker_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
# Module 4 Handlers
|
||||
|
||||
def standby_create_sell_offer():
|
||||
results = create_sell_offer(
|
||||
ent_standby_seed.get(),
|
||||
ent_standby_amount.get(),
|
||||
ent_standby_nft_id.get(),
|
||||
ent_standby_expiration.get(),
|
||||
ent_standby_destination.get()
|
||||
)
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def standby_accept_sell_offer():
|
||||
results = accept_sell_offer (
|
||||
ent_standby_seed.get(),
|
||||
ent_standby_nft_offer_index.get()
|
||||
)
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def standby_create_buy_offer():
|
||||
results = create_buy_offer(
|
||||
ent_standby_seed.get(),
|
||||
ent_standby_amount.get(),
|
||||
ent_standby_nft_id.get(),
|
||||
ent_standby_owner.get(),
|
||||
ent_standby_expiration.get(),
|
||||
ent_standby_destination.get()
|
||||
)
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def standby_accept_buy_offer():
|
||||
results = accept_buy_offer (
|
||||
ent_standby_seed.get(),
|
||||
ent_standby_nft_offer_index.get()
|
||||
)
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def standby_get_offers():
|
||||
results = get_offers(ent_standby_nft_id.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", results)
|
||||
|
||||
|
||||
def standby_cancel_offer():
|
||||
results = cancel_offer(
|
||||
ent_standby_seed.get(),
|
||||
ent_standby_nft_offer_index.get()
|
||||
)
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def op_create_sell_offer():
|
||||
results = create_sell_offer(
|
||||
ent_operational_seed.get(),
|
||||
ent_operational_amount.get(),
|
||||
ent_operational_nft_id.get(),
|
||||
ent_operational_expiration.get(),
|
||||
ent_operational_destination.get()
|
||||
)
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def op_accept_sell_offer():
|
||||
results = accept_sell_offer (
|
||||
ent_operational_seed.get(),
|
||||
ent_operational_nft_offer_index.get()
|
||||
)
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def op_create_buy_offer():
|
||||
results = create_buy_offer(
|
||||
ent_operational_seed.get(),
|
||||
ent_operational_amount.get(),
|
||||
ent_operational_nft_id.get(),
|
||||
ent_operational_owner.get(),
|
||||
ent_operational_expiration.get(),
|
||||
ent_operational_destination.get()
|
||||
)
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def op_accept_buy_offer():
|
||||
results = accept_buy_offer (
|
||||
ent_operational_seed.get(),
|
||||
ent_operational_nft_offer_index.get()
|
||||
)
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def op_get_offers():
|
||||
results = get_offers(ent_operational_nft_id.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", results)
|
||||
|
||||
|
||||
def op_cancel_offer():
|
||||
results = cancel_offer(
|
||||
ent_operational_seed.get(),
|
||||
ent_operational_nft_offer_index.get()
|
||||
)
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
|
||||
# Module 3 Handlers
|
||||
|
||||
def standby_mint_token():
|
||||
results = mint_token(
|
||||
ent_standby_seed.get(),
|
||||
ent_standby_uri.get(),
|
||||
ent_standby_flags.get(),
|
||||
ent_standby_transfer_fee.get(),
|
||||
ent_standby_taxon.get()
|
||||
)
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def standby_get_tokens():
|
||||
results = get_tokens(ent_standby_account.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def standby_burn_token():
|
||||
results = burn_token(
|
||||
ent_standby_seed.get(),
|
||||
ent_standby_nft_id.get()
|
||||
)
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def operational_mint_token():
|
||||
results = mint_token(
|
||||
ent_operational_seed.get(),
|
||||
ent_operational_uri.get(),
|
||||
ent_operational_flags.get(),
|
||||
ent_operational_transfer_fee.get(),
|
||||
ent_operational_taxon.get()
|
||||
)
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def operational_get_tokens():
|
||||
results = get_tokens(ent_operational_account.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def operational_burn_token():
|
||||
results = burn_token(
|
||||
ent_operational_seed.get(),
|
||||
ent_operational_nft_id.get()
|
||||
)
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
# Module 2 Handlers
|
||||
|
||||
def standby_create_trust_line():
|
||||
results = create_trust_line(ent_standby_seed.get(),
|
||||
ent_standby_destination.get(),
|
||||
ent_standby_currency.get(),
|
||||
ent_standby_amount.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def standby_send_currency():
|
||||
results = send_currency(ent_standby_seed.get(),
|
||||
ent_standby_destination.get(),
|
||||
ent_standby_currency.get(),
|
||||
ent_standby_amount.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def standby_configure_account():
|
||||
results = configure_account(
|
||||
ent_standby_seed.get(),
|
||||
standbyRippling)
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def operational_create_trust_line():
|
||||
results = create_trust_line(ent_operational_seed.get(),
|
||||
ent_operational_destination.get(),
|
||||
ent_operational_currency.get(),
|
||||
ent_operational_amount.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def operational_send_currency():
|
||||
results = send_currency(ent_operational_seed.get(),
|
||||
ent_operational_destination.get(),
|
||||
ent_operational_currency.get(),
|
||||
ent_operational_amount.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def operational_configure_account():
|
||||
results = configure_account(
|
||||
ent_operational_seed.get(),
|
||||
operationalRippling)
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def get_balances():
|
||||
results = get_balance(ent_operational_account.get(), ent_standby_account.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
results = get_balance(ent_standby_account.get(), ent_operational_account.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
# Module 1 Handlers
|
||||
def get_standby_account():
|
||||
new_wallet = get_account(ent_standby_seed.get())
|
||||
ent_standby_account.delete(0, tk.END)
|
||||
ent_standby_seed.delete(0, tk.END)
|
||||
ent_standby_account.insert(0, new_wallet.classic_address)
|
||||
ent_standby_seed.insert(0, new_wallet.seed)
|
||||
|
||||
|
||||
def get_standby_account_info():
|
||||
accountInfo = get_account_info(ent_standby_account.get())
|
||||
ent_standby_balance.delete(0, tk.END)
|
||||
ent_standby_balance.insert(0,accountInfo['Balance'])
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0",json.dumps(accountInfo, indent=4))
|
||||
|
||||
|
||||
def standby_send_xrp():
|
||||
response = send_xrp(ent_standby_seed.get(),ent_standby_amount.get(),
|
||||
ent_standby_destination.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0",json.dumps(response.result, indent=4))
|
||||
get_standby_account_info()
|
||||
get_operational_account_info()
|
||||
|
||||
|
||||
def get_operational_account():
|
||||
new_wallet = get_account(ent_operational_seed.get())
|
||||
ent_operational_account.delete(0, tk.END)
|
||||
ent_operational_account.insert(0, new_wallet.classic_address)
|
||||
ent_operational_seed.delete(0, tk.END)
|
||||
ent_operational_seed.insert(0, new_wallet.seed)
|
||||
|
||||
|
||||
def get_operational_account_info():
|
||||
accountInfo = get_account_info(ent_operational_account.get())
|
||||
ent_operational_balance.delete(0, tk.END)
|
||||
ent_operational_balance.insert(0,accountInfo['Balance'])
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0",json.dumps(accountInfo, indent=4))
|
||||
|
||||
|
||||
def operational_send_xrp():
|
||||
response = send_xrp(ent_operational_seed.get(),ent_operational_amount.get(), ent_operational_destination.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0",json.dumps(response.result,indent=4))
|
||||
get_standby_account_info()
|
||||
get_operational_account_info()
|
||||
```
|
||||
|
||||
Create a new window with the title _Quickstart - Broker Sale_.
|
||||
|
||||
```python
|
||||
window = tk.Tk()
|
||||
window.title("Quickstart - Broker Sale")
|
||||
|
||||
myscrollbar=tk.Scrollbar(window,orient="vertical")
|
||||
myscrollbar.pack(side="right",fill="y")
|
||||
|
||||
|
||||
standbyRippling = tk.BooleanVar()
|
||||
operationalRippling = tk.BooleanVar()
|
||||
```
|
||||
|
||||
Add a new frame to hold the broker fields and buttons.
|
||||
|
||||
```python
|
||||
# Broker frame
|
||||
|
||||
frm_broker = tk.Frame(relief=tk.SUNKEN, borderwidth=3)
|
||||
frm_broker.pack()
|
||||
```
|
||||
|
||||
Define the broker entry fields.
|
||||
|
||||
```python
|
||||
lbl_broker_seed = tk.Label(master=frm_broker, text="Broker Seed")
|
||||
ent_broker_seed = tk.Entry(master=frm_broker, width=50)
|
||||
lbl_broker_account = tk.Label(master=frm_broker, text="Broker Account")
|
||||
ent_broker_account = tk.Entry(master=frm_broker, width=50)
|
||||
lbl_broker_balance = tk.Label(master=frm_broker, text="XRP Balance")
|
||||
ent_broker_balance = tk.Entry(master=frm_broker, width=50)
|
||||
lbl_broker_amount = tk.Label(master=frm_broker, text="Amount")
|
||||
ent_broker_amount = tk.Entry(master=frm_broker, width=50)
|
||||
lbl_broker_nft_id = tk.Label(master=frm_broker, text="NFT ID")
|
||||
ent_broker_nft_id = tk.Entry(master=frm_broker, width=50)
|
||||
lbl_broker_sell_nft_idx = tk.Label(master=frm_broker, text="Sell NFT Offer Index")
|
||||
ent_broker_sell_nft_idx = tk.Entry(master=frm_broker, width=50)
|
||||
lbl_broker_buy_nft_idx = tk.Label(master=frm_broker, text="Buy NFT Offer Index")
|
||||
ent_broker_buy_nft_idx = tk.Entry(master=frm_broker, width=50)
|
||||
lbl_broker_owner = tk.Label(master=frm_broker, text="Owner")
|
||||
ent_broker_owner = tk.Entry(master=frm_broker, width=50)
|
||||
lbl_broker_fee = tk.Label(master=frm_broker, text="Broker Fee")
|
||||
ent_broker_fee = tk.Entry(master=frm_broker, width=50)
|
||||
lbl_broker_results=tk.Label(master=frm_broker, text="Results")
|
||||
text_broker_results = tk.Text(master=frm_broker, height=10, width=65)
|
||||
```
|
||||
|
||||
Place the fields in a grid.
|
||||
|
||||
```python
|
||||
lbl_broker_seed.grid(row=0, column=0, sticky="w")
|
||||
ent_broker_seed.grid(row=0, column=1)
|
||||
lbl_broker_account.grid(row=1, column=0, sticky="w")
|
||||
ent_broker_account.grid(row=1, column=1)
|
||||
lbl_broker_balance.grid(row=2, column=0, sticky="w")
|
||||
ent_broker_balance.grid(row=2, column=1)
|
||||
lbl_broker_amount.grid(row=3, column=0, sticky="w")
|
||||
ent_broker_amount.grid(row=3, column=1)
|
||||
lbl_broker_nft_id.grid(row=4, column=0, sticky="w")
|
||||
ent_broker_nft_id.grid(row=4, column=1)
|
||||
lbl_broker_sell_nft_idx.grid(row=5, column=0, sticky="w")
|
||||
ent_broker_sell_nft_idx.grid(row=5, column=1)
|
||||
lbl_broker_buy_nft_idx.grid(row=6, column=0, sticky="w")
|
||||
ent_broker_buy_nft_idx.grid(row=6, column=1)
|
||||
lbl_broker_owner.grid(row=7, column=0, sticky="w")
|
||||
ent_broker_owner.grid(row=7, column=1)
|
||||
lbl_broker_fee.grid(row=8, column=0, sticky="w")
|
||||
ent_broker_fee.grid(row=8, column=1)
|
||||
lbl_broker_results.grid(row=9, column=0)
|
||||
text_broker_results.grid(row=9, column=1)
|
||||
```
|
||||
|
||||
Define and place the broker buttons.
|
||||
|
||||
```python
|
||||
btn_broker_get_account = tk.Button(master=frm_broker, text="Get Broker Account",
|
||||
command = get_broker_account)
|
||||
btn_broker_get_account.grid(row=0, column=2, sticky = "nsew")
|
||||
btn_broker_get_account_info = tk.Button(master=frm_broker, text="Get Broker Account Info",
|
||||
command = get_broker_account_info)
|
||||
btn_broker_get_account_info.grid(row=1, column=2, sticky = "nsew")
|
||||
btn_broker_sale = tk.Button(master=frm_broker, text="Broker Sale",
|
||||
command = broker_broker_sale)
|
||||
btn_broker_sale.grid(row=2, column=2, sticky = "nsew")
|
||||
btn_broker_get_offers = tk.Button(master=frm_broker, text="Get Offers",
|
||||
command = broker_get_offers)
|
||||
btn_broker_get_offers.grid(row=3, column=2, sticky = "nsew")
|
||||
btn_broker_cancel_offer = tk.Button(master=frm_broker, text="Cancel Offer",
|
||||
command = broker_cancel_offer)
|
||||
btn_broker_cancel_offer.grid(row=4, column=2, sticky="nsew")
|
||||
|
||||
# Form frame
|
||||
frm_form = tk.Frame(relief=tk.SUNKEN, borderwidth=3)
|
||||
frm_form.pack()
|
||||
|
||||
# Create the Label and Entry widgets for "Standby Account"
|
||||
lbl_standy_seed = tk.Label(master=frm_form, text="Standby Seed")
|
||||
ent_standby_seed = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standby_account = tk.Label(master=frm_form, text="Standby Account")
|
||||
ent_standby_account = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standy_amount = tk.Label(master=frm_form, text="Amount")
|
||||
ent_standby_amount = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standby_destination = tk.Label(master=frm_form, text="Destination")
|
||||
ent_standby_destination = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standby_balance = tk.Label(master=frm_form, text="XRP Balance")
|
||||
ent_standby_balance = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standby_currency = tk.Label(master=frm_form, text="Currency")
|
||||
ent_standby_currency = tk.Entry(master=frm_form, width=50)
|
||||
cb_standby_allow_rippling = tk.Checkbutton(master=frm_form, text="Allow Rippling", variable=standbyRippling, onvalue=True, offvalue=False)
|
||||
lbl_standby_uri = tk.Label(master=frm_form, text="NFT URI")
|
||||
ent_standby_uri = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standby_flags = tk.Label(master=frm_form, text="Flags")
|
||||
ent_standby_flags = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standby_transfer_fee = tk.Label(master=frm_form, text="Transfer Fee")
|
||||
ent_standby_transfer_fee = tk.Entry(master=frm_form, width="50")
|
||||
lbl_standby_taxon = tk.Label(master=frm_form, text="Taxon")
|
||||
ent_standby_taxon = tk.Entry(master=frm_form, width="50")
|
||||
lbl_standby_nft_id = tk.Label(master=frm_form, text="NFT ID")
|
||||
ent_standby_nft_id = tk.Entry(master=frm_form, width="50")
|
||||
lbl_standby_nft_offer_index = tk.Label(master=frm_form, text="NFT Offer Index")
|
||||
ent_standby_nft_offer_index = tk.Entry(master=frm_form, width="50")
|
||||
lbl_standby_owner = tk.Label(master=frm_form, text="Owner")
|
||||
ent_standby_owner = tk.Entry(master=frm_form, width="50")
|
||||
lbl_standby_expiration = tk.Label(master=frm_form, text="Expiration")
|
||||
ent_standby_expiration = tk.Entry(master=frm_form, width="50")
|
||||
lbl_standby_results = tk.Label(master=frm_form,text='Results')
|
||||
text_standby_results = tk.Text(master=frm_form, height = 10, width = 65)
|
||||
|
||||
# Place field in a grid.
|
||||
lbl_standy_seed.grid(row=0, column=0, sticky="w")
|
||||
ent_standby_seed.grid(row=0, column=1)
|
||||
lbl_standby_account.grid(row=2, column=0, sticky="e")
|
||||
ent_standby_account.grid(row=2, column=1)
|
||||
lbl_standy_amount.grid(row=3, column=0, sticky="e")
|
||||
ent_standby_amount.grid(row=3, column=1)
|
||||
lbl_standby_destination.grid(row=4, column=0, sticky="e")
|
||||
ent_standby_destination.grid(row=4, column=1)
|
||||
lbl_standby_balance.grid(row=5, column=0, sticky="e")
|
||||
ent_standby_balance.grid(row=5, column=1)
|
||||
lbl_standby_currency.grid(row=6, column=0, sticky="e")
|
||||
ent_standby_currency.grid(row=6, column=1)
|
||||
cb_standby_allow_rippling.grid(row=7,column=1, sticky="w")
|
||||
lbl_standby_uri.grid(row=8, column=0, sticky="e")
|
||||
ent_standby_uri.grid(row=8, column=1, sticky="w")
|
||||
lbl_standby_flags.grid(row=9, column=0, sticky="e")
|
||||
ent_standby_flags.grid(row=9, column=1, sticky="w")
|
||||
lbl_standby_transfer_fee.grid(row=10, column=0, sticky="e")
|
||||
ent_standby_transfer_fee.grid(row=10, column=1, sticky="w")
|
||||
lbl_standby_taxon.grid(row=11, column=0, sticky="e")
|
||||
ent_standby_taxon.grid(row=11, column=1, sticky="w")
|
||||
lbl_standby_nft_id.grid(row=12, column=0, sticky="e")
|
||||
ent_standby_nft_id.grid(row=12, column=1, sticky="w")
|
||||
lbl_standby_nft_offer_index.grid(row=13, column=0, sticky="ne")
|
||||
ent_standby_nft_offer_index.grid(row=13, column=1, sticky="w")
|
||||
lbl_standby_owner.grid(row=14, column=0, sticky="ne")
|
||||
ent_standby_owner.grid(row=14, column=1, sticky="w")
|
||||
lbl_standby_expiration.grid(row=15, column=0, sticky="ne")
|
||||
ent_standby_expiration.grid(row=15, column=1, sticky="w")
|
||||
lbl_standby_results.grid(row=17, column=0, sticky="ne")
|
||||
text_standby_results.grid(row=17, column=1, sticky="nw")
|
||||
|
||||
cb_standby_allow_rippling.select()
|
||||
|
||||
###############################################
|
||||
## Operational Account ########################
|
||||
###############################################
|
||||
|
||||
# Create the Label and Entry widgets for "Operational Account"
|
||||
lbl_operational_seed = tk.Label(master=frm_form, text="Operational Seed")
|
||||
ent_operational_seed = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_account = tk.Label(master=frm_form, text="Operational Account")
|
||||
ent_operational_account = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_amount = tk.Label(master=frm_form, text="Amount")
|
||||
ent_operational_amount = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_destination = tk.Label(master=frm_form, text="Destination")
|
||||
ent_operational_destination = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_balance = tk.Label(master=frm_form, text="XRP Balance")
|
||||
ent_operational_balance = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_currency = tk.Label(master=frm_form, text="Currency")
|
||||
ent_operational_currency = tk.Entry(master=frm_form, width=50)
|
||||
cb_operational_allow_rippling = tk.Checkbutton(master=frm_form, text="Allow Rippling", variable=operationalRippling, onvalue=True, offvalue=False)
|
||||
lbl_operational_uri = tk.Label(master=frm_form, text="NFT URI")
|
||||
ent_operational_uri = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_flags = tk.Label(master=frm_form, text="Flags")
|
||||
ent_operational_flags = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_transfer_fee = tk.Label(master=frm_form, text="Transfer Fee")
|
||||
ent_operational_transfer_fee = tk.Entry(master=frm_form, width="50")
|
||||
lbl_operational_taxon = tk.Label(master=frm_form, text="Taxon")
|
||||
ent_operational_taxon = tk.Entry(master=frm_form, width="50")
|
||||
lbl_operational_nft_id = tk.Label(master=frm_form, text="NFT ID")
|
||||
ent_operational_nft_id = tk.Entry(master=frm_form, width="50")
|
||||
lbl_operational_nft_offer_index = tk.Label(master=frm_form, text="NFT Offer Index")
|
||||
ent_operational_nft_offer_index = tk.Entry(master=frm_form, width="50")
|
||||
lbl_operational_owner = tk.Label(master=frm_form, text="Owner")
|
||||
ent_operational_owner = tk.Entry(master=frm_form, width="50")
|
||||
lbl_operational_expiration = tk.Label(master=frm_form, text="Expiration")
|
||||
ent_operational_expiration = tk.Entry(master=frm_form, width="50")
|
||||
lbl_operational_results = tk.Label(master=frm_form,text="Results")
|
||||
text_operational_results = tk.Text(master=frm_form, height = 10, width = 65)
|
||||
|
||||
#Place the widgets in a grid
|
||||
lbl_operational_seed.grid(row=0, column=4, sticky="e")
|
||||
ent_operational_seed.grid(row=0, column=5, sticky="w")
|
||||
lbl_operational_account.grid(row=2,column=4, sticky="e")
|
||||
ent_operational_account.grid(row=2,column=5, sticky="w")
|
||||
lbl_operational_amount.grid(row=3, column=4, sticky="e")
|
||||
ent_operational_amount.grid(row=3, column=5, sticky="w")
|
||||
lbl_operational_destination.grid(row=4, column=4, sticky="e")
|
||||
ent_operational_destination.grid(row=4, column=5, sticky="w")
|
||||
lbl_operational_balance.grid(row=5, column=4, sticky="e")
|
||||
ent_operational_balance.grid(row=5, column=5, sticky="w")
|
||||
lbl_operational_currency.grid(row=6, column=4, sticky="e")
|
||||
ent_operational_currency.grid(row=6, column=5)
|
||||
cb_operational_allow_rippling.grid(row=7,column=5, sticky="w")
|
||||
lbl_operational_uri.grid(row=8, column=4, sticky="e")
|
||||
ent_operational_uri.grid(row=8, column=5, sticky="w")
|
||||
lbl_operational_flags.grid(row=9, column=4, sticky="e")
|
||||
ent_operational_flags.grid(row=9, column=5, sticky="w")
|
||||
lbl_operational_transfer_fee.grid(row=10, column=4, sticky="e")
|
||||
ent_operational_transfer_fee.grid(row=10, column=5, sticky="w")
|
||||
lbl_operational_taxon.grid(row=11, column=4, sticky="e")
|
||||
ent_operational_taxon.grid(row=11, column=5, sticky="w")
|
||||
lbl_operational_nft_id.grid(row=12, column=4, sticky="e")
|
||||
ent_operational_nft_id.grid(row=12, column=5, sticky="w")
|
||||
lbl_operational_nft_offer_index.grid(row=13, column=4, sticky="ne")
|
||||
ent_operational_nft_offer_index.grid(row=13, column=5, sticky="w")
|
||||
lbl_operational_owner.grid(row=14, column=4, sticky="ne")
|
||||
ent_operational_owner.grid(row=14, column=5, sticky="w")
|
||||
lbl_operational_expiration.grid(row=15, column=4, sticky="ne")
|
||||
ent_operational_expiration.grid(row=15, column=5, sticky="w")
|
||||
lbl_operational_results.grid(row=17, column=4, sticky="ne")
|
||||
text_operational_results.grid(row=17, column=5, sticky="nw")
|
||||
|
||||
cb_operational_allow_rippling.select()
|
||||
|
||||
#############################################
|
||||
## Buttons ##################################
|
||||
#############################################
|
||||
|
||||
# Create the Standby Account Buttons
|
||||
btn_get_standby_account = tk.Button(master=frm_form, text="Get Standby Account",
|
||||
command = get_standby_account)
|
||||
btn_get_standby_account.grid(row=0, column=2, sticky = "nsew")
|
||||
btn_get_standby_account_info = tk.Button(master=frm_form,
|
||||
text="Get Standby Account Info",
|
||||
command = get_standby_account_info)
|
||||
btn_get_standby_account_info.grid(row=1, column=2, sticky = "nsew")
|
||||
btn_standby_send_xrp = tk.Button(master=frm_form, text="Send XRP >",
|
||||
command = standby_send_xrp)
|
||||
btn_standby_send_xrp.grid(row=2, column = 2, sticky = "nsew")
|
||||
btn_standby_create_trust_line = tk.Button(master=frm_form,
|
||||
text="Create Trust Line",
|
||||
command = standby_create_trust_line)
|
||||
btn_standby_create_trust_line.grid(row=4, column=2, sticky = "nsew")
|
||||
btn_standby_send_currency = tk.Button(master=frm_form, text="Send Currency >",
|
||||
command = standby_send_currency)
|
||||
btn_standby_send_currency.grid(row=5, column=2, sticky = "nsew")
|
||||
btn_standby_send_currency = tk.Button(master=frm_form, text="Get Balances",
|
||||
command = get_balances)
|
||||
btn_standby_send_currency.grid(row=6, column=2, sticky = "nsew")
|
||||
btn_standby_configure_account = tk.Button(master=frm_form,
|
||||
text="Configure Account",
|
||||
command = standby_configure_account)
|
||||
btn_standby_configure_account.grid(row=7,column=0, sticky = "nsew")
|
||||
btn_standby_mint_token = tk.Button(master=frm_form, text="Mint NFT",
|
||||
command = standby_mint_token)
|
||||
btn_standby_mint_token.grid(row=8, column=2, sticky="nsew")
|
||||
btn_standby_get_tokens = tk.Button(master=frm_form, text="Get NFTs",
|
||||
command = standby_get_tokens)
|
||||
btn_standby_get_tokens.grid(row=9, column=2, sticky="nsew")
|
||||
btn_standby_burn_token = tk.Button(master=frm_form, text="Burn NFT",
|
||||
command = standby_burn_token)
|
||||
btn_standby_burn_token.grid(row=10, column=2, sticky="nsew")
|
||||
btn_standby_create_sell_offer = tk.Button(master=frm_form, text="Create Sell Offer",
|
||||
command = standby_create_sell_offer)
|
||||
btn_standby_create_sell_offer.grid(row=11, column=2, sticky="nsew")
|
||||
btn_standby_accept_sell_offer = tk.Button(master=frm_form, text="Accept Sell Offer",
|
||||
command = standby_accept_sell_offer)
|
||||
btn_standby_accept_sell_offer.grid(row=12, column=2, sticky="nsew")
|
||||
btn_standby_create_buy_offer = tk.Button(master=frm_form, text="Create Buy Offer",
|
||||
command = standby_create_buy_offer)
|
||||
btn_standby_create_buy_offer.grid(row=13, column=2, sticky="nsew")
|
||||
btn_standby_accept_buy_offer = tk.Button(master=frm_form, text="Accept Buy Offer",
|
||||
command = standby_accept_buy_offer)
|
||||
btn_standby_accept_buy_offer.grid(row=14, column=2, sticky="nsew")
|
||||
btn_standby_get_offers = tk.Button(master=frm_form, text="Get Offers",
|
||||
command = standby_get_offers)
|
||||
btn_standby_get_offers.grid(row=15, column=2, sticky="nsew")
|
||||
btn_standby_cancel_offer = tk.Button(master=frm_form, text="Cancel Offer",
|
||||
command = standby_cancel_offer)
|
||||
btn_standby_cancel_offer.grid(row=16, column=2, sticky="nsew")
|
||||
|
||||
|
||||
|
||||
# Create the Operational Account Buttons
|
||||
btn_get_operational_account = tk.Button(master=frm_form,
|
||||
text="Get Operational Account",
|
||||
command = get_operational_account)
|
||||
btn_get_operational_account.grid(row=0, column=3, sticky = "nsew")
|
||||
btn_get_op_account_info = tk.Button(master=frm_form, text="Get Op Account Info",
|
||||
command = get_operational_account_info)
|
||||
btn_get_op_account_info.grid(row=1, column=3, sticky = "nsew")
|
||||
btn_op_send_xrp = tk.Button(master=frm_form, text="< Send XRP",
|
||||
command = operational_send_xrp)
|
||||
btn_op_send_xrp.grid(row=2, column = 3, sticky = "nsew")
|
||||
btn_op_create_trust_line = tk.Button(master=frm_form, text="Create Trust Line",
|
||||
command = operational_create_trust_line)
|
||||
btn_op_create_trust_line.grid(row=4, column=3, sticky = "nsew")
|
||||
btn_op_send_currency = tk.Button(master=frm_form, text="< Send Currency",
|
||||
command = operational_send_currency)
|
||||
btn_op_send_currency.grid(row=5, column=3, sticky = "nsew")
|
||||
btn_op_get_balances = tk.Button(master=frm_form, text="Get Balances",
|
||||
command = get_balances)
|
||||
btn_op_get_balances.grid(row=6, column=3, sticky = "nsew")
|
||||
btn_op_configure_account = tk.Button(master=frm_form, text="Configure Account",
|
||||
command = operational_configure_account)
|
||||
btn_op_configure_account.grid(row=7,column=4, sticky = "nsew")
|
||||
btn_op_mint_token = tk.Button(master=frm_form, text="Mint NFT",
|
||||
command = operational_mint_token)
|
||||
btn_op_mint_token.grid(row=8, column=3, sticky="nsew")
|
||||
btn_op_get_tokens = tk.Button(master=frm_form, text="Get NFTs",
|
||||
command = operational_get_tokens)
|
||||
btn_op_get_tokens.grid(row=9, column=3, sticky="nsew")
|
||||
btn_op_burn_token = tk.Button(master=frm_form, text="Burn NFT",
|
||||
command = operational_burn_token)
|
||||
btn_op_burn_token.grid(row=10, column=3, sticky="nsew")
|
||||
btn_op_create_sell_offer = tk.Button(master=frm_form, text="Create Sell Offer",
|
||||
command = op_create_sell_offer)
|
||||
btn_op_create_sell_offer.grid(row=11, column=3, sticky="nsew")
|
||||
btn_op_accept_sell_offer = tk.Button(master=frm_form, text="Accept Sell Offer",
|
||||
command = op_accept_sell_offer)
|
||||
btn_op_accept_sell_offer.grid(row=12, column=3, sticky="nsew")
|
||||
btn_op_create_buy_offer = tk.Button(master=frm_form, text="Create Buy Offer",
|
||||
command = op_create_buy_offer)
|
||||
btn_op_create_buy_offer.grid(row=13, column=3, sticky="nsew")
|
||||
btn_op_accept_buy_offer = tk.Button(master=frm_form, text="Accept Buy Offer",
|
||||
command = op_accept_buy_offer)
|
||||
btn_op_accept_buy_offer.grid(row=14, column=3, sticky="nsew")
|
||||
btn_op_get_offers = tk.Button(master=frm_form, text="Get Offers",
|
||||
command = op_get_offers)
|
||||
btn_op_get_offers.grid(row=15, column=3, sticky="nsew")
|
||||
btn_op_cancel_offer = tk.Button(master=frm_form, text="Cancel Offer",
|
||||
command = op_cancel_offer)
|
||||
btn_op_cancel_offer.grid(row=16, column=3, sticky="nsew")
|
||||
|
||||
|
||||
# Start the application
|
||||
window.mainloop()
|
||||
```
|
||||
432
content/tutorials/quickstart/py-create-accounts-send-xrp.md
Normal file
@@ -0,0 +1,432 @@
|
||||
---
|
||||
html: py-create-accounts-send-xrp.html
|
||||
parent: quickstart-python.html
|
||||
blurb: Quickstart 1, create two accounts and transfer XRP between them.
|
||||
labels:
|
||||
- Accounts
|
||||
- Quickstart
|
||||
- Transaction Sending
|
||||
- XRP
|
||||
---
|
||||
# 1. Create Accounts and Send XRP (Python)
|
||||
|
||||
This example shows how to:
|
||||
|
||||
1. Create accounts on the Testnet, funded with 10000 test XRP with no actual value.
|
||||
2. Retrieve the accounts from seed values.
|
||||
3. Transfer XRP between accounts.
|
||||
|
||||
When you create an account, you receive a public/private key pair offline. Your account does not appear on the ledger until it is funded with XRP. This example shows how to create accounts for Testnet, but not how to create an account that you can use on Mainnet.
|
||||
|
||||
[](img/quickstart-py2.png)
|
||||
|
||||
## Prerequisites
|
||||
|
||||
To get started, create a new folder on your local disk and install the Python library using `pip`.
|
||||
|
||||
```
|
||||
pip3 install xrpl-py
|
||||
```
|
||||
|
||||
Download and expand the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/quickstart/python/){.github-code-download} archive.
|
||||
|
||||
**Note:** Without the Quickstart Samples, you will not be able to try the examples that follow.
|
||||
|
||||
## Usage
|
||||
|
||||
To get test accounts:
|
||||
|
||||
1. Open and launch `lesson1-send-xrp.py`.
|
||||
2. Click **Get Standby Account**.
|
||||
3. Click **Get Operational Account**.
|
||||
4. Click **Get Standby Account Info**.
|
||||
5. Click **Get Operational Account Info**.
|
||||
5. Copy and paste the **Standby Seed** and **Operational Seed** fields to a persistent location, such as a Notepad, so that you can reuse the accounts after reloading the form.
|
||||
|
||||
[](img/quickstart-py3.png)
|
||||
|
||||
You can transfer XRP between your new accounts. Each account has its own fields and buttons.
|
||||
|
||||
To transfer XRP from the Standby account to the Operational account:
|
||||
|
||||
1. On the Standby (left) side of the form, enter the **Amount** of XRP to send.
|
||||
2. Copy and paste the **Operational Account** field to the Standby **Destination** field.
|
||||
3. Click **Send XRP>** to transfer XRP from the standby account to the operational account
|
||||
|
||||
[](img/quickstart-py4.png)
|
||||
|
||||
To transfer XRP from the Operational account to the Standby account:
|
||||
|
||||
1. On the Operational (right) side of the form, enter the **Amount** of XRP to send.
|
||||
2. Copy and paste the **Standby Account** field to the Operational **Destination** field.
|
||||
3. Click **<Send XRP** to transfer XRP from the Operational account to the Standby account.
|
||||
|
||||
# Code Walkthrough
|
||||
|
||||
You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/quickstart/js/quickstart.zip){.github-code-download} in the source repository for this website.
|
||||
|
||||
## mod1.py
|
||||
|
||||
The mod1.py module contains the business logic for interacting with the XRP Ledger.
|
||||
|
||||
Import the XRPL and JSON libraries, and the module 1 methods.
|
||||
|
||||
```python
|
||||
import xrpl
|
||||
import json
|
||||
import xrpl.clients
|
||||
import xrpl.wallet
|
||||
|
||||
```
|
||||
|
||||
### get_account
|
||||
|
||||
This method lets you get an existing account by providing a seed value. If you provide no seed value, the method creates a new account for you.
|
||||
|
||||
Import required methods.
|
||||
|
||||
```python
|
||||
def get_account(seed):
|
||||
"""get_account"""
|
||||
```
|
||||
|
||||
This example uses the _Testnet_ ledger. You can update the URI to choose a different XRP Ledger instance.
|
||||
|
||||
```python
|
||||
JSON_RPC_URL = "https://s.altnet.rippletest.net:51234/"
|
||||
```
|
||||
|
||||
Request a new client from the XRP Ledger.
|
||||
|
||||
```python
|
||||
client = xrpl.clients.JsonRpcClient(JSON_RPC_URL)
|
||||
```
|
||||
|
||||
If you do not enter a seed, generate and return a new wallet. If you provide a seed value, return the wallet for that seed.
|
||||
|
||||
```python
|
||||
if (seed == ''):
|
||||
new_wallet = xrpl.wallet.generate_faucet_wallet(client)
|
||||
else:
|
||||
new_wallet = xrpl.wallet.Wallet(seed, sequence = 79396029)
|
||||
return(new_wallet)
|
||||
```
|
||||
|
||||
### get_account_info
|
||||
|
||||
Pass the account ID to the `get_account_info` method.
|
||||
|
||||
```python
|
||||
def get_account_info(accountId):
|
||||
"""get_account_info"""
|
||||
```
|
||||
|
||||
Get a client instance from Testnet.
|
||||
|
||||
```python
|
||||
JSON_RPC_URL = 'wss://s.altnet.rippletest.net:51234'
|
||||
client = xrpl.clients.JsonRpcClient(JSON_RPC_URL)
|
||||
```
|
||||
|
||||
Create the account info request, passing the account ID and the ledger index (in this case, the latest validated ledger).
|
||||
|
||||
```python
|
||||
acct_info = xrpl.models.requests.account_info.AccountInfo(
|
||||
account=accountId,
|
||||
ledger_index="validated"
|
||||
)
|
||||
```
|
||||
|
||||
Send the request to the XRP Ledger instance.
|
||||
|
||||
```python
|
||||
response=client.request(acct_info)
|
||||
```
|
||||
|
||||
Return the account data.
|
||||
|
||||
```python
|
||||
return response.result['account_data']
|
||||
```
|
||||
|
||||
### send_xrp
|
||||
|
||||
Transfer XRP to another account by passing the client seed, amount to transfer, and the destination account.
|
||||
|
||||
```python
|
||||
def send_xrp(seed, amount, destination):
|
||||
```
|
||||
|
||||
Get the sending wallet.
|
||||
|
||||
```python
|
||||
sending_wallet = xrpl.wallet.Wallet(seed, sequence = 16237283)
|
||||
testnet_url = "https://s.altnet.rippletest.net:51234"
|
||||
client = xrpl.clients.JsonRpcClient(testnet_url)
|
||||
```
|
||||
|
||||
Create a transaction request, passing the sending account, amount, and destination account.
|
||||
|
||||
```python
|
||||
payment=xrpl.models.transactions.Payment(
|
||||
account=sending_wallet.classic_address,
|
||||
amount=xrpl.utils.xrp_to_drops(int(amount)),
|
||||
destination=destination,
|
||||
)
|
||||
```
|
||||
|
||||
Sign the transaction.
|
||||
|
||||
```python
|
||||
signed_tx = xrpl.transaction.safe_sign_and_autofill_transaction(
|
||||
payment, sending_wallet, client)
|
||||
```
|
||||
|
||||
Submit the transaction and return the response. If the transaction fails, return the error message.
|
||||
|
||||
```python
|
||||
try:
|
||||
tx_response = xrpl.transaction.send_reliable_submission(signed_tx,client)
|
||||
response = tx_response
|
||||
except xrpl.transaction.XRPLReliableSubmissionException as e:
|
||||
response = f"Submit failed: {e}"
|
||||
return response
|
||||
```
|
||||
|
||||
## lesson1-send-xrp.py
|
||||
|
||||
This module handles the UI for the application, providing fields for entering and reporting results of transactions and requests.
|
||||
|
||||
Import the tkinter, xrpl, and json modules.
|
||||
|
||||
```python
|
||||
import tkinter as tk
|
||||
import xrpl
|
||||
import json
|
||||
```
|
||||
|
||||
Import the methods from mod1.py.
|
||||
|
||||
```python
|
||||
from .mod1 import get_account, get_account_info, send_xrp
|
||||
```
|
||||
|
||||
### getStandbyAccount
|
||||
|
||||
```python
|
||||
def get_standby_account():
|
||||
```
|
||||
|
||||
Use the value in the standby Seed field (or an empty value) to request a new account.
|
||||
|
||||
```python
|
||||
new_wallet = get_account(ent_standby_seed.get())
|
||||
```
|
||||
|
||||
Clear the **Standby Seed** and **Standby Account** fields.
|
||||
|
||||
```python
|
||||
ent_standby_account.delete(0, tk.END)
|
||||
ent_standby_seed.delete(0, tk.END)
|
||||
```
|
||||
|
||||
Insert the account ID and seed values in the standby fields.
|
||||
|
||||
```python
|
||||
ent_standby_account.insert(0, new_wallet.classic_address)
|
||||
ent_standby_seed.insert(0, new_wallet.seed)
|
||||
```
|
||||
|
||||
### get_standby_account_info
|
||||
|
||||
With an account ID, anyone can request information about the account. Get the standby account value and use it to populate a `get_account_info` request.
|
||||
|
||||
```python
|
||||
def get_standby_account_info():
|
||||
accountInfo = get_account_info(ent_standby_account.get())
|
||||
```
|
||||
|
||||
Clear the Standby **Balance** field and insert the value from the account info response.
|
||||
|
||||
```python
|
||||
ent_standby_balance.delete(0, tk.END)
|
||||
ent_standby_balance.insert(0,accountInfo['Balance'])
|
||||
```
|
||||
|
||||
Clear the Standby **Results** text area and fill it with the full JSON response.
|
||||
|
||||
```python
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0",json.dumps(accountInfo, indent=4))
|
||||
```
|
||||
|
||||
### standby_send_xrp
|
||||
|
||||
```python
|
||||
def standby_send_xrp():
|
||||
```
|
||||
|
||||
Call the `send_xrp` method, passing the standby seed, the amount, and the destination value.
|
||||
|
||||
```python
|
||||
response = send_xrp(ent_standby_seed.get(),ent_standby_amount.get(),
|
||||
ent_standby_destination.get())
|
||||
```
|
||||
|
||||
Clear the standby **Results** field and insert the JSON response.
|
||||
|
||||
```python
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0",json.dumps(response.result, indent=4))
|
||||
```
|
||||
|
||||
Use `get_standby_account_info()` and `get_operational_account_info()` to update the balance field for both accounts.
|
||||
|
||||
```python
|
||||
get_standby_account_info()
|
||||
get_operational_account_info()
|
||||
```
|
||||
|
||||
### Reciprocal Transactions and Requests
|
||||
|
||||
The following four methods are the same as the previous standby transactions, but for the operational account.
|
||||
|
||||
```python
|
||||
def get_operational_account():
|
||||
new_wallet = get_account(ent_operational_seed.get())
|
||||
ent_operational_account.delete(0, tk.END)
|
||||
ent_operational_account.insert(0, new_wallet.classic_address)
|
||||
ent_operational_seed.delete(0, tk.END)
|
||||
ent_operational_seed.insert(0, new_wallet.seed)
|
||||
|
||||
|
||||
def get_operational_account_info():
|
||||
account_info = get_account_info(ent_operational_account.get())
|
||||
ent_operational_balance.delete(0, tk.END)
|
||||
ent_operational_balance.insert(0,accountInfo['Balance'])
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0",json.dumps(accountInfo, indent=4))
|
||||
|
||||
|
||||
def operational_send_xrp():
|
||||
response = send_xrp(ent_operational_seed.get(),ent_operational_amount.get(),
|
||||
ent_operational_destination.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0",json.dumps(response.result,indent=4))
|
||||
get_standby_account_info()
|
||||
get_operational_account_info()
|
||||
```
|
||||
|
||||
Create UI elements, starting with the main window.
|
||||
|
||||
```python
|
||||
window = tk.Tk()
|
||||
window.title("Quickstart Module 1")
|
||||
```
|
||||
|
||||
Add a frame for the form.
|
||||
|
||||
```python
|
||||
frm_form = tk.Frame(relief=tk.SUNKEN, borderwidth=3)
|
||||
frm_form.pack()
|
||||
```
|
||||
|
||||
Create the `Label` and `Entry` widgets for the standby account.
|
||||
|
||||
```python
|
||||
lbl_standy_seed = tk.Label(master=frm_form, text="Standby Seed")
|
||||
ent_standby_seed = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standby_account = tk.Label(master=frm_form, text="Standby Account")
|
||||
ent_standby_account = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standy_amount = tk.Label(master=frm_form, text="Amount")
|
||||
ent_standby_amount = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standby_destination = tk.Label(master=frm_form, text="Destination")
|
||||
ent_standby_destination = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standby_balance = tk.Label(master=frm_form, text="XRP Balance")
|
||||
ent_standby_balance = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standby_results = tk.Label(master=frm_form,text='Results')
|
||||
text_standby_results = tk.Text(master=frm_form, height = 20, width = 65)
|
||||
```
|
||||
|
||||
Place the fields in a grid.
|
||||
|
||||
```python
|
||||
lbl_standy_seed.grid(row=0, column=0, sticky="w")
|
||||
ent_standby_seed.grid(row=0, column=1)
|
||||
lbl_standby_account.grid(row=2, column=0, sticky="e")
|
||||
ent_standby_account.grid(row=2, column=1)
|
||||
lbl_standy_amount.grid(row=3, column=0, sticky="e")
|
||||
ent_standby_amount.grid(row=3, column=1)
|
||||
lbl_standby_destination.grid(row=4, column=0, sticky="e")
|
||||
ent_standby_destination.grid(row=4, column=1)
|
||||
lbl_standby_balance.grid(row=5, column=0, sticky="e")
|
||||
ent_standby_balance.grid(row=5, column=1)
|
||||
lbl_standby_results.grid(row=6, column=0, sticky="ne")
|
||||
text_standby_results.grid(row=6, column=1, sticky="nw")
|
||||
```
|
||||
|
||||
Create the `Label` and `Entry` widgets for the operational account
|
||||
|
||||
```python
|
||||
lbl_operational_seed = tk.Label(master=frm_form, text="Operational Seed")
|
||||
ent_operational_seed = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_account = tk.Label(master=frm_form, text="Operational Account")
|
||||
ent_operational_account = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_amount = tk.Label(master=frm_form, text="Amount")
|
||||
ent_operational_amount = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_destination = tk.Label(master=frm_form, text="Destination")
|
||||
ent_operational_destination = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_balance = tk.Label(master=frm_form, text="XRP Balance")
|
||||
ent_operational_balance = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_results = tk.Label(master=frm_form,text='Results')
|
||||
text_operational_results = tk.Text(master=frm_form, height = 20, width = 65)
|
||||
```
|
||||
|
||||
Place the operational widgets in a grid.
|
||||
|
||||
```python
|
||||
lbl_operational_seed.grid(row=0, column=4, sticky="e")
|
||||
ent_operational_seed.grid(row=0, column=5, sticky="w")
|
||||
lbl_operational_account.grid(row=2,column=4, sticky="e")
|
||||
ent_operational_account.grid(row=2,column=5, sticky="w")
|
||||
lbl_operational_amount.grid(row=3, column=4, sticky="e")
|
||||
ent_operational_amount.grid(row=3, column=5, sticky="w")
|
||||
lbl_operational_destination.grid(row=4, column=4, sticky="e")
|
||||
ent_operational_destination.grid(row=4, column=5, sticky="w")
|
||||
lbl_operational_balance.grid(row=5, column=4, sticky="e")
|
||||
ent_operational_balance.grid(row=5, column=5, sticky="w")
|
||||
lbl_operational_results.grid(row=6, column=4, sticky="ne")
|
||||
text_operational_results.grid(row=6, column=5, sticky="nw")
|
||||
```
|
||||
|
||||
Create the standby account buttons and add them to the grid.
|
||||
|
||||
```python
|
||||
btn_get_standby_account = tk.Button(master=frm_form, text="Get Standby Account", command = get_standby_account)
|
||||
btn_get_standby_account.grid(row=0, column=2, sticky = "nsew")
|
||||
btn_get_standby_account_info = tk.Button(master=frm_form, text="Get Standby Account Info", command = get_standby_account_info)
|
||||
btn_get_standby_account_info.grid(row=1, column=2, sticky = "nsew")
|
||||
btn_standby_send_xrp = tk.Button(master=frm_form, text="Send XRP >", command = standby_send_xrp)
|
||||
btn_standby_send_xrp.grid(row=2, column = 2, sticky = "nsew")
|
||||
```
|
||||
|
||||
Create the operational account buttons and add them to the grid.
|
||||
|
||||
```python
|
||||
btn_get_operational_account = tk.Button(master=frm_form, text="Get Operational Account",
|
||||
command = get_operational_account)
|
||||
btn_get_operational_account.grid(row=0, column=3, sticky = "nsew")
|
||||
btn_get_op_account_info = tk.Button(master=frm_form, text="Get Op Account Info",
|
||||
command = get_operational_account_info)
|
||||
btn_get_op_account_info.grid(row=1, column=3, sticky = "nsew")
|
||||
btn_op_send_xrp = tk.Button(master=frm_form, text="< Send XRP",
|
||||
command = operational_send_xrp)
|
||||
btn_op_send_xrp.grid(row=2, column = 3, sticky = "nsew")
|
||||
```
|
||||
|
||||
Start the application.
|
||||
|
||||
```python
|
||||
window.mainloop()
|
||||
```
|
||||
|
||||
@@ -0,0 +1,618 @@
|
||||
---
|
||||
html: py-create-trustline-send-currency.html
|
||||
parent: quickstart-python.html
|
||||
blurb: Quickstart step 2, create trust lines and send currency.
|
||||
labels:
|
||||
- Cross-Currency
|
||||
- Payments
|
||||
- Quickstart
|
||||
- Tokens
|
||||
---
|
||||
# 2. Create Trust Line and Send Currency (Python)
|
||||
|
||||
This example shows how to:
|
||||
|
||||
1. Configure accounts to allow transfer of funds to third party accounts.
|
||||
2. Set a currency type for transactions.
|
||||
3. Create a trust line between the standby account and the operational account.
|
||||
4. Send issued currency between accounts.
|
||||
5. Display account balances for all currencies.
|
||||
|
||||
[](img/quickstart-py5.png)
|
||||
|
||||
You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/quickstart/js/quickstart.zip){.github-code-download} archive to try each of the samples in your own browser.
|
||||
|
||||
**Note:** Without the Quickstart Samples, you will not be able to try the examples that follow.
|
||||
|
||||
## Usage
|
||||
|
||||
Open the Quickstart window and get accounts:
|
||||
|
||||
1. Open and run `lesson2-send-currency.py`.
|
||||
2. Get test accounts.
|
||||
1. If you have existing account seeds
|
||||
1. Paste account seeds in the **Seeds** field.
|
||||
2. Click **Get Accounts from Seeds**.
|
||||
2. If you do not have account seeds:
|
||||
1. Click **Get New Standby Account**.
|
||||
2. Click **Get New Operational Account**.
|
||||
|
||||
## Create Trust Line
|
||||
|
||||
To create a trust line between accounts:
|
||||
|
||||
1. Enter a [currency code](https://www.iban.com/currency-codes) in the **Currency** field.
|
||||
2. Enter the maximum transfer limit in the **Amount** field.
|
||||
3. Enter the destination account value in the **Destination** field.
|
||||
4. Click **Create Trust Line**.
|
||||
|
||||
[](img/quickstart-py6.png)
|
||||
|
||||
## Send an Issued Currency Token
|
||||
|
||||
To transfer an issued currency token, once you have created a trust line:
|
||||
|
||||
1. Enter the **Amount**.
|
||||
2. Enter the **Destination**.
|
||||
3. Enter the **Currency** type.
|
||||
4. Click **Send Currency**.
|
||||
|
||||
[](img/quickstart-py7.png)
|
||||
|
||||
### Configure Account
|
||||
|
||||
When transferring fiat currency, the actual transfer of funds is not simultaneous, as it is with XRP. If currency is transferred to a third party for a different currency, there can be a devaluation of the currency that impacts the originating account. To avoid this situation, this up and down valuation of currency, known as _rippling_, is not allowed by default. Currency transferred from one account can only be transferred back to the same account. To enable currency transfer to third parties, you need to set the `rippleDefault` value to true. The Token Test Harness provides a checkbox to enable or disable rippling.
|
||||
|
||||
To enable rippling:
|
||||
|
||||
1. Select the **Allow Rippling** checkbox.
|
||||
2. Click **Configure Account**.
|
||||
|
||||
Verify the setting by looking for the _Set Flag_ value in the response, which should show a flag setting of _8_.
|
||||
|
||||
[](img/quickstart-py8.png)
|
||||
|
||||
To disable rippling:
|
||||
|
||||
1. Deselect the **Allow Rippling** checkbox.
|
||||
2. Click **Configure Account**.
|
||||
|
||||
Verify the setting by looking for the _Clear Flag_ value in the response, which shold show a flag setting of _8_.
|
||||
|
||||
[](img/quickstart-py9.png)
|
||||
|
||||
# Code Walkthrough
|
||||
|
||||
You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/quickstart/js/quickstart.zip){.github-code-download} archive to try each of the samples.
|
||||
|
||||
## mod2.py
|
||||
|
||||
Module 2 provides the logic for creating trust lines and sending issued currency tokens between accounts.
|
||||
|
||||
Import dependencies and set the `testnet_url`.
|
||||
|
||||
```python
|
||||
import xrpl
|
||||
import json
|
||||
from xrpl.clients import JsonRpcClient
|
||||
from xrpl.wallet import Wallet
|
||||
from xrpl.models.requests.account_info import AccountInfo
|
||||
|
||||
testnet_url = "https://s.altnet.rippletest.net:51234"
|
||||
```
|
||||
|
||||
### Create Trust Line
|
||||
|
||||
Pass the wallet seed, the issuer account, the currency code, and the maximum amount of currency to send.
|
||||
|
||||
```python
|
||||
def create_trust_line(seed, issuer, currency, amount):
|
||||
"""create_trust_line"""
|
||||
```
|
||||
|
||||
Get the wallet and a new client instance.
|
||||
|
||||
```python
|
||||
receiving_wallet = Wallet(seed, sequence = 16237283)
|
||||
client = JsonRpcClient(testnet_url)
|
||||
```
|
||||
|
||||
Define the `TrustSet` transaction.
|
||||
|
||||
```python
|
||||
trustline_tx=xrpl.models.transactions.TrustSet(
|
||||
account=receiving_wallet.classic_address,
|
||||
limit_amount=xrpl.models.amounts.IssuedCurrencyAmount(
|
||||
currency=currency,
|
||||
issuer=issuer,
|
||||
value=int(amount)
|
||||
)
|
||||
)
|
||||
```
|
||||
|
||||
Sign the transaction.
|
||||
|
||||
```python
|
||||
signed_tx = xrpl.transaction.safe_sign_and_autofill_transaction(
|
||||
trustline_tx, receiving_wallet, client)
|
||||
```
|
||||
|
||||
Submit the transaction to the XRP Ledger.
|
||||
|
||||
```python
|
||||
reply = ""
|
||||
try:
|
||||
response = xrpl.transaction.send_reliable_submission(signed_tx,client)
|
||||
reply = response.result
|
||||
except xrpl.transaction.XRPLReliableSubmissionException as e:
|
||||
reply = f"Submit failed: {e}"
|
||||
```
|
||||
|
||||
Return the results.
|
||||
|
||||
```python
|
||||
return reply
|
||||
```
|
||||
## send_currency
|
||||
|
||||
Send currency to another account based on the sender wallet, destination account, the currency type, and the amount of the currency.
|
||||
|
||||
```python
|
||||
def send_currency(seed, destination, currency, amount):
|
||||
"""send_currency"""
|
||||
```
|
||||
|
||||
Get the sending wallet and a client instance on Testnet.
|
||||
|
||||
```python
|
||||
sending_wallet=Wallet(seed, sequence=16237283)
|
||||
client=JsonRpcClient(testnet_url)
|
||||
```
|
||||
|
||||
Define the payment transaction. The amount requires further description to identify the type of currency and issuer.
|
||||
|
||||
```python
|
||||
send_currency_tx=xrpl.models.transactions.Payment(
|
||||
account=sending_wallet.classic_address,
|
||||
amount=xrpl.models.amounts.IssuedCurrencyAmount(
|
||||
currency=currency,
|
||||
value=int(amount),
|
||||
issuer=sending_wallet.classic_address
|
||||
),
|
||||
destination=destination
|
||||
)
|
||||
```
|
||||
|
||||
Sign and fill the transaction.
|
||||
|
||||
```python
|
||||
signed_tx=xrpl.transaction.safe_sign_and_autofill_transaction(
|
||||
send_currency_tx, sending_wallet, client)
|
||||
```
|
||||
|
||||
Submit the transaction and get the response.
|
||||
|
||||
```python
|
||||
reply = ""
|
||||
try:
|
||||
response=xrpl.transaction.send_reliable_submission(signed_tx,client)
|
||||
reply = response.result
|
||||
except xrpl.transaction.XRPLReliableSubmissionException as e:
|
||||
reply = f"Submit failed: {e}"
|
||||
```
|
||||
|
||||
Return the JSON response, or an error message if the transaction fails.
|
||||
|
||||
```python
|
||||
return reply
|
||||
```
|
||||
|
||||
### get_balance
|
||||
|
||||
Update the **XRP Balance** fields and list the balance information for issued currencies in the **Results** text areas.
|
||||
|
||||
```python
|
||||
def get_balance(sb_account_id, op_account_id):
|
||||
"""get_balance"""
|
||||
```
|
||||
|
||||
Connect to the XRP Ledger and instantiate a client.
|
||||
|
||||
```python
|
||||
JSON_RPC_URL='wss://s.altnet.rippletest.net:51234'
|
||||
client=JsonRpcClient(JSON_RPC_URL)
|
||||
```
|
||||
|
||||
Create the `GatewayBalances` request.
|
||||
|
||||
```python
|
||||
balance=xrpl.models.requests.GatewayBalances(
|
||||
account=sb_account_id,
|
||||
ledger_index="validated",
|
||||
hotwallet=[op_account_id]
|
||||
)
|
||||
```
|
||||
|
||||
Return the result.
|
||||
|
||||
```python
|
||||
response = client.request(balance)
|
||||
return response.result
|
||||
```
|
||||
|
||||
### configure_account
|
||||
|
||||
This example shows how to set and clear configuration flags using the `AccountSet` method. The `ASF_DEFAULT_RIPPLE` flag is pertinent to experimentation with transfer of issued currencies to third-party accounts, so it is demonstrated here. You can set any of the configuration flags using the same structure, substituting the particular flags you want to set. See [AccountSet Flags](accountset.html).
|
||||
|
||||
Send the account seed and a Boolean value for whether to enable or disable rippling.
|
||||
```python
|
||||
def configure_account(seed, default_setting):
|
||||
"""configure_account"
|
||||
```
|
||||
|
||||
Get the account wallet and instantiate a client.
|
||||
|
||||
```python
|
||||
wallet=Wallet(seed, sequence = 16237283)
|
||||
client=JsonRpcClient(testnet_url)
|
||||
```
|
||||
|
||||
If `default_setting` is true, create a `set_flag` transaction to enable rippling. If false, create a `clear_flag` transaction to disable rippling.
|
||||
|
||||
```python
|
||||
if (default_setting):
|
||||
setting_tx=xrpl.models.transactions.AccountSet(
|
||||
account=wallet.classic_address,
|
||||
set_flag=xrpl.models.transactions.AccountSetFlag.ASF_DEFAULT_RIPPLE
|
||||
)
|
||||
else:
|
||||
setting_tx=xrpl.models.transactions.AccountSet(
|
||||
account=wallet.classic_address,
|
||||
clear_flag=xrpl.models.transactions.AccountSetFlag.ASF_DEFAULT_RIPPLE
|
||||
)
|
||||
```
|
||||
|
||||
Sign and fill the transaction.
|
||||
|
||||
```python
|
||||
signed_tx=xrpl.transaction.safe_sign_and_autofill_transaction(
|
||||
setting_tx, wallet, client)
|
||||
```
|
||||
|
||||
Submit the transaction and get results.
|
||||
|
||||
```python
|
||||
reply = ""
|
||||
try:
|
||||
response = xrpl.transaction.send_reliable_submission(signed_tx,client)
|
||||
reply = response.result
|
||||
except xrpl.transaction.XRPLReliableSubmissionException as e:
|
||||
reply = f"Submit failed: {e}"
|
||||
```
|
||||
|
||||
Return the results.
|
||||
|
||||
```python
|
||||
return reply
|
||||
```
|
||||
|
||||
## lesson2-send-currency.py
|
||||
|
||||
This module builds on `lesson1-send-xrp.py`. Changes are noted below.
|
||||
|
||||
```python
|
||||
import tkinter as tk
|
||||
import xrpl
|
||||
import json
|
||||
```
|
||||
|
||||
Import methods from `mod2.py`.
|
||||
|
||||
```python
|
||||
from mod1 import get_account, get_account_info, send_xrp
|
||||
from mod2 import (
|
||||
create_trust_line,
|
||||
send_currency,
|
||||
get_balance,
|
||||
configure_account,
|
||||
)
|
||||
```
|
||||
|
||||
Module 2 Handlers.
|
||||
|
||||
```python
|
||||
def standby_create_trust_line():
|
||||
results = create_trust_line(ent_standby_seed.get(),
|
||||
ent_standby_destination.get(),
|
||||
ent_standby_currency.get(),
|
||||
ent_standby_amount.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def standby_send_currency():
|
||||
results = send_currency(ent_standby_seed.get(),
|
||||
ent_standby_destination.get(),
|
||||
ent_standby_currency.get(),
|
||||
ent_standby_amount.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def standby_configure_account():
|
||||
results = configure_account(
|
||||
ent_standby_seed.get(),
|
||||
standbyRippling)
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def operational_create_trust_line():
|
||||
results = create_trust_line(ent_operational_seed.get(),
|
||||
ent_operational_destination.get(),
|
||||
ent_operational_currency.get(),
|
||||
ent_operational_amount.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def operational_send_currency():
|
||||
results = send_currency(ent_operational_seed.get(),
|
||||
ent_operational_destination.get(),
|
||||
ent_operational_currency.get(),
|
||||
ent_operational_amount.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def operational_configure_account():
|
||||
results = configure_account(
|
||||
ent_operational_seed.get(),
|
||||
operationalRippling)
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def get_balances():
|
||||
results = get_balance(ent_operational_account.get(), ent_standby_account.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
results = get_balance(ent_standby_account.get(), ent_operational_account.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
# Module 1 Handlers
|
||||
def get_standby_account():
|
||||
new_wallet = get_account(ent_standby_seed.get())
|
||||
ent_standby_account.delete(0, tk.END)
|
||||
ent_standby_seed.delete(0, tk.END)
|
||||
ent_standby_account.insert(0, new_wallet.classic_address)
|
||||
ent_standby_seed.insert(0, new_wallet.seed)
|
||||
|
||||
|
||||
def get_standby_account_info():
|
||||
accountInfo = get_account_info(ent_standby_account.get())
|
||||
ent_standby_balance.delete(0, tk.END)
|
||||
ent_standby_balance.insert(0,accountInfo['Balance'])
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0",json.dumps(accountInfo, indent=4))
|
||||
|
||||
|
||||
def standby_send_xrp():
|
||||
response = send_xrp(ent_standby_seed.get(),ent_standby_amount.get(),
|
||||
ent_standby_destination.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0",json.dumps(response.result, indent=4))
|
||||
get_standby_account_info()
|
||||
get_operational_account_info()
|
||||
|
||||
|
||||
def get_operational_account():
|
||||
new_wallet = get_account(ent_operational_seed.get())
|
||||
ent_operational_account.delete(0, tk.END)
|
||||
ent_operational_account.insert(0, new_wallet.classic_address)
|
||||
ent_operational_seed.delete(0, tk.END)
|
||||
ent_operational_seed.insert(0, new_wallet.seed)
|
||||
|
||||
|
||||
def get_operational_account_info():
|
||||
accountInfo = get_account_info(ent_operational_account.get())
|
||||
ent_operational_balance.delete(0, tk.END)
|
||||
ent_operational_balance.insert(0,accountInfo['Balance'])
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0",json.dumps(accountInfo, indent=4))
|
||||
|
||||
|
||||
def operational_send_xrp():
|
||||
response = send_xrp(ent_operational_seed.get(),ent_operational_amount.get(), ent_operational_destination.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0",json.dumps(response.result,indent=4))
|
||||
get_standby_account_info()
|
||||
get_operational_account_info()
|
||||
|
||||
# Create a new window with the title "Quickstart Module 2"
|
||||
|
||||
window = tk.Tk()
|
||||
window.title("Quickstart Module 2")
|
||||
|
||||
|
||||
standbyRippling = tk.BooleanVar()
|
||||
operationalRippling = tk.BooleanVar()
|
||||
|
||||
|
||||
# Form frame
|
||||
frm_form = tk.Frame(relief=tk.SUNKEN, borderwidth=3)
|
||||
frm_form.pack()
|
||||
|
||||
# Create the Label and Entry widgets for "Standby Account"
|
||||
lbl_standy_seed = tk.Label(master=frm_form, text="Standby Seed")
|
||||
ent_standby_seed = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standby_account = tk.Label(master=frm_form, text="Standby Account")
|
||||
ent_standby_account = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standy_amount = tk.Label(master=frm_form, text="Amount")
|
||||
ent_standby_amount = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standby_destination = tk.Label(master=frm_form, text="Destination")
|
||||
ent_standby_destination = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standby_balance = tk.Label(master=frm_form, text="XRP Balance")
|
||||
ent_standby_balance = tk.Entry(master=frm_form, width=50)
|
||||
```
|
||||
|
||||
Add **Currency** field.
|
||||
|
||||
```python
|
||||
lbl_standby_currency = tk.Label(master=frm_form, text="Currency")
|
||||
ent_standby_currency = tk.Entry(master=frm_form, width=50)
|
||||
```
|
||||
|
||||
Add checkbox to **Allow Rippling**.
|
||||
|
||||
```python
|
||||
cb_standby_allow_rippling = tk.Checkbutton(master=frm_form, text="Allow Rippling", variable=standbyRippling, onvalue=True, offvalue=False)
|
||||
lbl_standby_results = tk.Label(master=frm_form,text='Results')
|
||||
text_standby_results = tk.Text(master=frm_form, height = 20, width = 65)
|
||||
|
||||
# Place field in a grid.
|
||||
lbl_standy_seed.grid(row=0, column=0, sticky="w")
|
||||
ent_standby_seed.grid(row=0, column=1)
|
||||
lbl_standby_account.grid(row=2, column=0, sticky="e")
|
||||
ent_standby_account.grid(row=2, column=1)
|
||||
lbl_standy_amount.grid(row=3, column=0, sticky="e")
|
||||
ent_standby_amount.grid(row=3, column=1)
|
||||
lbl_standby_destination.grid(row=4, column=0, sticky="e")
|
||||
ent_standby_destination.grid(row=4, column=1)
|
||||
lbl_standby_balance.grid(row=5, column=0, sticky="e")
|
||||
ent_standby_balance.grid(row=5, column=1)
|
||||
```
|
||||
|
||||
Place new UI elements.
|
||||
|
||||
```python
|
||||
lbl_standby_currency.grid(row=6, column=0, sticky="e")
|
||||
ent_standby_currency.grid(row=6, column=1)
|
||||
cb_standby_allow_rippling.grid(row=7,column=1, sticky="w")
|
||||
lbl_standby_results.grid(row=8, column=0, sticky="ne")
|
||||
text_standby_results.grid(row=8, column=1, sticky="nw")
|
||||
cb_standby_allow_rippling.select()
|
||||
|
||||
###############################################
|
||||
## Operational Account ########################
|
||||
###############################################
|
||||
|
||||
# Create the Label and Entry widgets for "Operational Account"
|
||||
lbl_operational_seed = tk.Label(master=frm_form, text="Operational Seed")
|
||||
ent_operational_seed = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_account = tk.Label(master=frm_form, text="Operational Account")
|
||||
ent_operational_account = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_amount = tk.Label(master=frm_form, text="Amount")
|
||||
ent_operational_amount = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_destination = tk.Label(master=frm_form, text="Destination")
|
||||
ent_operational_destination = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_balance = tk.Label(master=frm_form, text="XRP Balance")
|
||||
ent_operational_balance = tk.Entry(master=frm_form, width=50)
|
||||
```
|
||||
|
||||
Add field for **Currency** and checkbox to **Allow Rippling**.
|
||||
|
||||
```python
|
||||
lbl_operational_currency = tk.Label(master=frm_form, text="Currency")
|
||||
ent_operational_currency = tk.Entry(master=frm_form, width=50)
|
||||
cb_operational_allow_rippling = tk.Checkbutton(master=frm_form, text="Allow Rippling", variable=operationalRippling, onvalue=True, offvalue=False)
|
||||
lbl_operational_results = tk.Label(master=frm_form,text='Results')
|
||||
text_operational_results = tk.Text(master=frm_form, height = 20, width = 65)
|
||||
|
||||
#Place the widgets in a grid
|
||||
lbl_operational_seed.grid(row=0, column=4, sticky="e")
|
||||
ent_operational_seed.grid(row=0, column=5, sticky="w")
|
||||
lbl_operational_account.grid(row=2,column=4, sticky="e")
|
||||
ent_operational_account.grid(row=2,column=5, sticky="w")
|
||||
lbl_operational_amount.grid(row=3, column=4, sticky="e")
|
||||
ent_operational_amount.grid(row=3, column=5, sticky="w")
|
||||
lbl_operational_destination.grid(row=4, column=4, sticky="e")
|
||||
ent_operational_destination.grid(row=4, column=5, sticky="w")
|
||||
lbl_operational_balance.grid(row=5, column=4, sticky="e")
|
||||
ent_operational_balance.grid(row=5, column=5, sticky="w")
|
||||
```
|
||||
|
||||
Add elements to the UI.
|
||||
|
||||
```python
|
||||
lbl_operational_currency.grid(row=6, column=4, sticky="e")
|
||||
ent_operational_currency.grid(row=6, column=5)
|
||||
cb_operational_allow_rippling.grid(row=7,column=5, sticky="w")
|
||||
lbl_operational_results.grid(row=8, column=4, sticky="ne")
|
||||
text_operational_results.grid(row=8, column=5, sticky="nw")
|
||||
cb_operational_allow_rippling.select()
|
||||
```
|
||||
|
||||
Create the Standby Account Buttons.
|
||||
|
||||
```python
|
||||
btn_get_standby_account = tk.Button(master=frm_form, text="Get Standby Account",
|
||||
command = get_standby_account)
|
||||
btn_get_standby_account.grid(row=0, column=2, sticky = "nsew")
|
||||
btn_get_standby_account_info = tk.Button(master=frm_form,
|
||||
text="Get Standby Account Info",
|
||||
command = get_standby_account_info)
|
||||
btn_get_standby_account_info.grid(row=1, column=2, sticky = "nsew")
|
||||
btn_standby_send_xrp = tk.Button(master=frm_form, text="Send XRP >",
|
||||
command = standby_send_xrp)
|
||||
btn_standby_send_xrp.grid(row=2, column = 2, sticky = "nsew")
|
||||
```
|
||||
|
||||
Add buttons **Create Trust Line**, **Send Currency**, **Get Balances**, and **Configure Account**.
|
||||
|
||||
```python
|
||||
btn_standby_create_trust_line = tk.Button(master=frm_form,
|
||||
text="Create Trust Line",
|
||||
command = standby_create_trust_line)
|
||||
btn_standby_create_trust_line.grid(row=3, column=2, sticky = "nsew")
|
||||
btn_standby_send_currency = tk.Button(master=frm_form, text="Send Currency >",
|
||||
command = standby_send_currency)
|
||||
btn_standby_send_currency.grid(row=4, column=2, sticky = "nsew")
|
||||
btn_standby_send_currency = tk.Button(master=frm_form, text="Get Balances",
|
||||
command = get_balances)
|
||||
btn_standby_send_currency.grid(row=5, column=2, sticky = "nsew")
|
||||
btn_standby_configure_account = tk.Button(master=frm_form,
|
||||
text="Configure Account",
|
||||
command = standby_configure_account)
|
||||
btn_standby_configure_account.grid(row=7,column=0, sticky = "nsew")
|
||||
```
|
||||
|
||||
Create the Operational Account buttons.
|
||||
|
||||
```python
|
||||
btn_get_operational_account = tk.Button(master=frm_form,
|
||||
text="Get Operational Account",
|
||||
command = get_operational_account)
|
||||
btn_get_operational_account.grid(row=0, column=3, sticky = "nsew")
|
||||
btn_get_op_account_info = tk.Button(master=frm_form, text="Get Op Account Info",
|
||||
command = get_operational_account_info)
|
||||
btn_get_op_account_info.grid(row=1, column=3, sticky = "nsew")
|
||||
btn_op_send_xrp = tk.Button(master=frm_form, text="< Send XRP",
|
||||
command = operational_send_xrp)
|
||||
btn_op_send_xrp.grid(row=2, column = 3, sticky = "nsew")
|
||||
```
|
||||
|
||||
Add operational buttons **Create Trust Line**, **Send Currency**, **Get Balances**, and **Configure Account**.
|
||||
|
||||
```python
|
||||
btn_op_create_trust_line = tk.Button(master=frm_form, text="Create Trust Line",
|
||||
command = operational_create_trust_line)
|
||||
btn_op_create_trust_line.grid(row=3, column=3, sticky = "nsew")
|
||||
btn_op_send_currency = tk.Button(master=frm_form, text="< Send Currency",
|
||||
command = operational_send_currency)
|
||||
btn_op_send_currency.grid(row=4, column=3, sticky = "nsew")
|
||||
btn_op_get_balances = tk.Button(master=frm_form, text="Get Balances",
|
||||
command = get_balances)
|
||||
btn_op_get_balances.grid(row=5, column=3, sticky = "nsew")
|
||||
btn_op_configure_account = tk.Button(master=frm_form, text="Configure Account",
|
||||
command = operational_configure_account)
|
||||
btn_op_configure_account.grid(row=7,column=4, sticky = "nsew")
|
||||
```
|
||||
|
||||
# Start the application
|
||||
|
||||
```python
|
||||
window.mainloop()
|
||||
```
|
||||
649
content/tutorials/quickstart/py-mint-and-burn-nfts.md
Normal file
@@ -0,0 +1,649 @@
|
||||
---
|
||||
html: py-mint-and-burn-nfts.html
|
||||
parent: quickstart-python.html
|
||||
blurb: Quickstart step 3, mint and burn NFTs.
|
||||
labels:
|
||||
- Quickstart
|
||||
- Tokens
|
||||
- Non-fungible tokens, NFTs
|
||||
---
|
||||
|
||||
# 3. Mint and Burn NFTs (Python)
|
||||
|
||||
This example shows how to:
|
||||
|
||||
1. Mint new Non-fungible Tokens (NFTs).
|
||||
2. Get a list of existing NFTs.
|
||||
3. Delete (Burn) an NFT.
|
||||
|
||||
[](img/quickstart-py10.png)
|
||||
|
||||
# Usage
|
||||
|
||||
You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/quickstart/js/quickstart.zip){.github-code-download} archive to try the sample in your own browser.
|
||||
|
||||
## Get Accounts
|
||||
|
||||
1. Open and run `lesson3-mint-token.py`.
|
||||
2. Get test accounts.
|
||||
1. If you have existing Testnet account seeds:
|
||||
1. Paste the standby account seed in the **Standby Seed** field.
|
||||
2. Click **Get Standby Account**.
|
||||
3. Paste the operational account seed in the **Operational Seed** field.
|
||||
4. Click **Get Operational Account**.
|
||||
2. If you do not have existing Testnet accounts:
|
||||
1. Click **Get New Standby Account**.
|
||||
2. Click **Get New Operational Account**.
|
||||
3. Click **Get Standby Account Info**.
|
||||
4. Click **Get Op Account Info**.
|
||||
|
||||
[](img/quickstart-py11.png)
|
||||
|
||||
## Mint an NFT
|
||||
|
||||
To mint a non-fungible token object:
|
||||
|
||||
1. Set the **Flags** field. For testing purposes, we recommend setting the value to _8_. This sets the _tsTransferable_ flag, meaning that the NFT can be transferred to another account. Otherwise, the NFT 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 NFTs.
|
||||
2. Enter the **NFT URI**. This is a URI that points to the data or metadata associated with the NFT. You can use the sample URI provided if you do not have one of your own.
|
||||
3. Enter the **Transfer Fee**, a percentage of the proceeds from future sales of the NFT that will be returned to the original creator. This is a value of 0-50000 inclusive, allowing transfer rates between 0.000% and 50.000% in increments of 0.001%. If you do not set the **Flags** field to allow the NFT to be transferrable, set this field to 0.
|
||||
4. Optionally a **Taxon** value as an integer. If you choose not to use a taxon, enter _0_.
|
||||
4. Click **Mint NFT**.
|
||||
|
||||
[](img/quickstart-py12.png)
|
||||
|
||||
|
||||
## Get Tokens
|
||||
|
||||
Click **Get NFTs** to get a list of NFTs owned by the account.
|
||||
|
||||
[](img/quickstart-py13.png)
|
||||
|
||||
## Burn a Token
|
||||
|
||||
The current owner of an NFT can always destroy (or _burn_) an NFT.
|
||||
|
||||
To permanently destroy an NFT:
|
||||
|
||||
1. Enter the **Token ID**.
|
||||
2. Click **Burn NFT**.
|
||||
|
||||
[](img/quickstart-py14.png)
|
||||
|
||||
# Code Walkthrough
|
||||
|
||||
You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/quickstart/js/quickstart.zip){.github-code-download} archive to examine the code samples.
|
||||
|
||||
## mod3.py
|
||||
|
||||
This module contains the new methods `mint_token`, `get_tokens`, and `burn_token`.
|
||||
|
||||
Import dependencies and set global variable.
|
||||
|
||||
```python
|
||||
import xrpl
|
||||
import json
|
||||
from xrpl.clients import JsonRpcClient
|
||||
from xrpl.wallet import Wallet
|
||||
from xrpl.models.requests import AccountNFTs
|
||||
|
||||
|
||||
testnet_url = "https://s.altnet.rippletest.net:51234"
|
||||
```
|
||||
|
||||
## mintToken
|
||||
|
||||
Pass the arguments account seed, NFT URI, transaction flags, the transfer fee, and optional taxon.
|
||||
|
||||
```python
|
||||
def mint_token(seed, uri, flags, transfer_fee, taxon):
|
||||
```
|
||||
|
||||
Get the account wallet and a client instance.
|
||||
|
||||
```python
|
||||
mint_wallet=Wallet(seed, sequence=16237283)
|
||||
client=JsonRpcClient(testnet_url)
|
||||
```
|
||||
|
||||
Define the mint transaction. Note that the NFT URI must be converted to a hex string.
|
||||
|
||||
```python
|
||||
mint_tx=xrpl.models.transactions.NFTokenMint(
|
||||
account=mint_wallet.classic_address,
|
||||
uri=xrpl.utils.str_to_hex(uri),
|
||||
flags=int(flags),
|
||||
transfer_fee=int(transfer_fee),
|
||||
nftoken_taxon=int(taxon)
|
||||
)
|
||||
```
|
||||
|
||||
Sign and fill the transaction.
|
||||
|
||||
```python
|
||||
signed_tx = xrpl.transaction.safe_sign_and_autofill_transaction(
|
||||
mint_tx, mint_wallet, client)
|
||||
```
|
||||
|
||||
Submit the transaction and return results.
|
||||
|
||||
```python
|
||||
reply=""
|
||||
try:
|
||||
response=xrpl.transaction.send_reliable_submission(signed_tx,client)
|
||||
reply=response.result
|
||||
except xrpl.transaction.XRPLReliableSubmissionException as e:
|
||||
reply=f"Submit failed: {e}"
|
||||
return reply
|
||||
```
|
||||
|
||||
## getTokens
|
||||
|
||||
```python
|
||||
def get_tokens(account):
|
||||
"""get_tokens"""
|
||||
```
|
||||
|
||||
Instantiate a client.
|
||||
|
||||
```python
|
||||
client=JsonRpcClient(testnet_url)
|
||||
```
|
||||
|
||||
Prepare the `AccountNFTs` request.
|
||||
|
||||
```python
|
||||
acct_nfts=AccountNFTs(
|
||||
account=account
|
||||
)
|
||||
```
|
||||
|
||||
Send the request and return the result.
|
||||
|
||||
```python
|
||||
response=client.request(acct_nfts)
|
||||
return response.result
|
||||
```
|
||||
|
||||
## burn_token
|
||||
|
||||
Pass the owner's seed value and the NFT ID.
|
||||
|
||||
```python
|
||||
def burn_token(seed, nftoken_id):
|
||||
"""burn_token"""
|
||||
```
|
||||
|
||||
Get the owner wallet and client instance.
|
||||
|
||||
```python
|
||||
owner_wallet=Wallet(seed, sequence=16237283)
|
||||
client=JsonRpcClient(testnet_url)
|
||||
```
|
||||
|
||||
Define the NFTokenBurn transaction.
|
||||
|
||||
```python
|
||||
burn_tx=xrpl.models.transactions.NFTokenBurn(
|
||||
account=owner_wallet.classic_address,
|
||||
nftoken_id=nftoken_id
|
||||
)
|
||||
```
|
||||
|
||||
Sign and fill the transaction.
|
||||
|
||||
```python
|
||||
signed_tx=xrpl.transaction.safe_sign_and_autofill_transaction(
|
||||
burn_tx, owner_wallet, client)
|
||||
```
|
||||
|
||||
Submit the transaction and return results.
|
||||
|
||||
```python
|
||||
reply=""
|
||||
try:
|
||||
response=xrpl.transaction.send_reliable_submission(signed_tx,client)
|
||||
reply=response.result
|
||||
except xrpl.transaction.XRPLReliableSubmissionException as e:
|
||||
reply=f"Submit failed: {e}"
|
||||
return reply
|
||||
```
|
||||
|
||||
|
||||
## lesson3-mint-token.py
|
||||
<!-- SPELLING_IGNORE: lesson3 -->
|
||||
|
||||
This module builds on `lesson2-create-trustline-send-currency.py`. Changes are noted below.
|
||||
|
||||
```python
|
||||
import tkinter as tk
|
||||
import xrpl
|
||||
import json
|
||||
import tkinter as tk
|
||||
import xrpl
|
||||
import json
|
||||
|
||||
from mod1 import get_account, get_account_info, send_xrp
|
||||
from mod2 import (
|
||||
create_trust_line,
|
||||
send_currency,
|
||||
get_balance,
|
||||
configure_account,
|
||||
)
|
||||
```
|
||||
|
||||
Import methods from `mod3.py`.
|
||||
|
||||
```python
|
||||
from mod3 import (
|
||||
mint_token,
|
||||
get_tokens,
|
||||
burn_token,
|
||||
)
|
||||
|
||||
#############################################
|
||||
## Handlers #################################
|
||||
#############################################
|
||||
```
|
||||
|
||||
Module 3 Handlers
|
||||
|
||||
```python
|
||||
def standby_mint_token():
|
||||
results = mint_token(
|
||||
ent_standby_seed.get(),
|
||||
ent_standby_uri.get(),
|
||||
ent_standby_flags.get(),
|
||||
ent_standby_transfer_fee.get(),
|
||||
ent_standby_taxon.get()
|
||||
)
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def standby_get_tokens():
|
||||
results = get_tokens(ent_standby_account.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def standby_burn_token():
|
||||
results = burn_token(
|
||||
ent_standby_seed.get(),
|
||||
ent_standby_nft_id.get()
|
||||
)
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def operational_mint_token():
|
||||
results = mint_token(
|
||||
ent_operational_seed.get(),
|
||||
ent_operational_uri.get(),
|
||||
ent_operational_flags.get(),
|
||||
ent_operational_transfer_fee.get(),
|
||||
ent_operational_taxon.get()
|
||||
)
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def operational_get_tokens():
|
||||
results = get_tokens(ent_operational_account.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def operational_burn_token():
|
||||
results = burn_token(
|
||||
ent_operational_seed.get(),
|
||||
ent_operational_nft_id.get()
|
||||
)
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
# Module 2 Handlers
|
||||
|
||||
def standby_create_trust_line():
|
||||
results = create_trust_line(ent_standby_seed.get(),
|
||||
ent_standby_destination.get(),
|
||||
ent_standby_currency.get(),
|
||||
ent_standby_amount.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def standby_send_currency():
|
||||
results = send_currency(ent_standby_seed.get(),
|
||||
ent_standby_destination.get(),
|
||||
ent_standby_currency.get(),
|
||||
ent_standby_amount.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def standby_configure_account():
|
||||
results = configure_account(
|
||||
ent_standby_seed.get(),
|
||||
standbyRippling)
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def operational_create_trust_line():
|
||||
results = create_trust_line(ent_operational_seed.get(),
|
||||
ent_operational_destination.get(),
|
||||
ent_operational_currency.get(),
|
||||
ent_operational_amount.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def operational_send_currency():
|
||||
results = send_currency(ent_operational_seed.get(),
|
||||
ent_operational_destination.get(),
|
||||
ent_operational_currency.get(),
|
||||
ent_operational_amount.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def operational_configure_account():
|
||||
results = configure_account(
|
||||
ent_operational_seed.get(),
|
||||
operationalRippling)
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
|
||||
def get_balances():
|
||||
results = get_balance(ent_operational_account.get(), ent_standby_account.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0", json.dumps(results, indent=4))
|
||||
results = get_balance(ent_standby_account.get(), ent_operational_account.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0", json.dumps(results, indent=4))
|
||||
|
||||
# Module 1 Handlers
|
||||
def get_standby_account():
|
||||
new_wallet = get_account(ent_standby_seed.get())
|
||||
ent_standby_account.delete(0, tk.END)
|
||||
ent_standby_seed.delete(0, tk.END)
|
||||
ent_standby_account.insert(0, new_wallet.classic_address)
|
||||
ent_standby_seed.insert(0, new_wallet.seed)
|
||||
|
||||
|
||||
def get_standby_account_info():
|
||||
accountInfo = get_account_info(ent_standby_account.get())
|
||||
ent_standby_balance.delete(0, tk.END)
|
||||
ent_standby_balance.insert(0,accountInfo['Balance'])
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0",json.dumps(accountInfo, indent=4))
|
||||
|
||||
|
||||
def standby_send_xrp():
|
||||
response = send_xrp(ent_standby_seed.get(),ent_standby_amount.get(),
|
||||
ent_standby_destination.get())
|
||||
text_standby_results.delete("1.0", tk.END)
|
||||
text_standby_results.insert("1.0",json.dumps(response.result, indent=4))
|
||||
get_standby_account_info()
|
||||
get_operational_account_info()
|
||||
|
||||
|
||||
def get_operational_account():
|
||||
new_wallet = get_account(ent_operational_seed.get())
|
||||
ent_operational_account.delete(0, tk.END)
|
||||
ent_operational_account.insert(0, new_wallet.classic_address)
|
||||
ent_operational_seed.delete(0, tk.END)
|
||||
ent_operational_seed.insert(0, new_wallet.seed)
|
||||
|
||||
|
||||
def get_operational_account_info():
|
||||
accountInfo = get_account_info(ent_operational_account.get())
|
||||
ent_operational_balance.delete(0, tk.END)
|
||||
ent_operational_balance.insert(0,accountInfo['Balance'])
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0",json.dumps(accountInfo, indent=4))
|
||||
|
||||
|
||||
def operational_send_xrp():
|
||||
response = send_xrp(ent_operational_seed.get(),ent_operational_amount.get(), ent_operational_destination.get())
|
||||
text_operational_results.delete("1.0", tk.END)
|
||||
text_operational_results.insert("1.0",json.dumps(response.result,indent=4))
|
||||
get_standby_account_info()
|
||||
get_operational_account_info()
|
||||
```
|
||||
|
||||
Create a new window with the title "Quickstart Module 3."
|
||||
|
||||
```python
|
||||
window = tk.Tk()
|
||||
window.title("Quickstart Module 3")
|
||||
|
||||
standbyRippling = tk.BooleanVar()
|
||||
operationalRippling = tk.BooleanVar()
|
||||
|
||||
# Form frame
|
||||
frm_form = tk.Frame(relief=tk.SUNKEN, borderwidth=3)
|
||||
frm_form.pack()
|
||||
|
||||
# Create the Label and Entry widgets for "Standby Account"
|
||||
lbl_operational_seed = tk.Label(master=frm_form, text="Operational Seed")
|
||||
ent_operational_seed = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_account = tk.Label(master=frm_form, text="Operational Account")
|
||||
ent_operational_account = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_amount = tk.Label(master=frm_form, text="Amount")
|
||||
ent_operational_amount = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_destination = tk.Label(master=frm_form, text="Destination")
|
||||
ent_operational_destination = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_balance = tk.Label(master=frm_form, text="XRP Balance")
|
||||
ent_operational_balance = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_currency = tk.Label(master=frm_form, text="Currency")
|
||||
ent_operational_currency = tk.Entry(master=frm_form, width=50)
|
||||
cb_standby_allow_rippling = tk.Checkbutton(master=frm_form, text="Allow Rippling", variable=standbyRippling, onvalue=True, offvalue=False)
|
||||
```
|
||||
|
||||
Add **NFT URI**, **Flags**, **Transfer Fee**, **Taxon**, and **NFT ID** fields.
|
||||
|
||||
```python
|
||||
lbl_standby_uri = tk.Label(master=frm_form, text="NFT URI")
|
||||
ent_standby_uri = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standby_flags = tk.Label(master=frm_form, text="Flags")
|
||||
ent_standby_flags = tk.Entry(master=frm_form, width=50)
|
||||
lbl_standby_transfer_fee = tk.Label(master=frm_form, text="Transfer Fee")
|
||||
ent_standby_transfer_fee = tk.Entry(master=frm_form, width="50")
|
||||
lbl_standby_taxon = tk.Label(master=frm_form, text="Taxon")
|
||||
ent_standby_taxon = tk.Entry(master=frm_form, width="50")
|
||||
lbl_standby_nft_id = tk.Label(master=frm_form, text="NFT ID")
|
||||
ent_standby_nft_id = tk.Entry(master=frm_form, width="50")
|
||||
lbl_standby_results = tk.Label(master=frm_form,text='Results')
|
||||
text_standby_results = tk.Text(master=frm_form, height = 20, width = 65)
|
||||
|
||||
# Place field in a grid.
|
||||
lbl_standy_seed.grid(row=0, column=0, sticky="w")
|
||||
ent_standby_seed.grid(row=0, column=1)
|
||||
lbl_standby_account.grid(row=2, column=0, sticky="e")
|
||||
ent_standby_account.grid(row=2, column=1)
|
||||
lbl_standy_amount.grid(row=3, column=0, sticky="e")
|
||||
ent_standby_amount.grid(row=3, column=1)
|
||||
lbl_standby_destination.grid(row=4, column=0, sticky="e")
|
||||
ent_standby_destination.grid(row=4, column=1)
|
||||
lbl_standby_balance.grid(row=5, column=0, sticky="e")
|
||||
ent_standby_balance.grid(row=5, column=1)
|
||||
lbl_standby_currency.grid(row=6, column=0, sticky="e")
|
||||
ent_standby_currency.grid(row=6, column=1)
|
||||
cb_standby_allow_rippling.grid(row=7,column=1, sticky="w")
|
||||
```
|
||||
|
||||
Place new UI elements in the grid.
|
||||
|
||||
```python
|
||||
lbl_standby_uri.grid(row=8, column=0, sticky="e")
|
||||
ent_standby_uri.grid(row=8, column=1, sticky="w")
|
||||
lbl_standby_flags.grid(row=9, column=0, sticky="e")
|
||||
ent_standby_flags.grid(row=9, column=1, sticky="w")
|
||||
lbl_standby_transfer_fee.grid(row=10, column=0, sticky="e")
|
||||
ent_standby_transfer_fee.grid(row=10, column=1, sticky="w")
|
||||
lbl_standby_taxon.grid(row=11, column=0, sticky="e")
|
||||
ent_standby_taxon.grid(row=11, column=1, sticky="w")
|
||||
lbl_standby_nft_id.grid(row=12, column=0, sticky="e")
|
||||
ent_standby_nft_id.grid(row=12, column=1, sticky="w")
|
||||
lbl_standby_results.grid(row=13, column=0, sticky="ne")
|
||||
text_standby_results.grid(row=13, column=1, sticky="nw")
|
||||
cb_standby_allow_rippling.select()
|
||||
|
||||
###############################################
|
||||
## Operational Account ########################
|
||||
###############################################
|
||||
|
||||
# Create the Label and Entry widgets for "Operational Account"
|
||||
lbl_operational_seed = tk.Label(master=frm_form, text="Operational Seed")
|
||||
ent_operational_seed = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_account = tk.Label(master=frm_form, text="Operational Account")
|
||||
ent_operational_account = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_amount = tk.Label(master=frm_form, text="Amount")
|
||||
ent_operational_amount = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_destination = tk.Label(master=frm_form, text="Destination")
|
||||
ent_operational_destination = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_balance = tk.Label(master=frm_form, text="XRP Balance")
|
||||
ent_operational_balance = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_currency = tk.Label(master=frm_form, text="Currency")
|
||||
ent_operational_currency = tk.Entry(master=frm_form, width=50)
|
||||
cb_operational_allow_rippling = tk.Checkbutton(master=frm_form, text="Allow Rippling", variable=operationalRippling, onvalue=True, offvalue=False)
|
||||
```
|
||||
|
||||
Add fields for **NFT URI**, **Flags**, **Transfer Fee**, **Taxon**, and **NFT ID**.
|
||||
|
||||
```python
|
||||
lbl_operational_uri = tk.Label(master=frm_form, text="NFT URI")
|
||||
ent_operational_uri = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_flags = tk.Label(master=frm_form, text="Flags")
|
||||
ent_operational_flags = tk.Entry(master=frm_form, width=50)
|
||||
lbl_operational_transfer_fee = tk.Label(master=frm_form, text="Transfer Fee")
|
||||
ent_operational_transfer_fee = tk.Entry(master=frm_form, width="50")
|
||||
lbl_operational_taxon = tk.Label(master=frm_form, text="Taxon")
|
||||
ent_operational_taxon = tk.Entry(master=frm_form, width="50")
|
||||
lbl_operational_nft_id = tk.Label(master=frm_form, text="NFT ID")
|
||||
ent_operational_nft_id = tk.Entry(master=frm_form, width="50")
|
||||
lbl_operational_results = tk.Label(master=frm_form,text='Results')
|
||||
text_operational_results = tk.Text(master=frm_form, height = 20, width = 65)
|
||||
|
||||
#Place the widgets in a grid
|
||||
lbl_operational_seed.grid(row=0, column=4, sticky="e")
|
||||
ent_operational_seed.grid(row=0, column=5, sticky="w")
|
||||
lbl_operational_account.grid(row=2,column=4, sticky="e")
|
||||
ent_operational_account.grid(row=2,column=5, sticky="w")
|
||||
lbl_operational_amount.grid(row=3, column=4, sticky="e")
|
||||
ent_operational_amount.grid(row=3, column=5, sticky="w")
|
||||
lbl_operational_destination.grid(row=4, column=4, sticky="e")
|
||||
ent_operational_destination.grid(row=4, column=5, sticky="w")
|
||||
lbl_operational_balance.grid(row=5, column=4, sticky="e")
|
||||
ent_operational_balance.grid(row=5, column=5, sticky="w")
|
||||
lbl_operational_currency.grid(row=6, column=4, sticky="e")
|
||||
ent_operational_currency.grid(row=6, column=5)
|
||||
cb_operational_allow_rippling.grid(row=7,column=5, sticky="w")
|
||||
```
|
||||
|
||||
Place new UI elements in the grid.
|
||||
|
||||
```python
|
||||
lbl_operational_uri.grid(row=8, column=4, sticky="e")
|
||||
ent_operational_uri.grid(row=8, column=5, sticky="w")
|
||||
lbl_operational_flags.grid(row=9, column=4, sticky="e")
|
||||
ent_operational_flags.grid(row=9, column=5, sticky="w")
|
||||
lbl_operational_transfer_fee.grid(row=10, column=4, sticky="e")
|
||||
ent_operational_transfer_fee.grid(row=10, column=5, sticky="w")
|
||||
lbl_operational_taxon.grid(row=11, column=4, sticky="e")
|
||||
ent_operational_taxon.grid(row=11, column=5, sticky="w")
|
||||
lbl_operational_nft_id.grid(row=12, column=4, sticky="e")
|
||||
ent_operational_nft_id.grid(row=12, column=5, sticky="w")
|
||||
lbl_operational_results.grid(row=13, column=4, sticky="ne")
|
||||
text_operational_results.grid(row=13, column=5, sticky="nw")
|
||||
|
||||
cb_operational_allow_rippling.select()
|
||||
|
||||
#############################################
|
||||
## Buttons ##################################
|
||||
#############################################
|
||||
|
||||
# Create the Standby Account Buttons
|
||||
btn_get_standby_account = tk.Button(master=frm_form, text="Get Standby Account",
|
||||
command = get_standby_account)
|
||||
btn_get_standby_account.grid(row=0, column=2, sticky = "nsew")
|
||||
btn_get_standby_account_info = tk.Button(master=frm_form,
|
||||
text="Get Standby Account Info",
|
||||
command = get_standby_account_info)
|
||||
btn_get_standby_account_info.grid(row=1, column=2, sticky = "nsew")
|
||||
btn_standby_send_xrp = tk.Button(master=frm_form, text="Send XRP >",
|
||||
command = standby_send_xrp)
|
||||
btn_standby_send_xrp.grid(row=2, column = 2, sticky = "nsew")
|
||||
btn_standby_create_trust_line = tk.Button(master=frm_form,
|
||||
text="Create Trust Line",
|
||||
command = standby_create_trust_line)
|
||||
btn_standby_create_trust_line.grid(row=3, column=2, sticky = "nsew")
|
||||
btn_standby_send_currency = tk.Button(master=frm_form, text="Send Currency >",
|
||||
command = standby_send_currency)
|
||||
btn_standby_send_currency.grid(row=4, column=2, sticky = "nsew")
|
||||
btn_standby_send_currency = tk.Button(master=frm_form, text="Get Balances",
|
||||
command = get_balances)
|
||||
btn_standby_send_currency.grid(row=5, column=2, sticky = "nsew")
|
||||
btn_standby_configure_account = tk.Button(master=frm_form,
|
||||
text="Configure Account",
|
||||
command = standby_configure_account)
|
||||
```
|
||||
|
||||
Add buttons for **Mint NFT**, **Get NFTs**, and **Burn NFT**.
|
||||
|
||||
```python
|
||||
btn_standby_mint_token = tk.Button(master=frm_form, text="Mint NFT",
|
||||
command = standby_mint_token)
|
||||
btn_standby_mint_token.grid(row=8, column=2, sticky="nsew")
|
||||
btn_standby_get_tokens = tk.Button(master=frm_form, text="Get NFTs",
|
||||
command = standby_get_tokens)
|
||||
btn_standby_get_tokens.grid(row=9, column=2, sticky="nsew")
|
||||
btn_standby_burn_token = tk.Button(master=frm_form, text="Burn NFT",
|
||||
command = standby_burn_token)
|
||||
btn_standby_burn_token.grid(row=10, column=2, sticky="nsew")
|
||||
|
||||
|
||||
# Create the Operational Account Buttons
|
||||
btn_get_operational_account = tk.Button(master=frm_form,
|
||||
text="Get Operational Account",
|
||||
command = get_operational_account)
|
||||
btn_get_operational_account.grid(row=0, column=3, sticky = "nsew")
|
||||
btn_get_op_account_info = tk.Button(master=frm_form, text="Get Op Account Info",
|
||||
command = get_operational_account_info)
|
||||
btn_get_op_account_info.grid(row=1, column=3, sticky = "nsew")
|
||||
btn_op_send_xrp = tk.Button(master=frm_form, text="< Send XRP",
|
||||
command = operational_send_xrp)
|
||||
btn_op_send_xrp.grid(row=2, column = 3, sticky = "nsew")
|
||||
btn_op_create_trust_line = tk.Button(master=frm_form, text="Create Trust Line",
|
||||
command = operational_create_trust_line)
|
||||
btn_op_create_trust_line.grid(row=3, column=3, sticky = "nsew")
|
||||
btn_op_send_currency = tk.Button(master=frm_form, text="< Send Currency",
|
||||
command = operational_send_currency)
|
||||
btn_op_send_currency.grid(row=4, column=3, sticky = "nsew")
|
||||
btn_op_get_balances = tk.Button(master=frm_form, text="Get Balances",
|
||||
command = get_balances)
|
||||
btn_op_get_balances.grid(row=5, column=3, sticky = "nsew")
|
||||
btn_op_configure_account = tk.Button(master=frm_form, text="Configure Account",
|
||||
command = operational_configure_account)
|
||||
btn_op_configure_account.grid(row=7,column=4, sticky = "nsew")
|
||||
```
|
||||
Add buttons for **Mint NFT**, **Get NFTs**, and **Burn NFT**.
|
||||
|
||||
```python
|
||||
btn_op_mint_token = tk.Button(master=frm_form, text="Mint NFT",
|
||||
command = operational_mint_token)
|
||||
btn_op_mint_token.grid(row=8, column=3, sticky="nsew")
|
||||
btn_op_get_tokens = tk.Button(master=frm_form, text="Get NFTs",
|
||||
command = operational_get_tokens)
|
||||
btn_op_get_tokens.grid(row=9, column=3, sticky="nsew")
|
||||
btn_op_burn_token = tk.Button(master=frm_form, text="Burn NFT",
|
||||
command = operational_burn_token)
|
||||
btn_op_burn_token.grid(row=10, column=3, sticky="nsew")
|
||||
|
||||
# Start the application
|
||||
window.mainloop()
|
||||
```
|
||||
|
||||
57
content/tutorials/quickstart/py-quickstart-intro.md
Normal file
@@ -0,0 +1,57 @@
|
||||
---
|
||||
html: py-quickstart-intro.html
|
||||
parent: quickstart-python.html
|
||||
blurb: Use a Python test harness to send XRP, trade currencies, and mint and trade NFTs.
|
||||
labels:
|
||||
- Accounts
|
||||
- Cross-Currency
|
||||
- Non-fungible Tokens, NFTs
|
||||
- Payments
|
||||
- Quickstart
|
||||
- Tokens
|
||||
- XRP
|
||||
---
|
||||
# Quickstart Introduction (Python)
|
||||
|
||||
The XRP Ledger (XRPL) is a robust, secure, customizable service. You can create your own interface to try out the capabilities and support your specific business needs.
|
||||
|
||||
This quickstart describes a test harness interface you can build to try out the XRP Ledger. The test harness displays multiple accounts, so that you can transfer tokens from one account to the other and see the results in real time. The image below shows the Token Test Harness at the completion of step 4.
|
||||
|
||||
[](img/quickstart-py15.png)
|
||||
|
||||
That is a lot of fields and buttons, all working together to perform some significant practical tasks. But getting _started_ with the XRP Ledger is not that complicated. When you eat the elephant a bite at a time, none of the tasks are difficult to consume.
|
||||
|
||||
Typically, the example functions for interacting with the XRP Ledger involve four steps.
|
||||
|
||||
1. Connect to the XRP Ledger and instantiate your wallet.
|
||||
2. Make changes to the XRP Ledger using transactions.
|
||||
3. Get the state of accounts and tokens on the XRP Ledger using requests.
|
||||
4. Disconnect from the XRP Ledger.
|
||||
|
||||
Each lesson shows you how to build the Token Test Harness one section at a time. Each module lets you try out meaningful interactions with the test ledger, with complete Python code samples and a code walkthrough. There is also a link to the complete source code for each section that can be modified with a text editor and run in a Python environment. You can try out the examples in any order.
|
||||
|
||||
This quickstart tutorial introduces you to the API used to implement features and explore the capabilities of XRP Ledger. It does not represent _all_ of the capabilities of the API and this example is not intended for production or secure payment use.
|
||||
|
||||
Much of this is “brute force” code that sacrifices conciseness for readability. Each example builds on the previous step, adding a new Python UI file and a module to support the new behavior in the lesson. We expect the applications you build to greatly improve upon these examples. Your feedback and contributions are most welcome.
|
||||
|
||||
In this quickstart, you can:
|
||||
|
||||
1. [Create Accounts and Send XRP](py-create-accounts-send-xrp.html)
|
||||
2. [Create Trust Line and Send Currency](py-create-trustline-send-currency.html).
|
||||
3. [Mint and Burn NFTs](py-mint-and-burn-nfts.html).
|
||||
4. [Transfer NFTs](py-transfer-nfts.html).
|
||||
|
||||
There are also expanded lessons demonstrating how to [Broker an NFT Sale](py-broker-sale.html) and [Assign an Authorized Minter](py-authorize-minter.html).
|
||||
|
||||
|
||||
## Prerequisites
|
||||
|
||||
To get started, create a new folder on your local disk and install the Python library (xrpl-py) using `pip`.
|
||||
|
||||
```
|
||||
pip3 install xrpl-py
|
||||
```
|
||||
|
||||
Download the python [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/quickstart/python/){.github-code-download}.
|
||||
|
||||
**Note:** Without the Quickstart Samples, you will not be able to try the examples that follow.
|
||||
1047
content/tutorials/quickstart/py-transfer-nfts.md
Normal file
@@ -1,7 +1,7 @@
|
||||
---
|
||||
html: xrpl-quickstart.html
|
||||
parent: tutorials.html
|
||||
blurb: Use a JavaScript test harness to send XRP, trade currencies, and mint and trade NFTokens.
|
||||
html: quickstart-intro.html
|
||||
parent: quickstart-javascript.html
|
||||
blurb: Use a JavaScript test harness to send XRP, trade currencies, and mint and trade NFTs.
|
||||
labels:
|
||||
- Accounts
|
||||
- Cross-Currency
|
||||
@@ -11,7 +11,7 @@ labels:
|
||||
- Tokens
|
||||
- XRP
|
||||
---
|
||||
# XRPL Quickstart
|
||||
# Quickstart Introduction (JavaScript)
|
||||
|
||||
The XRP Ledger (XRPL) is a robust, secure, customizable service. You can create your own interface to try out the capabilities and support your specific business needs.
|
||||
|
||||
@@ -28,7 +28,7 @@ Typically, the example functions for interacting with the XRP Ledger involve fou
|
||||
3. Get the state of accounts and tokens on the XRP Ledger using requests.
|
||||
4. Disconnect from the XRP Ledger.
|
||||
|
||||
Each lesson shows you how to build the Token Test Harness one section at a time. Each module lets you try out meaningful interactions with the test ledger, with complete JavaScript and HTML code samples and a code walkthrough. There is also a link to the complete source code for each section that can be modified with a text editor and run in a browser. If you cannot wait, you can follow the prerequisites below, then jump to lesson 4, [Transfer NFTokens](transfer-nftokens.html), and try out the complete test harness right away.
|
||||
Each lesson shows you how to build the Token Test Harness one section at a time. Each module lets you try out meaningful interactions with the test ledger, with complete JavaScript and HTML code samples and a code walkthrough. There is also a link to the complete source code for each section that can be modified with a text editor and run in a browser. If you cannot wait, you can follow the prerequisites below, then jump to lesson 4, [Transfer NFTs](transfer-nfts.html), and try out the complete test harness right away.
|
||||
|
||||
This quickstart tutorial introduces you to the API used to implement features and explore the capabilities of XRP Ledger. It does not represent *all* of the capabilities of the API and this example is not intended for production or secure payment use.
|
||||
|
||||
@@ -38,10 +38,10 @@ In this quickstart, you can:
|
||||
|
||||
1. [Create Accounts and Send XRP](create-accounts-send-xrp.html)
|
||||
2. [Create Trust Line and Send Currency](create-trustline-send-currency.html).
|
||||
3. [Mint and Burn NFTokens](mint-and-burn-nftokens.html).
|
||||
4. [Transfer NFTokens](transfer-nftokens.html).
|
||||
3. [Mint and Burn NFTs](mint-and-burn-nfts.html).
|
||||
4. [Transfer NFTs](transfer-nfts.html).
|
||||
|
||||
There are also expanded lessons demonstrating how to [Broker a NFToken Sale](broker-sale.html), [Assign an Authorized Minter](authorize-minter.html), and [Batch Mint NFTokens](batch-minting.html).
|
||||
There are also expanded lessons demonstrating how to [Broker a NFT Sale](broker-sale.html), [Assign an Authorized Minter](authorize-minter.html), and [Batch Mint NFTs](batch-minting.html).
|
||||
|
||||
|
||||
## Prerequisites
|
||||
@@ -52,6 +52,6 @@ To get started, create a new folder on your local disk and install the JavaScrip
|
||||
npm install xrpl
|
||||
```
|
||||
|
||||
Download and expand the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/quickstart/js/quickstart.zip){.github-code-download} archive.
|
||||
Download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/quickstart/js/){.github-code-download}.
|
||||
|
||||
**Note:** Without the Quickstart Samples, you will not be able to try the examples that follow.
|
||||
@@ -1,25 +1,25 @@
|
||||
---
|
||||
html: transfer-nftokens.html
|
||||
parent: xrpl-quickstart.html
|
||||
blurb: Use a JavaScript test harness to send XRP, trade currencies, and mint and trade NFTokens.
|
||||
html: transfer-nfts.html
|
||||
parent: quickstart-javascript.html
|
||||
blurb: Use a JavaScript test harness to send XRP, trade currencies, and mint and trade NFTs.
|
||||
labels:
|
||||
- Quickstart
|
||||
- Tokens
|
||||
- Non-fungible Tokens, NFTs
|
||||
---
|
||||
|
||||
# 4. Transfer NFTokens
|
||||
# 4. Transfer NFTs
|
||||
|
||||
This example shows how to:
|
||||
|
||||
1. Create NFToken Sell Offers.
|
||||
2. Create NFToken Buy Offers.
|
||||
3. Accept NFToken Sell Offers.
|
||||
4. Accept NFToken Buy Offers.
|
||||
5. Get a list of offers for a particular NFToken.
|
||||
1. Create NFT Sell Offers.
|
||||
2. Create NFT Buy Offers.
|
||||
3. Accept NFT Sell Offers.
|
||||
4. Accept NFT Buy Offers.
|
||||
5. Get a list of offers for a particular NFT.
|
||||
6. Cancel an offer.
|
||||
|
||||
[](img/quickstart13.png)
|
||||
[](img/quickstart13.png)
|
||||
|
||||
You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/quickstart/js/quickstart.zip){.github-code-download} archive to try each of the samples in your own browser.
|
||||
|
||||
@@ -27,7 +27,7 @@ You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-port
|
||||
|
||||
## Get Accounts
|
||||
|
||||
1. Open `4.transfer-nftokens.html` in a browser.
|
||||
1. Open `4.transfer-nfts.html` in a browser.
|
||||
2. Choose your ledger instance (**Testnet** or **Devnet**).
|
||||
3. Get test accounts.
|
||||
1. If you have existing test account seeds
|
||||
@@ -41,56 +41,56 @@ You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-port
|
||||
|
||||
## Create a Sell Offer
|
||||
|
||||
To create a NFToken sell offer:
|
||||
To create a NFT sell offer:
|
||||
|
||||
1. Enter the **Amount** of the sell offer in drops (millionths of an XRP).
|
||||
2. Set the **Flags** field to _1_.
|
||||
3. Enter the **NFToken ID** of the NFToken you want to sell.
|
||||
3. Enter the **NFT ID** of the NFT you want to sell.
|
||||
4. Optionally, enter a number of days until **Expiration**.
|
||||
5. Click **Create Sell Offer**.
|
||||
|
||||
The important piece of information in the response is the NFToken Offer Index, labeled as `nft_offer_index`, which you use to accept the sell offer.
|
||||
The important piece of information in the response is the NFT Offer Index, labeled as `nft_offer_index`, which you use to accept the sell offer.
|
||||
|
||||
[](img/quickstart15.png)
|
||||
[](img/quickstart15.png)
|
||||
|
||||
## Accept Sell Offer
|
||||
|
||||
Once a sell offer is available, another account can opt to accept the offer and buy the NFToken.
|
||||
Once a sell offer is available, another account can opt to accept the offer and buy the NFT.
|
||||
|
||||
To accept an available sell offer:
|
||||
|
||||
1. Enter the **NFToken Offer Index** (labeled as `nft_offer_index` in the token offer results. This is different from the `NFTokenID`.)
|
||||
1. Enter the **NFT Offer Index** (labeled as `nft_offer_index` in the token offer results. This is different from the `NFTokenID`.)
|
||||
2. Click **Accept Sell Offer**.
|
||||
|
||||
[](img/quickstart16.png)
|
||||
|
||||
## Create a Buy Offer
|
||||
|
||||
You can offer to buy a NFToken from another account.
|
||||
You can offer to buy a NFT from another account.
|
||||
|
||||
To create an offer to buy a NFToken:
|
||||
To create an offer to buy a NFT:
|
||||
|
||||
1. Enter the **Amount** of your offer.
|
||||
2. Enter the **NFToken ID**.
|
||||
2. Enter the **NFT ID**.
|
||||
3. Enter the owner’s account string in the **Owner** field.
|
||||
4. Optionally enter the number of days until **Expiration**.
|
||||
5. Click **Create Buy Offer**.
|
||||
|
||||
[](img/quickstart17.png)
|
||||
[](img/quickstart17.png)
|
||||
|
||||
## Accept a Buy Offer
|
||||
|
||||
To accept an offer to buy a NFToken:
|
||||
To accept an offer to buy an NFT:
|
||||
|
||||
1. Enter the **NFToken Offer Index** (the `nft_offer_index` of the NFToken buy offer).
|
||||
1. Enter the **NFT Offer Index** (the `nft_offer_index` of the NFT buy offer).
|
||||
3. Click **Accept Buy Offer**.
|
||||
|
||||
[](img/quickstart18.png)
|
||||
|
||||
## Get Offers
|
||||
|
||||
To list the buy and sell offers associated with a NFToken:
|
||||
1. Enter the **NFToken ID**.
|
||||
To list the buy and sell offers associated with an NFT:
|
||||
1. Enter the **NFT ID**.
|
||||
2. Click **Get Offers**.
|
||||
|
||||
[](img/quickstart19.png)
|
||||
@@ -99,7 +99,7 @@ To list the buy and sell offers associated with a NFToken:
|
||||
|
||||
To cancel a buy or sell offer that you have created:
|
||||
|
||||
1. Enter the **NFToken Offer Index**.
|
||||
1. Enter the **NFT Offer Index**.
|
||||
2. Click **Cancel Offer**.
|
||||
|
||||
[](img/quickstart20.png)
|
||||
@@ -165,7 +165,7 @@ If the Expiration Date is present, append it to the transaction.
|
||||
|
||||
```
|
||||
|
||||
If the Destination field is not empty, append it to the transaction. When the destination is set, only the destination account can buy the NFToken.
|
||||
If the Destination field is not empty, append it to the transaction. When the destination is set, only the destination account can buy the NFT.
|
||||
|
||||
```javascript
|
||||
if(standbyDestinationField.value !== '') {
|
||||
@@ -1140,7 +1140,7 @@ Update the form with fields and buttons to support the new functions.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFToken URL</td>
|
||||
<td align="right">NFT URL</td>
|
||||
<td><input type="text" id="standbyTokenUrlField"
|
||||
value = "ipfs://bafybeigdyrzt5sfp7udm7hu76uh7y26nf4dfuylqabf3oclgtqy55fbzdi" size="80"/>
|
||||
</td>
|
||||
@@ -1150,11 +1150,11 @@ Update the form with fields and buttons to support the new functions.
|
||||
<td><input type="text" id="standbyFlagsField" value="1" size="10"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFToken ID</td>
|
||||
<td align="right">NFT ID</td>
|
||||
<td><input type="text" id="standbyTokenIdField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFToken Offer Index</td>
|
||||
<td align="right">NFT Offer Index</td>
|
||||
<td><input type="text" id="standbyTokenOfferIndexField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -1191,11 +1191,11 @@ Update the form with fields and buttons to support the new functions.
|
||||
<br/>
|
||||
<button type="button" onClick="getBalances()">Get Balances</button>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="mintToken()">Mint NFToken</button>
|
||||
<button type="button" onClick="mintToken()">Mint NFT</button>
|
||||
<br/>
|
||||
<button type="button" onClick="getTokens()">Get NFTokens</button>
|
||||
<button type="button" onClick="getTokens()">Get NFTs</button>
|
||||
<br/>
|
||||
<button type="button" onClick="burnToken()">Burn NFToken</button>
|
||||
<button type="button" onClick="burnToken()">Burn NFT</button>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="createSellOffer()">Create Sell Offer</button>
|
||||
<br/>
|
||||
@@ -1233,11 +1233,11 @@ Update the form with fields and buttons to support the new functions.
|
||||
<br/>
|
||||
<button type="button" onClick="getBalances()">Get Balances</button>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="oPmintToken()">Mint NFToken</button>
|
||||
<button type="button" onClick="oPmintToken()">Mint NFT</button>
|
||||
<br/>
|
||||
<button type="button" onClick="oPgetTokens()">Get NFTokens</button>
|
||||
<button type="button" onClick="oPgetTokens()">Get NFTs</button>
|
||||
<br/>
|
||||
<button type="button" onClick="oPburnToken()">Burn NFToken</button>
|
||||
<button type="button" onClick="oPburnToken()">Burn NFT</button>
|
||||
<br/><br/>
|
||||
<button type="button" onClick="oPcreateSellOffer()">Create Sell Offer</button>
|
||||
<br/>
|
||||
@@ -1325,7 +1325,7 @@ Update the form with fields and buttons to support the new functions.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFToken URL</td>
|
||||
<td align="right">NFT URL</td>
|
||||
<td><input type="text" id="operationalTokenUrlField"
|
||||
value = "ipfs://bafybeigdyrzt5sfp7udm7hu76uh7y26nf4dfuylqabf3oclgtqy55fbzdi" size="80"/>
|
||||
</td>
|
||||
@@ -1335,11 +1335,11 @@ Update the form with fields and buttons to support the new functions.
|
||||
<td><input type="text" id="operationalFlagsField" value="1" size="10"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFToken ID</td>
|
||||
<td align="right">NFT ID</td>
|
||||
<td><input type="text" id="operationalTokenIdField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">NFToken Offer Index</td>
|
||||
<td align="right">NFT Offer Index</td>
|
||||
<td><input type="text" id="operationalTokenOfferIndexField" value="" size="80"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -1248,49 +1248,136 @@ pages:
|
||||
- ja
|
||||
|
||||
# TODO: translate
|
||||
- md: tutorials/quickstart/xrpl-quickstart.md
|
||||
- name: Quickstart
|
||||
html: xrpl-quickstart.html
|
||||
parent: tutorials.html
|
||||
blurb: Quickly experiment with the basics of XRPL development.
|
||||
cta_text: Quickstart tutorials
|
||||
template: pagetype-category.html.jinja
|
||||
targets:
|
||||
- en
|
||||
- ja
|
||||
|
||||
# TODO: translate
|
||||
- name: Quickstart (JavaScript)
|
||||
html: quickstart-javascript.html
|
||||
parent: xrpl-quickstart.html
|
||||
template: pagetype-category.html.jinja
|
||||
blurb: Use a JavaScript test harness to send XRP, trade currencies, and mint and trade NFTs.
|
||||
targets:
|
||||
- en
|
||||
- ja
|
||||
|
||||
# TODO: translate
|
||||
- md: tutorials/quickstart/quickstart-intro.md
|
||||
parent: quickstart-javascript.html
|
||||
targets:
|
||||
- en
|
||||
- ja
|
||||
|
||||
# TODO: translate
|
||||
- md: tutorials/quickstart/create-accounts-send-xrp.md
|
||||
parent: quickstart-javascript.html
|
||||
targets:
|
||||
- en
|
||||
- ja
|
||||
|
||||
# TODO: translate
|
||||
- md: tutorials/quickstart/create-trustline-send-currency.md
|
||||
parent: quickstart-javascript.html
|
||||
targets:
|
||||
- en
|
||||
- ja
|
||||
|
||||
# TODO: translate
|
||||
- md: tutorials/quickstart/mint-and-burn-nftokens.md
|
||||
- md: tutorials/quickstart/mint-and-burn-nfts.md
|
||||
parent: quickstart-javascript.html
|
||||
targets:
|
||||
- en
|
||||
- ja
|
||||
|
||||
# TODO: translate
|
||||
- md: tutorials/quickstart/transfer-nftokens.md
|
||||
- md: tutorials/quickstart/transfer-nfts.md
|
||||
parent: quickstart-javascript.html
|
||||
targets:
|
||||
- en
|
||||
- ja
|
||||
|
||||
# TODO: translate
|
||||
# TODO: translate
|
||||
- md: tutorials/quickstart/broker-sale.md
|
||||
parent: quickstart-javascript.html
|
||||
targets:
|
||||
- en
|
||||
- ja
|
||||
|
||||
# TODO: translate
|
||||
- md: tutorials/quickstart/authorize-minter.md
|
||||
parent: quickstart-javascript.html
|
||||
targets:
|
||||
- en
|
||||
- ja
|
||||
|
||||
# TODO: translate
|
||||
- md: tutorials/quickstart/batch-minting.md
|
||||
parent: quickstart-javascript.html
|
||||
targets:
|
||||
- en
|
||||
- ja
|
||||
|
||||
- name: Quickstart (Python)
|
||||
html: quickstart-python.html
|
||||
parent: xrpl-quickstart.html
|
||||
template: pagetype-category.html.jinja
|
||||
blurb: Use a Python test harness to send XRP, trade currencies, and mint and trade NFTs.
|
||||
targets:
|
||||
- en
|
||||
- ja
|
||||
|
||||
# TODO: translate
|
||||
- md: tutorials/quickstart/py-quickstart-intro.md
|
||||
parent: quickstart-python.html
|
||||
targets:
|
||||
- en
|
||||
- ja
|
||||
|
||||
# TODO: translate
|
||||
- md: tutorials/quickstart/py-create-accounts-send-xrp.md
|
||||
parent: quickstart-python.html
|
||||
targets:
|
||||
- en
|
||||
- ja
|
||||
|
||||
# TODO: translate
|
||||
- md: tutorials/quickstart/py-create-trustline-send-currency.md
|
||||
parent: quickstart-python.html
|
||||
targets:
|
||||
- en
|
||||
- ja
|
||||
|
||||
# TODO: translate
|
||||
- md: tutorials/quickstart/py-mint-and-burn-nfts.md
|
||||
parent: quickstart-python.html
|
||||
targets:
|
||||
- en
|
||||
- ja
|
||||
|
||||
# TODO: translate
|
||||
- md: tutorials/quickstart/py-transfer-nfts.md
|
||||
parent: quickstart-python.html
|
||||
targets:
|
||||
- en
|
||||
- ja
|
||||
|
||||
# TODO: translate
|
||||
- md: tutorials/quickstart/py-broker-sale.md
|
||||
parent: quickstart-python.html
|
||||
targets:
|
||||
- en
|
||||
- ja
|
||||
|
||||
# TODO: translate
|
||||
- md: tutorials/quickstart/py-authorize-minter.md
|
||||
parent: quickstart-python.html
|
||||
targets:
|
||||
- en
|
||||
- ja
|
||||
|
||||
BIN
img/quickstart-py10.png
Normal file
|
After Width: | Height: | Size: 72 KiB |
BIN
img/quickstart-py11.png
Normal file
|
After Width: | Height: | Size: 117 KiB |
BIN
img/quickstart-py12.png
Normal file
|
After Width: | Height: | Size: 136 KiB |
BIN
img/quickstart-py13.png
Normal file
|
After Width: | Height: | Size: 134 KiB |
BIN
img/quickstart-py14.png
Normal file
|
After Width: | Height: | Size: 152 KiB |
BIN
img/quickstart-py15.png
Normal file
|
After Width: | Height: | Size: 91 KiB |
BIN
img/quickstart-py16.png
Normal file
|
After Width: | Height: | Size: 149 KiB |
BIN
img/quickstart-py17.png
Normal file
|
After Width: | Height: | Size: 139 KiB |
BIN
img/quickstart-py18.png
Normal file
|
After Width: | Height: | Size: 149 KiB |
BIN
img/quickstart-py19.png
Normal file
|
After Width: | Height: | Size: 177 KiB |
BIN
img/quickstart-py2.png
Normal file
|
After Width: | Height: | Size: 42 KiB |
BIN
img/quickstart-py20.png
Normal file
|
After Width: | Height: | Size: 150 KiB |
BIN
img/quickstart-py21.png
Normal file
|
After Width: | Height: | Size: 151 KiB |
BIN
img/quickstart-py22.png
Normal file
|
After Width: | Height: | Size: 154 KiB |
BIN
img/quickstart-py23.png
Normal file
|
After Width: | Height: | Size: 130 KiB |
BIN
img/quickstart-py24.png
Normal file
|
After Width: | Height: | Size: 201 KiB |
BIN
img/quickstart-py25.png
Normal file
|
After Width: | Height: | Size: 200 KiB |
BIN
img/quickstart-py26.png
Normal file
|
After Width: | Height: | Size: 216 KiB |
BIN
img/quickstart-py27.png
Normal file
|
After Width: | Height: | Size: 172 KiB |
BIN
img/quickstart-py28.png
Normal file
|
After Width: | Height: | Size: 219 KiB |
BIN
img/quickstart-py29.png
Normal file
|
After Width: | Height: | Size: 177 KiB |
BIN
img/quickstart-py3.png
Normal file
|
After Width: | Height: | Size: 87 KiB |
BIN
img/quickstart-py30.png
Normal file
|
After Width: | Height: | Size: 102 KiB |
BIN
img/quickstart-py31.png
Normal file
|
After Width: | Height: | Size: 166 KiB |
BIN
img/quickstart-py32.png
Normal file
|
After Width: | Height: | Size: 173 KiB |
BIN
img/quickstart-py33.png
Normal file
|
After Width: | Height: | Size: 154 KiB |
BIN
img/quickstart-py34.png
Normal file
|
After Width: | Height: | Size: 162 KiB |
BIN
img/quickstart-py35.png
Normal file
|
After Width: | Height: | Size: 168 KiB |
BIN
img/quickstart-py4.png
Normal file
|
After Width: | Height: | Size: 90 KiB |
BIN
img/quickstart-py5.png
Normal file
|
After Width: | Height: | Size: 56 KiB |
BIN
img/quickstart-py6.png
Normal file
|
After Width: | Height: | Size: 130 KiB |
BIN
img/quickstart-py7.png
Normal file
|
After Width: | Height: | Size: 133 KiB |
BIN
img/quickstart-py8.png
Normal file
|
After Width: | Height: | Size: 129 KiB |
BIN
img/quickstart-py9.png
Normal file
|
After Width: | Height: | Size: 129 KiB |
|
Before Width: | Height: | Size: 224 KiB After Width: | Height: | Size: 144 KiB |
|
Before Width: | Height: | Size: 199 KiB After Width: | Height: | Size: 141 KiB |
|
Before Width: | Height: | Size: 192 KiB After Width: | Height: | Size: 137 KiB |
|
Before Width: | Height: | Size: 106 KiB After Width: | Height: | Size: 94 KiB |
|
Before Width: | Height: | Size: 152 KiB After Width: | Height: | Size: 124 KiB |
|
Before Width: | Height: | Size: 190 KiB After Width: | Height: | Size: 141 KiB |
|
Before Width: | Height: | Size: 178 KiB After Width: | Height: | Size: 168 KiB |
|
Before Width: | Height: | Size: 193 KiB After Width: | Height: | Size: 166 KiB |
|
Before Width: | Height: | Size: 219 KiB After Width: | Height: | Size: 161 KiB |
|
Before Width: | Height: | Size: 206 KiB After Width: | Height: | Size: 152 KiB |
|
Before Width: | Height: | Size: 182 KiB After Width: | Height: | Size: 142 KiB |
|
Before Width: | Height: | Size: 103 KiB After Width: | Height: | Size: 84 KiB |
|
Before Width: | Height: | Size: 162 KiB After Width: | Height: | Size: 125 KiB |
|
Before Width: | Height: | Size: 191 KiB After Width: | Height: | Size: 138 KiB |
|
Before Width: | Height: | Size: 171 KiB After Width: | Height: | Size: 128 KiB |
|
Before Width: | Height: | Size: 157 KiB After Width: | Height: | Size: 114 KiB |
|
Before Width: | Height: | Size: 225 KiB After Width: | Height: | Size: 117 KiB |
|
Before Width: | Height: | Size: 207 KiB After Width: | Height: | Size: 148 KiB |
|
Before Width: | Height: | Size: 255 KiB After Width: | Height: | Size: 150 KiB |
|
Before Width: | Height: | Size: 316 KiB After Width: | Height: | Size: 174 KiB |