You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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):
78
+
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).
79
+
80
+
{% admonition type="info" name="Note" %}
81
+
The standard approach with `xrpl-py` is to use the JSON-RPC client. While a WebSocket client is available, it requires you to use `async`/`await` throughout your code. For most use cases, stick with JSON-RPC to avoid the complexity of asynchronous programming.
82
+
{% /admonition %}
79
83
80
84
The sample code shows you how to connect to the Testnet, which is one of the available [parallel networks](../../../concepts/networks-and-servers/parallel-networks.md).
81
85
{% /step %}
@@ -104,10 +108,8 @@ The sample code in the previous section shows you how to connect to the Testnet,
104
108
```
105
109
{%/step %}
106
110
107
-
### 3. Get account
108
-
109
111
{% step id="get-account-create-wallet-tag"%}
110
-
#### Create and Fund a Wallet
112
+
### 3. Get account
111
113
112
114
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.
113
115
@@ -118,60 +120,46 @@ For testing and development purposes, you can use the [XRP Faucets](/resources/d
118
120
To create and fund an account on the Testnet, `xrpl-py` provides the [`generate_faucet_wallet`](https://xrpl-py.readthedocs.io/en/latest/source/xrpl.wallet.html#xrpl.wallet.generate_faucet_wallet) method. This method returns a [`Wallet` instance](https://xrpl-py.readthedocs.io/en/latest/source/xrpl.wallet.html#xrpl.wallet.Wallet).
119
121
{%/step %}
120
122
121
-
{% step id="get-account-x-address-tag"%}
122
-
#### Derive an X-Address
123
-
124
-
You can use `xrpl-py`'s [`xrpl.core.addresscodec`](https://xrpl-py.readthedocs.io/en/latest/source/xrpl.core.addresscodec.html) module to derive an [X-address](https://xrpaddress.info/) from the `Wallet.address` field.
125
-
126
-
The X-address format [packs the address and destination tag](https://github.com/XRPLF/XRPL-Standards/issues/6) into a more user-friendly value.
127
-
{%/step %}
128
-
123
+
{% step id="query-xrpl-tag"%}
129
124
### 4. Query the XRP Ledger
130
125
131
-
{% step id="query-xrpl-tag"%}
132
126
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).
133
127
134
-
Here, we use `xrpl-py`'s [`xrpl.account`](https://xrpl-py.readthedocs.io/en/latest/source/xrpl.account.html) module to look up information about the account we got in the previous step.
128
+
Use the [account_info method][] to look up information about the account you got in the previous step. Use a request model like `AccountInfo` to validate the request formatand catch errors sooner.
135
129
{%/step %}
136
130
131
+
{% step id="run-app-tag"%}
137
132
### 5. Run the Application
138
133
139
-
{% step id="run-app-tag"%}
140
134
Finally, in your terminal, run the application like so:
141
135
142
136
```sh
143
-
python3 get-acct-info.py
137
+
python get-acct-info.py
144
138
```
145
139
146
140
You should see output similar to this example:
147
141
148
142
```sh
149
-
Connected to Testnet
150
-
151
143
Creating a new wallet and funding it with Testnet XRP...
152
-
Attempting to fund address ranrY8twgDvEGjk8NnC8QsZY1NNyyDV2TZ
144
+
Attempting to fund address ravbHNootpSNQkxyEFCWevSkHsFGDHfyop
The response fields that you want to inspect in most cases are:
199
187
200
-
-`account_data.Sequence` — This is the sequence number of the next valid transaction for the account. You need to specify the sequence number when you prepare transactions. With `xrpl-py`, you can use the [`get_next_valid_seq_number`](https://xrpl-py.readthedocs.io/en/latest/source/xrpl.account.html#xrpl.account.get_next_valid_seq_number) to get this automatically from the XRP Ledger. See an example of this usage in the project [README](https://github.com/XRPLF/xrpl-py#serialize-and-sign-transactions).
201
-
202
188
-`account_data.Balance` — This is the account's balance of [XRP, in drops][]. You can use this to confirm that you have enough XRP to send (if you're making a payment) and to meet the [current transaction cost](../../../concepts/transactions/transaction-cost.md#current-transaction-cost) for a given transaction.
203
189
204
190
-`validated` — Indicates whether the returned data isfrom a [validated ledger](../../../concepts/ledgers/open-closed-validated-ledgers.md). When inspecting transactions, it's important to confirm that [the results are final](../../../concepts/transactions/finality-of-results/index.md) before further processing the transaction. If `validated` is `true` then you know for sure the results won't change. For more information about best practices for transaction processing, see [Reliable Transaction Submission](../../../concepts/transactions/reliable-transaction-submission.md).
0 commit comments