run prettier

This commit is contained in:
Mayukha Vadari
2026-01-12 14:19:31 -05:00
parent cae2019eb7
commit 0b247281eb
1661 changed files with 378338 additions and 65894 deletions

View File

@@ -2,9 +2,11 @@
html: build-a-desktop-wallet-in-python.html
parent: python.html
seo:
description: Build a graphical desktop wallet for the XRPL in Python.
description: Build a graphical desktop wallet for the XRPL in Python.
---
# Build a Desktop Wallet in Python
<!-- STYLE_OVERRIDE: wallet -->
This tutorial demonstrates how to build a desktop wallet for the XRP Ledger using the Python programming language and various libraries. This application can be used as a starting point for building a more complete and powerful application, as a reference point for building comparable apps, or as a learning experience to better understand how to integrate XRP Ledger functionality into a larger project.
@@ -33,9 +35,9 @@ The exact look and feel of the user interface depend on your computer's operatin
- Can view any XRP Ledger account's activity "read-only" including showing how much XRP was delivered by each transaction.
- Shows how much XRP is set aside for the account's [reserve requirement](../../../concepts/accounts/reserves.md).
- Can send [direct XRP payments](../../../concepts/payment-types/direct-xrp-payments.md), and provides feedback about the intended destination address, including:
- Whether the intended destination already exists in the XRP Ledger, or the payment would have to fund its creation.
- If the address doesn't want to receive XRP (**Disallow XRP** flag enabled).
- If the address has a [verified domain name](../../../references/xrp-ledger-toml.md#account-verification) associated with it.
- Whether the intended destination already exists in the XRP Ledger, or the payment would have to fund its creation.
- If the address doesn't want to receive XRP (**Disallow XRP** flag enabled).
- If the address has a [verified domain name](../../../references/xrp-ledger-toml.md#account-verification) associated with it.
The application in this tutorial _doesn't_ have the ability to send or trade [tokens](../../../concepts/tokens/index.md) or use other [payment types](../../../concepts/payment-types/index.md) like Escrow or Payment Channels. However, it provides a foundation that you can implement those and other features on top of.
@@ -80,7 +82,6 @@ If you have trouble installing wxPython on WSL, you can also try installing it t
python -m pip install -U -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-18.04 wxPython
```
### 1. Hello World
The first step is to build an app that combines the "hello world" equivalents for the XRP Ledger and wxPython programming. The code is as follows:
@@ -158,7 +159,6 @@ On macOS, run the [`Install Certificates.command`](https://stackoverflow.com/que
On Windows, open Edge or Chrome and browse to <https://s1.ripple.com>, then close the page. This should be enough to update your system's certificates. (It doesn't work if you use Firefox or Safari, because those browser's don't use Windows' certificate validation APIs.) <!-- SPELLING_IGNORE: s1 -->
### 3. Display an Account
**Full code for this step:** {% repo-link path="_code-samples/build-a-desktop-wallet/py/3_account.py" %}`3_account.py`{% /repo-link %}
@@ -252,7 +252,6 @@ Lastly, towards the end of the file, in the `if __name__ == "__main__":` block,
To test your wallet app with your own test account, first go to the [Testnet Faucet](/resources/dev-tools/xrp-faucets) and **Get Testnet credentials**. Save the address and secret key somewhere, and try your wallet app with either one. Then, to see balance changes, go to the [Transaction Sender](/resources/dev-tools/tx-sender) and paste your address into the **Destination Address** field. Click **Initialize** and try out some of the transaction types there, and see if the balance displayed by your wallet app updates as you expect.
### 4. Show Account's Transactions
**Full code for this step:** {% repo-link path="_code-samples/build-a-desktop-wallet/py/4_tx_history.py" %}`4_tx_history.py`{% /repo-link %}
@@ -319,7 +318,6 @@ Lastly, add a similar method to the `TWaXLFrame` to add a single transaction to
As before, you can test your wallet app with your own test account if you use the [Testnet Faucet](/resources/dev-tools/xrp-faucets) and the [Transaction Sender](/resources/dev-tools/tx-sender). On the Faucet page, select **Get Testnet credentials** (or use the same credentials from before). Input either the address or secret when you open your wallet app. On the Transaction Sender page, paste your address into the **Destination Address** field, click **Initialize**, then click various transaction buttons to see how your wallet displays the results.
### 5. Send XRP
**Full code for this step:** {% repo-link path="_code-samples/build-a-desktop-wallet/py/5_send_xrp.py" %}`5_send_xrp.py`{% /repo-link %}
@@ -409,24 +407,23 @@ You can now use your wallet to send XRP! You can even fund an entirely new accou
1. Open the Python interpreter.
```
python3
```
{% admonition type="warning" name="Caution" %}Depending on your OS, the command may be `python` or `python3`. You want to open Python 3, not a Python 2.x version.{% /admonition %}
```
python3
```
{% admonition type="warning" name="Caution" %}Depending on your OS, the command may be `python` or `python3`. You want to open Python 3, not a Python 2.x version.{% /admonition %}
2. Run the following commands in the Python interpreter:
```
import xrpl
w = xrpl.wallet.Wallet.create()
print(w.address)
print(w.seed)
exit()
```
```
import xrpl
w = xrpl.wallet.Wallet.create()
print(w.address)
print(w.seed)
exit()
```
Save the classic address and seed somewhere.
Save the classic address and seed somewhere.
3. Open your wallet app and provide a **Secret** (seed) value from an already-funded address, such as one you got from the [Testnet Faucet](/resources/dev-tools/xrp-faucets).
@@ -438,7 +435,6 @@ You can now use your wallet to send XRP! You can even fund an entirely new accou
7. You should see the balance and transaction history of your newly-funded account, matching the address you generated in the interpreter.
### 6. Domain Verification and Polish
**Full code for this step:** {% repo-link path="_code-samples/build-a-desktop-wallet/py/6_verification_and_polish.py" %}`6_verification_and_polish.py`{% /repo-link %}
@@ -527,7 +523,7 @@ The formula this code uses to calculate the maximum amount the user can send is
Test your wallet app the same way you did in the previous steps. To test domain verification, try entering the following addresses in the "To" box of the Send XRP dialog:
| Address | Domain | Verified? |
|:-------------------------------------|:-------------|:----------|
| :----------------------------------- | :----------- | :-------- |
| `rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW` | `mduo13.com` | ✅ Yes |
| `rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn` | `xrpl.org` | ❌ No |
| `rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe` | (Not set) | ❌ No |
@@ -535,19 +531,18 @@ Test your wallet app the same way you did in the previous steps. To test domain
To test X-addresses, try the following addresses:
| Address | Destination Tag | Test Net? |
|:--------------------------------------------------|:----------------|:----------|
| :------------------------------------------------ | :-------------- | :-------- |
| `T7YChPFWifjCAXLEtg5N74c7fSAYsvPKxzQAET8tbZ8q3SC` | 0 | Yes |
| `T7YChPFWifjCAXLEtg5N74c7fSAYsvJVm6xKZ14AmjegwRM` | None | Yes |
| `X7d3eHCXzwBeWrZec1yT24iZerQjYLjJrFT7A8ZMzzYWCCj` | 0 | No |
| `X7d3eHCXzwBeWrZec1yT24iZerQjYLeTFXz1GU9RBnWr7gZ` | None | No |
## Next Steps
Now that you have a functional wallet, you can take it in several new directions. The following are a few ideas:
- You could support more of the XRP Ledger's [transaction types](../../../references/protocol/transactions/types/index.md) including [tokens](../../../concepts/tokens/index.md) and [cross-currency payments](../../../concepts/payment-types/cross-currency-payments.md)
- Example code for displaying token balances and other objects: {% repo-link path="_code-samples/build-a-desktop-wallet/py/7_owned_objects.py" %}`7_owned_objects.py`{% /repo-link %}
- Example code for displaying token balances and other objects: {% repo-link path="_code-samples/build-a-desktop-wallet/py/7_owned_objects.py" %}`7_owned_objects.py`{% /repo-link %}
- Allow the user to trade in the [decentralized exchange](../../../concepts/tokens/decentralized-exchange/index.md)
- Add a way to request payments, such as with QR codes or URIs that open in your wallet.
- Support better account security including [regular key pairs](../../../concepts/accounts/cryptographic-keys.md#regular-key-pair) or [multi-signing](../../../concepts/accounts/multi-signing.md).

View File

@@ -1,8 +1,10 @@
---
seo:
description: Build a credential issuing microservice in Python.
description: Build a credential issuing microservice in Python.
---
# Build a Credential Issuing Service
_(Requires the Credentials amendment. {% not-enabled /%})_
This tutorial demonstrates how to build and use a microservice that issues [Credentials](../../../concepts/decentralized-storage/credentials.md) on the XRP Ledger, in the form of a RESTlike API, using the [Flask](https://flask.palletsprojects.com/) framework for Python.
@@ -25,16 +27,15 @@ This should install appropriate versions of Flask and xrpl-py.
To use the API that this microservice provides, you also need an HTTP client such as [Postman](https://www.postman.com/downloads/), [RESTED](https://github.com/RESTEDClient/RESTED), or [cURL](https://curl.se/).
## Overview
The Credential Issuer microservice, mostly implemented in `issuer_service.py`, provides a RESTlike API with the following methods:
| Method | Description |
|---|----|
| `POST /credential` | Request that the issuer issue a specific credential to a specific account. |
| `GET /admin/credential` | List all credentials issued by the issuer's address, optionally filtering only for credentials that have or have not been accepted by their subject. |
| `DELETE /admin/credential` | Delete a specific credential from the XRP Ledger, which revokes it. |
| Method | Description |
| -------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| `POST /credential` | Request that the issuer issue a specific credential to a specific account. |
| `GET /admin/credential` | List all credentials issued by the issuer's address, optionally filtering only for credentials that have or have not been accepted by their subject. |
| `DELETE /admin/credential` | Delete a specific credential from the XRP Ledger, which revokes it. |
{% admonition type="info" name="Note" %}Some of the methods have `/admin` in the path because they are intended to be used by the microservice's administrator. However, the sample code does not implement any authentication.{% /admonition %}
@@ -42,7 +43,6 @@ The sample code also contains a simple commmandline interface for a user account
The other files contain helper code that is used by one or both tools.
## Usage
### 1. Get Accounts
@@ -68,7 +68,7 @@ It should prompt you for your **issuer account** seed. Input the secret key you
The output should look like the following:
```txt
Issuer account seed:
Issuer account seed:
Starting credential issuer with XRPL address rJ6XzCCSapCaWZxExArkcBWLgJvT6bXCbV
* Serving Flask app 'issuer_service'
* Debug mode: off
@@ -86,13 +86,14 @@ To request a credential, make a request such as the following:
{% tabs %}
{% tab label="Summary" %}
* HTTP method: `POST`
* URL: `http://localhost:5000/credential`
{% admonition type="info" name="Note for macOS Users" %}If you specified a different port when starting the service, change `:5000` in this and other examples to match the port you specified.{% /admonition %}
* Headers:
* `Content-Type: application/json`
* Request Body:
```json
- HTTP method: `POST`
- URL: `http://localhost:5000/credential`
{% admonition type="info" name="Note for macOS Users" %}If you specified a different port when starting the service, change `:5000` in this and other examples to match the port you specified.{% /admonition %}
- Headers:
- `Content-Type: application/json`
- Request Body:
`json
{
"subject": "rGtnKx7veDhV9CgYenkiCV5HMLpgU2BfcQ",
"credential": "TestCredential",
@@ -100,26 +101,28 @@ To request a credential, make a request such as the following:
"reason": "please"
}
}
```
{% /tab %}
`
{% /tab %}
{% tab label="cURL" %}
```sh
curl -H "Content-Type: application/json" -X POST -d '{"subject": "rGtnKx7veDhV9CgYenkiCV5HMLpgU2BfcQ", "credential": "TestCredential", "documents": {"reason": "please"}}' http://localhost:5000/credential
```
{% /tab %}
{% /tabs %}
The parameters of the JSON request body should be as follows:
| Field | Type | Required? | Description |
|---|---|---|---|
| `subject` | String - Address | Yes | The XRPL classic address of the subject of the credential. Set this to the address that you generated at the start of this tutorial for the credential holder account. |
| `credential` | String | Yes | The type of credential to issue. The example microservice accepts any string consisting of alphanumeric characters as well as the special characters underscore (`_`), dash (`-`), and period (`.`), with a minimum length of 1 and a maximum length of 64 characters. |
| `documents` | Object | Yes | As a credential issuer, you typically need to verify some confidential information about someone before you issue them a credential. As a placeholder, the sample code checks for a nested field named `reason` that contains the string `please`. |
| `expiration` | String - ISO8601 Datetime | No | The time after which the credential expires, such as `2025-12-31T00:00:00Z`. |
| `uri` | String | No | Optional URI data to store with the credential. This data will become public on the XRP Ledger. If provided, this must be a string with minimum length 1 and max length 256, consisting of only characters that are valid in URIs, which are numbers, letters, and the following special characters: `-._~:/?#[]@!$&'()*+,;=%`. Conventionally, it should link to a Verifiable Credential document as defined by the W3C. |
| Field | Type | Required? | Description |
| ------------ | ------------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `subject` | String - Address | Yes | The XRPL classic address of the subject of the credential. Set this to the address that you generated at the start of this tutorial for the credential holder account. |
| `credential` | String | Yes | The type of credential to issue. The example microservice accepts any string consisting of alphanumeric characters as well as the special characters underscore (`_`), dash (`-`), and period (`.`), with a minimum length of 1 and a maximum length of 64 characters. |
| `documents` | Object | Yes | As a credential issuer, you typically need to verify some confidential information about someone before you issue them a credential. As a placeholder, the sample code checks for a nested field named `reason` that contains the string `please`. |
| `expiration` | String - ISO8601 Datetime | No | The time after which the credential expires, such as `2025-12-31T00:00:00Z`. |
| `uri` | String | No | Optional URI data to store with the credential. This data will become public on the XRP Ledger. If provided, this must be a string with minimum length 1 and max length 256, consisting of only characters that are valid in URIs, which are numbers, letters, and the following special characters: `-._~:/?#[]@!$&'()*+,;=%`. Conventionally, it should link to a Verifiable Credential document as defined by the W3C. |
This microservice immediately issues any credential that the user requests. A successful response from the API uses the HTTP status code `201 Created` and has a response body with the result of submitting the transaction to the XRP Ledger. You can use the `hash` or `ctid` value from the response to look up the transaction using an explorer such as [https://devnet.xrpl.org/](https://devnet.xrpl.org/).
@@ -132,15 +135,18 @@ To show a list of credentials issued by the issuing account, make the following
{% tabs %}
{% tab label="Summary" %}
* HTTP method: `GET`
* URL: `http://localhost:5000/admin/credential`
* Query parameters (optional): Use `?accepted=yes` to filter results to only credentials that the subject has accepted, or `?accepted=no` for credentials the user has not accepted.
{% /tab %}
- HTTP method: `GET`
- URL: `http://localhost:5000/admin/credential`
- Query parameters (optional): Use `?accepted=yes` to filter results to only credentials that the subject has accepted, or `?accepted=no` for credentials the user has not accepted.
{% /tab %}
{% tab label="cURL" %}
```sh
curl http://localhost:5000/admin/credential
```
{% /tab %}
{% /tabs %}
@@ -190,33 +196,36 @@ To revoke an issued credential, make a request such as the following:
{% tabs %}
{% tab label="Summary" %}
* HTTP method: `DELETE`
* URL: `http://localhost:5000/admin/credential`
* Headers:
* `Content-Type: application/json`
* Request Body:
```json
- HTTP method: `DELETE`
- URL: `http://localhost:5000/admin/credential`
- Headers:
- `Content-Type: application/json`
- Request Body:
`json
{
"subject": "rGtnKx7veDhV9CgYenkiCV5HMLpgU2BfcQ",
"credential": "TestCredential"
}
```
{% /tab %}
`
{% /tab %}
{% tab label="cURL" %}
```sh
curl -H "Content-Type: application/json" -X DELETE -d '{"subject": "rGtnKx7veDhV9CgYenkiCV5HMLpgU2BfcQ", "credential": "TestCredential"}' http://localhost:5000/admin/credential
```
{% /tab %}
{% /tabs %}
The parameters of the JSON request body should be as follows:
| Field | Type | Required? | Description |
|---|---|---|---|
| `subject` | String - Address | Yes | The XRPL classic address of the subject of the credential to revoke. |
| `credential` | String | Yes | The type of credential to revoke. This must match a credential type previously issued. |
| Field | Type | Required? | Description |
| ------------ | ---------------- | --------- | -------------------------------------------------------------------------------------- |
| `subject` | String - Address | Yes | The XRPL classic address of the subject of the credential to revoke. |
| `credential` | String | Yes | The type of credential to revoke. This must match a credential type previously issued. |
A successful response from the API uses the HTTP status code `200 OK` and has a response body with the result of submitting the transaction to the XRP Ledger. You can use the `hash` or `ctid` value from the response to look up the transaction using an explorer.
@@ -224,17 +233,17 @@ A successful response from the API uses the HTTP status code `200 OK` and has a
The code for this tutorial is divided among the following files:
| File | Purpose |
|---|---|
| `accept_credential.py` | Commandline interface for a credential subject to look up and accept Credentials. |
| `credential_mode.py` | A model class for Credentials that validates user input, and maps between the microservice's simplified Credential format and the full XRPL representation of Credentials. |
| `decode_hex.py` | A helper function for decoding hexadecimal into human-readable strings, used by both the credential issuer and holder. |
| `issuer_service.py` | Defines the microservice as a Flask app, including API methods and error handling. |
| `look_up_credentials.py` | A helper function for looking up Credentials tied to an account, including pagination and filtering, used by both the credential issuer and holder. |
| File | Purpose |
| ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `accept_credential.py` | Commandline interface for a credential subject to look up and accept Credentials. |
| `credential_mode.py` | A model class for Credentials that validates user input, and maps between the microservice's simplified Credential format and the full XRPL representation of Credentials. |
| `decode_hex.py` | A helper function for decoding hexadecimal into human-readable strings, used by both the credential issuer and holder. |
| `issuer_service.py` | Defines the microservice as a Flask app, including API methods and error handling. |
| `look_up_credentials.py` | A helper function for looking up Credentials tied to an account, including pagination and filtering, used by both the credential issuer and holder. |
### accept_credential.py
This file is meant to be run as a commandline tool so it starts with a [shebang](https://en.wikipedia.org/wiki/Shebang_(Unix)), followed by dependencies grouped by type: standard lib, then PyPI packages, and local files last.
This file is meant to be run as a commandline tool so it starts with a [shebang](<https://en.wikipedia.org/wiki/Shebang_(Unix)>), followed by dependencies grouped by type: standard lib, then PyPI packages, and local files last.
{% code-snippet file="/_code-samples/issue-credentials/py/accept_credential.py" language="py" before="XRPL_SERVER =" /%}

View File

@@ -1,6 +1,6 @@
---
seo:
description: Build a Python app that interacts with the XRP Ledger.
description: Build a Python app that interacts with the XRP Ledger.
top_nav_name: Python
top_nav_grouping: Get Started
labels:
@@ -9,7 +9,7 @@ labels:
{% code-walkthrough
filesets=[
{
{
"files": ["/_code-samples/get-started/py/get-acct-info.py"],
"downloadAssociatedFiles": ["/_code-samples/get-started/py/requirements.txt","/_code-samples/get-started/py/get-acct-info.py", "/_code-samples/get-started/py/README.md"]
}
@@ -48,6 +48,7 @@ Click **Download** on the top right of the code preview panel to download the so
Follow the steps to create a simple application with `xrpl-py`.
{% step id="import-tag" %}
### 1. Install Dependencies
Start a new project by creating an empty folder, then move into that folder and set up a Python virtual environment with the necessary dependencies:
@@ -68,11 +69,13 @@ python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
```
{% /step %}
### 2. Connect to the XRP Ledger
{% step id="connect-tag" %}
#### Connect to the XRP Ledger Testnet
To make queries and submit transactions, you need to connect to the XRP Ledger. To do this with `xrpl-py`, use the [`xrp.clients` module](https://xrpl-py.readthedocs.io/en/latest/source/xrpl.clients.html).
@@ -85,30 +88,33 @@ The sample code shows you how to connect to the Testnet, which is one of the ava
{% /step %}
{% step id="connect-mainnet-tag"%}
#### Connect to the XRP Ledger Mainnet
The sample code in the previous section shows you how to connect to the Testnet, which is a [parallel network](../../../concepts/networks-and-servers/parallel-networks.md) for testing where the money has no real value. When you're ready to integrate with the production XRP Ledger, you'll need to connect to the Mainnet. You can do that in two ways:
- By [installing the core server](../../../infrastructure/installation/index.md) (`rippled`) and running a node yourself. The core server connects to the Mainnet by default, but you can [change the configuration to use Testnet or Devnet](../../../infrastructure/configuration/connect-your-rippled-to-the-xrp-test-net.md). [There are good reasons to run your own core server](../../../concepts/networks-and-servers/index.md#reasons-to-run-your-own-server). If you run your own server, you can connect to it like so:
```python
from xrpl.clients import JsonRpcClient
JSON_RPC_URL = "http://localhost:5005/"
client = JsonRpcClient(JSON_RPC_URL)
```
```python
from xrpl.clients import JsonRpcClient
JSON_RPC_URL = "http://localhost:5005/"
client = JsonRpcClient(JSON_RPC_URL)
```
See the example [core server config file](https://github.com/XRPLF/rippled/blob/c0a0b79d2d483b318ce1d82e526bd53df83a4a2c/cfg/rippled-example.cfg#L1562) for more information about default values.
See the example [core server config file](https://github.com/XRPLF/rippled/blob/c0a0b79d2d483b318ce1d82e526bd53df83a4a2c/cfg/rippled-example.cfg#L1562) for more information about default values.
- By using one of the available [public servers][]:
```python
from xrpl.clients import JsonRpcClient
JSON_RPC_URL = "https://s2.ripple.com:51234/"
client = JsonRpcClient(JSON_RPC_URL)
```
{% /step %}
```python
from xrpl.clients import JsonRpcClient
JSON_RPC_URL = "https://s2.ripple.com:51234/"
client = JsonRpcClient(JSON_RPC_URL)
```
{% /step %}
{% step id="get-account-create-wallet-tag" %}
### 3. Get account
To store value and execute transactions on the XRP Ledger, you need an account: a [set of keys](../../../concepts/accounts/cryptographic-keys.md#key-components) and an [address](../../../concepts/accounts/addresses.md) that's been [funded with enough XRP](../../../concepts/accounts/index.md#creating-accounts) to meet the [account reserve](../../../concepts/accounts/reserves.md). The address is the identifier of your account and you use the [private key](../../../concepts/accounts/cryptographic-keys.md#private-key) to sign transactions that you submit to the XRP Ledger.
@@ -121,6 +127,7 @@ To create and fund an account on the Testnet, `xrpl-py` provides the [`generate_
{% /step %}
{% step id="query-xrpl-tag" %}
### 4. Query the XRP Ledger
You can query the XRP Ledger to get information about [a specific account](../../../references/http-websocket-apis/public-api-methods/account-methods/index.md), [a specific transaction](../../../references/http-websocket-apis/public-api-methods/transaction-methods/tx.md), the state of a [current or a historical ledger](../../../references/http-websocket-apis/public-api-methods/ledger-methods/index.md), and [the XRP Ledger's decentralized exchange](../../../references/http-websocket-apis/public-api-methods/path-and-order-book-methods/index.md). You need to make these queries, among other reasons, to look up account info to follow best practices for [reliable transaction submission](../../../concepts/transactions/reliable-transaction-submission.md).
@@ -129,6 +136,7 @@ Use the [account_info method][] to look up information about the account you got
{% /step %}
{% step id="run-app-tag" %}
### 5. Run the Application
Finally, in your terminal, run the application like so:
@@ -144,7 +152,7 @@ Creating a new wallet and funding it with Testnet XRP...
Attempting to fund address ravbHNootpSNQkxyEFCWevSkHsFGDHfyop
Faucet fund successful.
Wallet: ravbHNootpSNQkxyEFCWevSkHsFGDHfyop
Account Testnet Explorer URL:
Account Testnet Explorer URL:
https://testnet.xrpl.org/accounts/ravbHNootpSNQkxyEFCWevSkHsFGDHfyop
Getting account info...
@@ -195,18 +203,18 @@ For a detailed description of every response field, see [account_info](../../../
## See Also
- **Concepts:**
- [XRP Ledger Overview](/about/)
- [Client Libraries](../../../references/client-libraries.md)
- [XRP Ledger Overview](/about/)
- [Client Libraries](../../../references/client-libraries.md)
- **Tutorials:**
- [Send XRP](../../how-tos/send-xrp.md)
- [Issue a Fungible Token](../../how-tos/use-tokens/issue-a-fungible-token.md)
- [Set up Secure Signing](../../../concepts/transactions/secure-signing.md)
- [Send XRP](../../how-tos/send-xrp.md)
- [Issue a Fungible Token](../../how-tos/use-tokens/issue-a-fungible-token.md)
- [Set up Secure Signing](../../../concepts/transactions/secure-signing.md)
- **References:**
- [`xrpl-py` Reference](https://xrpl-py.readthedocs.io/en/latest/)
- [Public API Methods](../../../references/http-websocket-apis/public-api-methods/index.md)
- [API Conventions](../../../references/http-websocket-apis/api-conventions/index.md)
- [base58 Encodings](../../../references/protocol/data-types/base58-encodings.md)
- [Transaction Formats](../../../references/protocol/transactions/index.md)
- [`xrpl-py` Reference](https://xrpl-py.readthedocs.io/en/latest/)
- [Public API Methods](../../../references/http-websocket-apis/public-api-methods/index.md)
- [API Conventions](../../../references/http-websocket-apis/api-conventions/index.md)
- [base58 Encodings](../../../references/protocol/data-types/base58-encodings.md)
- [Transaction Formats](../../../references/protocol/transactions/index.md)
{% raw-partial file="/docs/_snippets/common-links.md" /%}

View File

@@ -5,8 +5,9 @@ top_nav_grouping: Article Types
metadata:
indexPage: true
seo:
description: Build full-featured applications in Python.
description: Build full-featured applications in Python.
---
# Build Applications in Python
Build full-featured applications in Python

View File

@@ -2,8 +2,9 @@
metadata:
indexPage: true
seo:
description: Transact with confidence using the XRP Ledger's suite of compliance features for following government regulations and security practices.
description: Transact with confidence using the XRP Ledger's suite of compliance features for following government regulations and security practices.
---
# Transact with Confidence Using Compliance Features
The XRP Ledger has a rich suite of features designed to help financial institutions of all sizes engage with DeFi technology while complying with government regulations domestically and internationally.

View File

@@ -1,9 +1,10 @@
---
seo:
description: Verify that an account holds a valid credential on the XRP Ledger.
description: Verify that an account holds a valid credential on the XRP Ledger.
labels:
- Credentials
- Credentials
---
# Verify Credentials in Python
This tutorial describes how to verify that an account holds a valid [credential](/docs/concepts/decentralized-storage/credentials) on the XRP Ledger, which has different use cases depending on the type of credential and the meaning behind it. A few possible reasons to verify a credential include:
@@ -19,7 +20,7 @@ This tutorial uses sample code in Python using the [xrpl-py library](../index.md
- You must have Python installed and know how to run Python code from the command line. Python 3.8 or later is required for xrpl-py.
- You should have a basic understanding of the XRP Ledger.
- The credential you want to verify should exist in the ledger already, and you should know the addresses of both the issuer and the holder, as well as the official credential type you want to check.
- For sample code showing how to create credentials, see [Build a Credential Issuing Service](../build-apps/credential-issuing-service.md).
- For sample code showing how to create credentials, see [Build a Credential Issuing Service](../build-apps/credential-issuing-service.md).
## Setup
@@ -91,6 +92,7 @@ The following examples show other possible scenarios. The data for these example
{% tabs %}
{% tab label="Valid with Expiration" %}
```text
$ ./verify_credential.py rEzikzbnH6FQJ2cCr4Bqmf6c3jyWLzkonS rs9DtpwyCSGMCyxiYEvVG29ZXo99iFjZ9S long_lasting_credential
@@ -104,9 +106,11 @@ Looking up validated ledger to check for expiration.
Most recent validated ledger is: 2025-03-11T20:01:51+00:00
Credential is valid.
```
{% /tab %}
{% tab label="Expired" %}
```text
$ ./verify_credential.py rEzikzbnH6FQJ2cCr4Bqmf6c3jyWLzkonS rs9DtpwyCSGMCyxiYEvVG29ZXo99iFjZ9S expiring_credential
@@ -120,9 +124,11 @@ Looking up validated ledger to check for expiration.
Most recent validated ledger is: 2025-03-11T20:02:03+00:00
Credential is expired.
```
{% /tab %}
{% tab label="Unaccepted" %}
```text
$ ./verify_credential.py rEzikzbnH6FQJ2cCr4Bqmf6c3jyWLzkonS rs9DtpwyCSGMCyxiYEvVG29ZXo99iFjZ9S unaccepted_credential
@@ -133,8 +139,10 @@ Found credential:
{'CredentialType': '756E61636365707465645F63726564656E7469616C', 'Flags': 0, 'Issuer': 'rEzikzbnH6FQJ2cCr4Bqmf6c3jyWLzkonS', 'IssuerNode': '0', 'LedgerEntryType': 'Credential', 'PreviousTxnID': '59DB4B17E5552AB1CA1E2A89F5C03E51C2ACD0D293955FA701AE4A1801E94C96', 'PreviousTxnLgrSeq': 997107, 'Subject': 'rs9DtpwyCSGMCyxiYEvVG29ZXo99iFjZ9S', 'SubjectNode': '0', 'index': '8E5AD9444D566BE5C6F87C94D696139CEEE43ACB9A96137A59C003B48DF565C6'}
Credential is not accepted.
```
{% /tab %}
{% tab label="Hexadecimal Credential Type" %}
```text
$ ./verify_credential.py rEzikzbnH6FQJ2cCr4Bqmf6c3jyWLzkonS rsYhHbanGpnYe3M6bsaMeJT5jnLTfDEzoA 6D795F63726564656E7469616C -b
@@ -144,16 +152,16 @@ Found credential:
{'CredentialType': '6D795F63726564656E7469616C', 'Flags': 65536, 'Issuer': 'rEzikzbnH6FQJ2cCr4Bqmf6c3jyWLzkonS', 'IssuerNode': '0', 'LedgerEntryType': 'Credential', 'PreviousTxnID': '7D1257779E2D298C07C7E0C73CD446534B143FBD1F13DB268A878E40FD153B9A', 'PreviousTxnLgrSeq': 803275, 'Subject': 'rsYhHbanGpnYe3M6bsaMeJT5jnLTfDEzoA', 'SubjectNode': '0', 'index': '9603F0E204A8B1C61823625682EB0ECE98A4ECF22FF46CD4845FA9BFA3606B24'}
Credential is valid.
```
{% /tab %}
{% /tabs %}
## Code Walkthrough
### 1. Initial setup
The `verify_credential.py` file implements the code for this tutorial.
This file can be run as a commandline tool, so it starts with a [shebang](https://en.wikipedia.org/wiki/Shebang_(Unix)). Then it imports dependencies, with standard lib first and then specific parts of the `xrpl-py` library:
The `verify_credential.py` file implements the code for this tutorial.
This file can be run as a commandline tool, so it starts with a [shebang](<https://en.wikipedia.org/wiki/Shebang_(Unix)>). Then it imports dependencies, with standard lib first and then specific parts of the `xrpl-py` library:
{% code-snippet file="/_code-samples/verify-credential/py/verify_credential.py" language="py" before="# Set up logging" /%}

View File

@@ -5,6 +5,7 @@ top_nav_grouping: Article Types
metadata:
indexPage: true
---
# Python
You can create your own interface to try out the capabilities and support your specific business needs. These tutorials build a test harness interface to try out features of the XRP Ledger. The harness displays multiple accounts, so that you can transfer tokens from one account to the other and see the results in real time.
@@ -23,14 +24,13 @@ Once familiar with the library functions, you can build sample applications in P
To get started:
- Create a new folder on your local disk and install the Python library (xrpl-py) using pip.
<br/><br/>
`pip3 install xrpl-py`
<br/><br/>
`pip3 install xrpl-py`
- Clone or download the [Sample modules](https://github.com/XRPLF/xrpl-dev-portal/tree/master/_code-samples/quickstart/py/).
**Note**: Without the sample modules, you won't be able to try the examples that follow.
## Tutorial Modules
{% child-pages /%}
{% child-pages /%}

View File

@@ -2,7 +2,7 @@
html: py-authorize-minter.html
parent: nfts-using-python.html
seo:
description: Authorize another account to mint NFTs for you.
description: Authorize another account to mint NFTs for you.
labels:
- Accounts
- Quickstart
@@ -29,19 +29,19 @@ You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-port
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**.
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
<div align="center">
@@ -62,13 +62,13 @@ This example uses the Operational account, which was authorized in the previous
To mint a non-fungible token for another account:
1. Set the **Flags** field. For testing purposes, we recommend setting the value to _8_.
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.
5. Copy the **Standby Account** value.
6. Paste the **Standby Account** value in the Operational account **Issuer** field.
7. Click the Operational account **Mint Other** button.
[![Minted NFT for Another Account](/docs/img/quickstart-py32.png)](/docs/img/quickstart-py32.png)
@@ -143,7 +143,7 @@ Define the AccountSet transaction that grants permission to another account to m
account=granter_wallet.address,
nftoken_minter=minter,
set_flag=xrpl.models.transactions.AccountSetAsfFlag.ASF_AUTHORIZED_NFTOKEN_MINTER
)
)
```
Submit the transaction and return the results.
@@ -163,7 +163,7 @@ Submit the transaction and return the results.
Get the minter wallet and instantiate a client connection to the XRP ledger.
``` python
```python
def mint_other(seed, uri, flags, transfer_fee, taxon, issuer):
"""mint_other"""
minter_wallet=Wallet.from_seed(seed)
@@ -705,7 +705,7 @@ lbl_operational_expiration = tk.Label(master=frm_form, text="Expiration")
ent_operational_expiration = tk.Entry(master=frm_form, width="50")
```
Add *Authorized Minter* and *Issuer* fields to the Operational side of the form.
Add _Authorized Minter_ and _Issuer_ fields to the Operational side of the form.
```python
lbl_operational_auth_minter = tk.Label(master=frm_form, text="Authorized Minter")
@@ -747,7 +747,7 @@ lbl_operational_expiration.grid(row=15, column=4, sticky="ne")
ent_operational_expiration.grid(row=15, column=5, sticky="w")
```
Add *Authorized Minter* and *Issuer* fields to the Operational grid.
Add _Authorized Minter_ and _Issuer_ fields to the Operational grid.
```python
lbl_operational_auth_minter.grid(row=16, column=4, sticky="ne")
@@ -817,7 +817,7 @@ btn_standby_cancel_offer = tk.Button(master=frm_form, text="Cancel Offer",
btn_standby_cancel_offer.grid(row=16, column=2, sticky="nsew")
```
Add buttons for *Set Minter* and *Mint Other* to the Standby side of the form.
Add buttons for _Set Minter_ and _Mint Other_ to the Standby side of the form.
```python
btn_standby_set_minter = tk.Button(master=frm_form, text="Set Minter",
@@ -881,7 +881,7 @@ btn_op_cancel_offer = tk.Button(master=frm_form, text="Cancel Offer",
btn_op_cancel_offer.grid(row=16, column=3, sticky="nsew")
```
Add *Set Minter* and *Mint Other* buttons to the Operational side of the form.
Add _Set Minter_ and _Mint Other_ buttons to the Operational side of the form.
```python
btn_op_set_minter = tk.Button(master=frm_form, text="Set Minter",

View File

@@ -2,7 +2,7 @@
html: py-batch-minting.html
parent: nfts-using-python.html
seo:
description: Mint multiple NFTs with the press of a button.
description: Mint multiple NFTs with the press of a button.
labels:
- Accounts
- Quickstart
@@ -26,20 +26,19 @@ You can download or clone the [Quickstart Samples](https://github.com/XRPLF/xrpl
1. Open and run `lesson7-batch-minting.py`.
2. Get a test account.
1. If you want to use an existing account seed:
1. Paste the account seed in the **Standby Seed** field.
2. Click **Get Standby Account**.
2. If you do not want to use an existing account seed, just click **Get Standby Account**.
1. If you want to use an existing account seed:
1. Paste the account seed in the **Standby Seed** field.
2. Click **Get Standby Account**.
2. If you do not want to use an existing account seed, just click **Get Standby Account**.
3. Click **Get Standby Account Info** to get the current XRP balance.
## Batch Mint NFTs
<div align="center">
<iframe width="560" height="315" src="https://www.youtube.com/embed/NjEqEWcqhwc?si=E8ws75gts_7TtOuU" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
</div>
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.
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 non-fungible token objects:
@@ -60,7 +59,7 @@ The difference between this function and the `getTokens()` function used earlier
You can download or clone the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/_code-samples/quickstart/py/)to try each of the samples locally.
Import dependencies and define the testnet_url variable.
Import dependencies and define the testnet_url variable.
```python
import xrpl
@@ -89,14 +88,14 @@ Get the account wallet and a client instance.
Request the full account info.
```python
```python
acct_info = xrpl.models.requests.account_info.AccountInfo(
account=wallet.classic_address,
ledger_index='validated'
)
get_seq_request = client.request(acct_info)
```
```
Parse the current sequence value.
@@ -110,7 +109,7 @@ Create a transaction to create tickets, starting at the current sequence number.
ticket_tx=xrpl.models.transactions.TicketCreate(
account=wallet.address,
ticket_count=int(count),
sequence=current_sequence
sequence=current_sequence
)
```
@@ -165,13 +164,14 @@ Use a `for` loop to send repeated mint requests, using the `ticket_sequence` fie
nftoken_taxon=int(taxon)
)
```
Submit each transaction and report the results.
```python
try:
response=xrpl.transaction.submit_and_wait(mint_tx,client,
wallet)
create_count+=1
create_count+=1
except xrpl.transaction.XRPLReliableSubmissionException as e:
reply+=f"Submit failed: {e}\n"
reply+=str(create_count)+' NFTs generated.'

View File

@@ -2,7 +2,7 @@
html: py-broker-sale.html
parent: nfts-using-python.html
seo:
description: Broker a sale between a sell offer and a buy offer.
description: Broker a sale between a sell offer and a buy offer.
labels:
- Accounts
- Quickstart
@@ -30,20 +30,20 @@ You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-port
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**.
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**.
3. Click **Get Operational Account**.
3. Click **Get Broker Account Info**.
4. Click **Get Standby Account Info**.
5. Click **Get Operational Account Info**.
[![Quickstart form with Account Information](/docs/img/quickstart-py24.png)](/docs/img/quickstart-py24.png)
@@ -54,22 +54,21 @@ You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-port
</div>
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.
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.
[![Sell Offer with Destination](/docs/img/quickstart25.png)](/docs/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 owners account string in the **Owner** field.
4. Optionally enter the number of seconds until **Expiration**.
5. Click **Create Buy Offer**.
1. Enter the **Amount** of your offer.
2. Enter the **NFT ID**.
3. Enter the owners account string in the **Owner** field.
4. Optionally enter the number of seconds until **Expiration**.
5. Click **Create Buy Offer**.
[![Buy Offer](/docs/img/quickstart-py26.png)](/docs/img/quickstart-py26.png)
@@ -89,7 +88,6 @@ You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-port
[![Brokered Sale](/docs/img/quickstart-py28.png)](/docs/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:
@@ -104,13 +102,14 @@ After accepting a buy offer, a best practice for the broker is to cancel all oth
You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/_code-samples/quickstart/py/) 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
```python
import xrpl
from xrpl.clients import JsonRpcClient
from xrpl.wallet import Wallet
@@ -119,7 +118,7 @@ testnet_url = "https://s.altnet.rippletest.net:51234"
## Broker Sale
Pass the _seed_, _sell___offer___index_, _buy___offer___index_, and _broker___fee_.
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):
@@ -606,7 +605,7 @@ text_broker_results.grid(row=9, column=1)
Define and place the broker buttons.
```python
````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")
@@ -622,7 +621,7 @@ 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()
@@ -881,3 +880,4 @@ btn_op_cancel_offer.grid(row=16, column=3, sticky="nsew")
# Start the application
window.mainloop()
```x
````

View File

@@ -5,11 +5,11 @@ top_nav_grouping: Article Types
metadata:
indexPage: true
seo:
description: Mint and sell NFTs on the XRP Ledger using Python.
description: Mint and sell NFTs on the XRP Ledger using Python.
---
# NFTs Using Python
Mint and sell NFTs on the XRP Ledger using Python.
{% child-pages /%}

View File

@@ -2,7 +2,7 @@
html: py-mint-and-burn-nfts.html
parent: nfts-using-python.html
seo:
description: Mint and burn NFTs.
description: Mint and burn NFTs.
labels:
- Quickstart
- Tokens
@@ -27,16 +27,16 @@ You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-port
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**.
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**.
[![Get accounts](/docs/img/quickstart-py11.png)](/docs/img/quickstart-py11.png)
@@ -52,11 +52,10 @@ To mint a non-fungible token object:
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**.
5. Click **Mint NFT**.
[![Mint NFT fields](/docs/img/quickstart-py12.png)](/docs/img/quickstart-py12.png)
## Get Tokens
Click **Get NFTs** to get a list of NFTs owned by the account.
@@ -161,7 +160,7 @@ Send the request and return the result.
return response.result
```
## burn_token
## burn_token
Pass the owner's seed value and the NFT ID.
@@ -182,7 +181,7 @@ Define the NFTokenBurn transaction.
```python
burn_tx=xrpl.models.transactions.NFTokenBurn(
account=owner_wallet.address,
nftoken_id=nftoken_id
nftoken_id=nftoken_id
)
```
@@ -199,6 +198,7 @@ Submit the transaction and return results.
```
## lesson3-mint-token.py
<!-- SPELLING_IGNORE: lesson3 -->
This module builds on `lesson2-create-trustline-send-currency.py`. Changes are noted below.
@@ -619,6 +619,7 @@ 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

View File

@@ -2,7 +2,7 @@
html: py-transfer-nfts.html
parent: nfts-using-python.html
seo:
description: Use a Python test harness to create and accept NFT buy and sell offers.
description: Use a Python test harness to create and accept NFT buy and sell offers.
labels:
- Quickstart
- Tokens
@@ -31,18 +31,18 @@ You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-port
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
1. Paste account seed in the **Standby Seed** field.
2. Click **Get Standby Account**.
3. Click **Get Standby Account Info**.
4. Paste account seed in the **Operational Seed** field.
5. Click **Get Operational Account**.
6. Click **Get Operational Account Info**.
2. If you do not have test account seeds:
1. Click **Get Standby Account**.
2. Click **Get Standby Account Info**.
3. Click **Get Operational Account**.
4. Click **Get Get Op Account Info**.
1. If you have existing test account seeds
1. Paste account seed in the **Standby Seed** field.
2. Click **Get Standby Account**.
3. Click **Get Standby Account Info**.
4. Paste account seed in the **Operational Seed** field.
5. Click **Get Operational Account**.
6. Click **Get Operational Account Info**.
2. If you do not have test account seeds:
1. Click **Get Standby Account**.
2. Click **Get Standby Account Info**.
3. Click **Get Operational Account**.
4. Click **Get Get Op Account Info**.
[![Form with account information](/docs/img/quickstart-py16.png)](/docs/img/quickstart-py16.png)
@@ -128,6 +128,7 @@ To cancel a buy or sell offer that you have created:
You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/_code-samples/quickstart/py/) archive to try each of the samples in your own browser.
## mod4.py
This module contains the new methods `create_sell_offer`, `create_buy_offer`, `accept_sell_offer`, `accept_buy_offer`, `get_offers`, and `cancel_offer`.
Import dependencies.
@@ -190,6 +191,7 @@ If the expiration date is present, include the `expiration` argument.
```python
expiration=expiration_date if expiration != '' else None,
```
Set the `flags` value to _1_, indicating that this is a sell offer.
```python
@@ -260,7 +262,7 @@ Submit the transaction and report the results.
## Create Buy Offer
Pass the buyer _seed_, _amount_, _NFT ID_, _owner_, _expiration_ (in seconds, optional), and _destination_ account (optional).
Pass the buyer _seed_, _amount_, _NFT ID_, _owner_, _expiration_ (in seconds, optional), and _destination_ account (optional).
```python
def create_buy_offer(seed, amount, nft_id, owner, expiration, destination):
@@ -326,7 +328,7 @@ Submit the transaction and report the results.
## Accept Buy Offer
Pass the buyer's _seed_ value and the NFT _offer___index_.
Pass the buyer's _seed_ value and the NFT \_offer*\_\_index*.
```python
def accept_buy_offer(seed, offer_index):
@@ -772,7 +774,7 @@ lbl_standby_nft_id = tk.Label(master=frm_form, text="NFT ID")
ent_standby_nft_id = tk.Entry(master=frm_form, width="50")
```
Add fields for the *NFT Offer Index*, *Owner*, *Expiration*, and *Transfer Fee*.
Add fields for the _NFT Offer Index_, _Owner_, _Expiration_, and _Transfer Fee_.
```python
lbl_standby_nft_offer_index = tk.Label(master=frm_form, text="NFT Offer Index")
@@ -851,7 +853,7 @@ lbl_operational_nft_id = tk.Label(master=frm_form, text="NFT ID")
ent_operational_nft_id = tk.Entry(master=frm_form, width="50")
```
Add fields for *NFT Offer Index*, *Owner*, *Expiration*, and *Transfer Fee*.
Add fields for _NFT Offer Index_, _Owner_, _Expiration_, and _Transfer Fee_.
```python
lbl_operational_nft_offer_index = tk.Label(master=frm_form, text="NFT Offer Index")

View File

@@ -2,18 +2,19 @@
html: py-create-accounts-send-xrp.html
parent: send-payments-using-python.html
seo:
description: Create two accounts and transfer XRP between them using Python.
description: Create two accounts and transfer XRP between them using Python.
labels:
- Accounts
- Quickstart
- Transaction Sending
- XRP
---
# Create Accounts and Send XRP Using Python
This example shows how to:
1. Create accounts on the Testnet, funded with 10000 test XRP with no actual value.
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.
@@ -34,6 +35,7 @@ Download and expand the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-p
{% admonition type="info" name="Note" %}Without the Quickstart Samples, you will not be able to try the examples that follow. {% /admonition %}
## Usage
<div align="center">
<iframe width="560" height="315" src="https://www.youtube.com/embed/YnPccLPa0hc?si=t-CqrLYmCCHSaZhB" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
</div>
@@ -45,7 +47,7 @@ To get test accounts:
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.
6. 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.
[![Standby and Operational Accounts](/docs/img/quickstart-py3.png)](/docs/img/quickstart-py3.png)
@@ -84,11 +86,10 @@ import xrpl
```
Create a variable for the server URI. This example uses the _Testnet_ ledger. You can update the URI to choose a different XRP Ledger instance.
Create a variable for the server URI. This example uses the _Testnet_ ledger. You can update the URI to choose a different XRP Ledger instance.
```python
testnet_url = "https://s.altnet.rippletest.net:51234/"
```python
testnet_url = "https://s.altnet.rippletest.net:51234/"
```
### get_account
@@ -127,13 +128,13 @@ def get_account_info(accountId):
"""get_account_info"""
```
Get a client instance from Testnet.
Get a client instance from Testnet.
```python
client = xrpl.clients.JsonRpcClient(testnet_url)
```
Create the account info request, passing the account ID and the ledger index (in this case, the latest validated ledger).
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(
@@ -182,9 +183,9 @@ Create a transaction request, passing the sending account, amount, and destinati
Submit the transaction and return the response. If the transaction fails, return the error message.
```python
try:
response = xrpl.transaction.submit_and_wait(payment, client, sending_wallet)
except xrpl.transaction.XRPLReliableSubmissionException as e:
try:
response = xrpl.transaction.submit_and_wait(payment, client, sending_wallet)
except xrpl.transaction.XRPLReliableSubmissionException as e:
response = f"Submit failed: {e}"
return response
```
@@ -203,7 +204,7 @@ import json
Import the methods from mod1.py.
```python
```python
from .mod1 import get_account, get_account_info, send_xrp
```
@@ -286,7 +287,7 @@ Use `get_standby_account_info()` and `get_operational_account_info()` to update
### 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())
@@ -412,7 +413,7 @@ Create the operational account buttons and add them to the grid.
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",
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",

View File

@@ -2,13 +2,14 @@
html: py-create-conditional-escrows.html
parent: send-payments-using-python.html
seo:
description: Create, finish, or cancel condition-based escrow transactions.
description: Create, finish, or cancel condition-based escrow transactions.
labels:
- Accounts
- Quickstart
- Transaction Sending
- XRP
---
# Create Conditional Escrows Using Python
This example shows how to:
@@ -21,7 +22,6 @@ This example shows how to:
[![Conditional Escrow Tester Form](/docs/img/quickstart-py-conditional-escrow-1.png)](/docs/img/quickstart-py-conditional-escrow-1.png)
## Prerequisites
Download and expand the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/_code-samples/quickstart/py/) archive.
@@ -39,27 +39,27 @@ pip install cryptoconditions
### Get Test Accounts
To get test accounts:
1. Open and run `lesson9-conditional-escrow.py`.
2. Get test accounts.
1. If you have existing account seeds
1. Paste Standby account seed in the **Standby Seed** field.
2. Click **Get Standby Account**.
3. Click **Get Standby Account Info**.
4. Paste Operational account seed in the **Operational Seed** field.
5. Click **Get Operational Account**.
6. Click **Get Op Account Info**.
2. If you do not have account seeds:
1. Click **Get Standby Account**.
2. Click **Get Standby Account Info**.
3. Click **Get Operational Account**.
4. Click **Get Op Account Info**.
1. If you have existing account seeds
1. Paste Standby account seed in the **Standby Seed** field.
2. Click **Get Standby Account**.
3. Click **Get Standby Account Info**.
4. Paste Operational account seed in the **Operational Seed** field.
5. Click **Get Operational Account**.
6. Click **Get Op Account Info**.
2. If you do not have account seeds:
1. Click **Get Standby Account**.
2. Click **Get Standby Account Info**.
3. Click **Get Operational Account**.
4. Click **Get Op Account Info**.
[![Escrow Example with Account Information](/docs/img/quickstart-py-conditional-escrow-2.png)](/docs/img/quickstart-py-conditional-escrow-2.png)
#### Get a Condition and Fulfillment
Click **Get Condition** to generate a condition/fulfillment pair and populate the fields on the form. You can copy the values and store them in a text file for safe keeping.
Click **Get Condition** to generate a condition/fulfillment pair and populate the fields on the form. You can copy the values and store them in a text file for safe keeping.
[![Escrow Example with Condition and Fulfillment](/docs/img/quickstart-py-conditional-escrow-3.png)](/docs/img/quickstart-py-conditional-escrow-3.png)
@@ -69,7 +69,7 @@ Click **Get Condition** to generate a condition/fulfillment pair and populate th
<iframe width="560" height="315" src="https://www.youtube.com/embed/IUfSX5RKahs?si=7kV0T2NTtqsZfpvX" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
</div>
When you create a conditional escrow, you need to specify the `Condition` value you generated above. You must also set a cancel date and time, after which the escrow is no longer available.
When you create a conditional escrow, you need to specify the `Condition` value you generated above. You must also set a cancel date and time, after which the escrow is no longer available.
To create a conditional escrow:
@@ -97,7 +97,7 @@ To finish a conditional escrow:
3. Enter the **Escrow Fulfillment** code for the `Condition`.
4. Copy the **Standby Account** value.
5. Paste it into the **Escrow Owner** field.
4. Click **Finish Conditional Escrow**.
6. Click **Finish Conditional Escrow**.
The transaction completes and balances are updated for both the Standby and Operational accounts.
@@ -105,7 +105,7 @@ The transaction completes and balances are updated for both the Standby and Oper
## Get Escrows
Click **Get Escrows** for either the Standby account or the Operational account to see their current list of escrows.
Click **Get Escrows** for either the Standby account or the Operational account to see their current list of escrows.
## Cancel Escrow
@@ -227,7 +227,7 @@ Instantiate a wallet and connect to Testnet.
client=JsonRpcClient(testnet_url)
```
Create a *cancel_date* variable, adding your specified number of seconds to the current Ripple epoch date.
Create a _cancel_date_ variable, adding your specified number of seconds to the current Ripple epoch date.
```python
cancel_date = add_seconds(cancel)
@@ -242,7 +242,7 @@ Define the transaction with your provided values.
destination=destination,
cancel_after=cancel_date,
condition=condition
)
)
```
Submit the transaction and return the results.
@@ -259,7 +259,7 @@ Submit the transaction and return the results.
### finish_conditional_escrow
At any time prior to the cancel date, the destination account can fulfill the escrow.
At any time prior to the cancel date, the destination account can fulfill the escrow.
Pass the _seed_ for the receiving account, the _owner_ (sending account), the _sequence_ number for the escrow, the _condition_ value, and the matching _fulfillment_ value.
@@ -327,7 +327,7 @@ def get_condition():
ent_standby_escrow_condition.insert(0, results[0])
ent_operational_escrow_fulfillment.delete(0, tk.END)
ent_operational_escrow_fulfillment.insert(0, results[1])
def standby_create_conditional_escrow():
results = create_conditional_escrow(
ent_standby_seed.get(),
@@ -365,12 +365,12 @@ def standby_cancel_time_escrow():
)
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
def operational_get_transaction():
results = get_transaction(ent_operational_account.get(),
ent_operational_look_up.get())
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
text_operational_results.insert("1.0", json.dumps(results, indent=4))
## Mod 1 Handlers
@@ -457,7 +457,7 @@ ent_standby_escrow_cancel = tk.Entry(master=frm_form, width=50)
lbl_standby_escrow_sequence_number = tk.Label(master=frm_form, text="Sequence Number")
ent_standby_escrow_sequence_number = tk.Entry(master=frm_form, width=50)
lbl_standby_escrow_owner = tk.Label(master=frm_form, text="Escrow Owner")
ent_standby_escrow_owner = tk.Entry(master=frm_form, width=50)
ent_standby_escrow_owner = 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)

View File

@@ -2,23 +2,22 @@
html: py-create-time-based-escrows.html
parent: send-payments-using-python.html
seo:
description: Create, finish, or cancel time-based escrow transactions.
description: Create, finish, or cancel time-based escrow transactions.
labels:
- Accounts
- Quickstart
- Transaction Sending
- XRP
---
# Create Time-based Escrows Using Python
This example shows how to:
1. Create escrow payments that become available at a specified time and expire at a specified time.
2. Finish an escrow payment.
3. Retrieve information on escrows attached to an account.
3. Cancel an escrow payment and return the XRP to the sending account.
4. Cancel an escrow payment and return the XRP to the sending account.
[![Escrow Tester Form](/docs/img/quickstart-py-escrow1.png)](/docs/img/quickstart-py-escrow1.png)
@@ -32,18 +31,18 @@ To get test accounts:
1. Open `lesson8-time-escrow.py.`
2. Get test accounts.
1. If you have existing account seeds
1. Paste Standby account seed in the **Standby Seed** field.
2. Click **Get Standby Account**.
3. Click **Get Standby Account Info**.
4. Paste Operational account seed in the **Operational Seed** field.
5. Click **Get Operational Account**.
6. Click **Get Op Account Info**.
2. If you do not have account seeds:
1. Click **Get Standby Account**.
2. Click **Get Standby Account Info**.
3. Click **Get Operational Account**.
4. Click **Get Op Account Info**.
1. If you have existing account seeds
1. Paste Standby account seed in the **Standby Seed** field.
2. Click **Get Standby Account**.
3. Click **Get Standby Account Info**.
4. Paste Operational account seed in the **Operational Seed** field.
5. Click **Get Operational Account**.
6. Click **Get Op Account Info**.
2. If you do not have account seeds:
1. Click **Get Standby Account**.
2. Click **Get Standby Account Info**.
3. Click **Get Operational Account**.
4. Click **Get Op Account Info**.
[![Escrow Tester with Account Information](/docs/img/quickstart-py-escrow2.png)](/docs/img/quickstart-py-escrow2.png)
@@ -91,7 +90,6 @@ For the purposes of this tutorial, you can follow the steps in [Create Escrow](#
[![Get Escrows results](/docs/img/quickstart-py-escrow5.png)](/docs/img/quickstart-py-escrow5.png)
## Cancel Escrow
When the Escrow Cancel time passes, the escrow is no longer available to the recipient. The initiator of the escrow can reclaim the XRP. If you try to cancel the transaction prior to the **Escrow Cancel** time, you are charged for the transaction, but the actual escrow cannot be cancelled until the time limit is reached.
@@ -102,7 +100,7 @@ To cancel an expired escrow:
1. Enter the sequence number in the Standby **Sequence Number** field.
2. Copy the **Standby Account** value and paste it in the **Escrow Owner** field.
2. Click **Cancel Time-based Escrow**.
3. Click **Cancel Time-based Escrow**.
The funds are returned to the Standby account, less the initial transaction fee.
@@ -166,7 +164,7 @@ Return the resulting date value.
### create_time_escrow
Call the create_time_escrow function, passing the _seed_, _amount_, _destination_, _finish_ interval, and _cancel_ interval.
Call the create*time_escrow function, passing the \_seed*, _amount_, _destination_, _finish_ interval, and _cancel_ interval.
```python
def create_time_escrow(seed, amount, destination, finish, cancel):
@@ -200,7 +198,7 @@ Define the **EscrowCreate** transaction.
destination=destination,
finish_after=finish_date,
cancel_after=cancel_date
)
)
```
Submit the transaction and report the results.
@@ -404,12 +402,12 @@ def standby_cancel_time_escrow():
)
text_standby_results.delete("1.0", tk.END)
text_standby_results.insert("1.0", json.dumps(results, indent=4))
def operational_get_transaction():
results = get_transaction(ent_operational_account.get(),
ent_operational_look_up.get())
text_operational_results.delete("1.0", tk.END)
text_operational_results.insert("1.0", json.dumps(results, indent=4))
text_operational_results.insert("1.0", json.dumps(results, indent=4))
## Mod 1 Handlers
@@ -494,7 +492,7 @@ ent_standby_escrow_cancel = tk.Entry(master=frm_form, width=50)
lbl_standby_escrow_sequence_number = tk.Label(master=frm_form, text="Sequence Number")
ent_standby_escrow_sequence_number = tk.Entry(master=frm_form, width=50)
lbl_standby_escrow_owner = tk.Label(master=frm_form, text="Escrow Owner")
ent_standby_escrow_owner = tk.Entry(master=frm_form, width=50)
ent_standby_escrow_owner = 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)

View File

@@ -2,13 +2,14 @@
html: py-create-trustline-send-currency.html
parent: send-payments-using-python.html
seo:
description: Create trust lines and send currency.
description: Create trust lines and send currency.
labels:
- Cross-Currency
- Payments
- Quickstart
- Tokens
---
# Create Trust Line and Send Currency Using Python
This example shows how to:
@@ -31,12 +32,12 @@ 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**.
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
@@ -44,7 +45,6 @@ Open the Quickstart window and get accounts:
<iframe width="560" height="315" src="https://www.youtube.com/embed/6KWP0PV6J8Y?si=SSxFGrvfTo6pOPLD" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
</div>
To create a trust line between accounts:
1. Enter a [currency code](https://www.iban.com/currency-codes) in the **Currency** field.
@@ -146,7 +146,8 @@ Return the results.
```python
return response.result
```
## send_currency
## send_currency
Send currency to another account based on the sender wallet, destination account, the currency type, and the amount of the currency.
@@ -178,16 +179,16 @@ Define the payment transaction. The amount requires further description to ident
Submit the transaction and get the response.
```python
````python
response=xrpl.transaction.submit_and_wait(send_currency_tx, client, sending_wallet)```
Return the results.
```python
return response.result
```
````
### get_balance
### get_balance
Update the **XRP Balance** fields and list the balance information for issued currencies in the **Results** text areas.
@@ -202,7 +203,7 @@ Connect to the XRP Ledger and instantiate a client.
client=JsonRpcClient(testnet_url)
```
Create the `GatewayBalances` request.
Create the `GatewayBalances` request.
```python
balance=xrpl.models.requests.GatewayBalances(
@@ -224,6 +225,7 @@ Return the result.
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](../../../references/protocol/transactions/types/accountset.md#accountset-flags).
Send the account seed and a Boolean value for whether to enable or disable rippling.
```python
def configure_account(seed, default_setting):
"""configure_account"
@@ -236,7 +238,7 @@ Get the account wallet and instantiate a client.
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.
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):
@@ -255,7 +257,7 @@ Submit the transaction and get results.
```python
response=xrpl.transaction.submit_and_wait(setting_tx,client,wallet)
return response.result
return response.result
```
## lesson2-send-currency.py

View File

@@ -2,7 +2,7 @@
html: send-payments-using-python.html
parent: modular-tutorials-in-python.html
seo:
description: Use a Python test harness to send XRP,trade currencies, and more.
description: Use a Python test harness to send XRP,trade currencies, and more.
labels:
- Accounts
- Cross-Currency
@@ -14,9 +14,9 @@ labels:
metadata:
indexPage: true
---
# Send Payments Using Python
Send XRP and issued currency on the XRP Ledger using Python.
{% child-pages /%}

View File

@@ -8,11 +8,12 @@ labels:
- Checks
- XRP
---
# Send and Cash Checks
This example shows how to:
1. Send a check to transfer XRP or issued currency to another account.
1. Send a check to transfer XRP or issued currency to another account.
2. Get a list of checks you have sent or received.
3. Cash a check received from another account.
4. Cancel a check you have sent.
@@ -20,8 +21,7 @@ This example shows how to:
Checks offer another option for transferring funds between accounts. Checks have two particular advantages.
1. You can use a check to send funds to another account without first creating a trust line - the trust line is created automatically when the receiver chooses to accept the funds.
2. The receiver can choose to accept less than the full amount of the check. This allows you to authorize a maximum amount when the actual cost is not finalized.
2. The receiver can choose to accept less than the full amount of the check. This allows you to authorize a maximum amount when the actual cost is not finalized.
[![Empty Check Form](/docs/img/quickstart-py-checks1.png)](/docs/img/quickstart-py-checks1.png)
@@ -46,7 +46,7 @@ To get test accounts:
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.
6. 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.
[![Form with New Accounts](/docs/img/quickstart-py-checks2.png)](/docs/img/quickstart-py-checks2.png)
@@ -79,7 +79,6 @@ To send a check for an issued currency token from the Standby account to the Ope
[![Send Token Check Settings](/docs/img/quickstart-py-checks4.png)](/docs/img/quickstart-py-checks4.png)
### Get Checks
Click **Get Checks** to get a list of the current checks you have sent or received. To uniquely identify a check (for existence, when cashing a check), capture the **index** value for the check.
@@ -94,14 +93,11 @@ To cash a check you have received:
2. Enter the **Amount** you want to collect, up to the full amount of the check.
3. Enter the currency code.
a. If you cashing a check for XRP, enter _XRP_ in the **Currency** field.
b. If you are cashing a check for an issued currency token:
1. Enter the **Issuer** of the token.
2. Enter the **Currency** code for the token.
b. If you are cashing a check for an issued currency token: 1. Enter the **Issuer** of the token. 2. Enter the **Currency** code for the token.
4. Click **Cash Check**.
[![Cashed check results](/docs/img/quickstart-py-checks6.png)](/docs/img/quickstart-py-checks6.png)
### Get Balances
Click **Get Balances** to get a list of obligations and assets for each account.
@@ -117,7 +113,6 @@ To cancel a check you have previously sent to another account.
[![Canceled check results](/docs/img/quickstart-py-checks8.png)](/docs/img/quickstart-py-checks8.png)
# Code Walkthrough
You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/quickstart/py/) in the source repository for this website.
@@ -140,9 +135,10 @@ Set the TestNet URL.
```python
testnet_url = "https://s.altnet.rippletest.net:51234"
```
### send_check
Pass the arguments for the account seed, check amount, and destination account. Set the currency type to _XRP_, or if it is an issued currency token provide the currency type and issuer.
Pass the arguments for the account seed, check amount, and destination account. Set the currency type to _XRP_, or if it is an issued currency token provide the currency type and issuer.
```python
def send_check(seed, amount, destination, currency, issuer):
@@ -173,7 +169,7 @@ Define the `CheckCreate` transaction.
account=wallet.address,
send_max=amount,
destination=destination
)
)
```
Submit the transaction and report the results.
@@ -190,7 +186,7 @@ Submit the transaction and report the results.
### cash_check
Pass the values for seed, amount, and check_id. Set the currency type to _XRP_, or include the currency type and issuer.
Pass the values for seed, amount, and check*id. Set the currency type to \_XRP*, or include the currency type and issuer.
```python
def cash_check(seed, amount, check_id, currency, issuer):
@@ -306,7 +302,7 @@ Send the request and report the results.
## lesson10-check.py
This example builds on `lesson2-send-currency.py`. Changes are noted below.
This example builds on `lesson2-send-currency.py`. Changes are noted below.
```python
import tkinter as tk
@@ -606,7 +602,6 @@ btn_standby_send_xrp.grid(row=2, column=2, sticky="nsew")
Add standby buttons for **Send Check**, **Get Checks**, **Cash Check**, **Cancel Check**, and **Get Balances**.
```python
btn_standby_send_check=tk.Button(master=frm_form, text="Send Check",
command=standby_send_check)
@@ -639,7 +634,6 @@ btn_op_send_xrp.grid(row=2, column=3, sticky="nsew")
Add operational buttons for **Send Check**, **Get Checks**, **Cash Check**, **Cancel Check**, and **Get Balances**.
```javascript
btn_op_send_check=tk.Button(master=frm_form, text="Send Check",
command=operational_send_check)