mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-28 07:35:50 +00:00
Compare commits
14 Commits
8d2d3850ec
...
minor-get-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d89fdc79b8 | ||
|
|
01ed3055ec | ||
|
|
eb174b8700 | ||
|
|
9e96d40799 | ||
|
|
d6b55ab177 | ||
|
|
d8b216bdd7 | ||
|
|
1e095599fd | ||
|
|
d27888182c | ||
|
|
7dd37e6b19 | ||
|
|
3347fc965d | ||
|
|
30c8e22eeb | ||
|
|
904761dc51 | ||
|
|
b2f345edd5 | ||
|
|
9e40756dd1 |
@@ -1,6 +1,6 @@
|
||||
// @ts-check
|
||||
|
||||
import { getInnerText } from '@redocly/realm/dist/shared/markdoc.js';
|
||||
import { getInnerText } from '@redocly/realm/dist/server/plugins/markdown/markdoc/helpers/get-inner-text.js';
|
||||
|
||||
import { dirname, relative, join as joinPath } from 'path';
|
||||
import markdoc from '@markdoc/markdoc';
|
||||
@@ -47,6 +47,7 @@ export function blogPosts() {
|
||||
actions.createSharedData('blog-posts', { blogPosts: sortedPosts });
|
||||
actions.addRouteSharedData('/blog/', 'blog-posts', 'blog-posts');
|
||||
actions.addRouteSharedData('/ja/blog/', 'blog-posts', 'blog-posts');
|
||||
actions.addRouteSharedData('/es-es/blog/', 'blog-posts', 'blog-posts');
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// @ts-check
|
||||
|
||||
import { getInnerText } from '@redocly/realm/dist/shared/markdoc.js';
|
||||
import { getInnerText } from '@redocly/realm/dist/server/plugins/markdown/markdoc/helpers/get-inner-text.js';
|
||||
|
||||
import { dirname, relative, join as joinPath } from 'path';
|
||||
|
||||
@@ -44,6 +44,7 @@ export function codeSamples() {
|
||||
});
|
||||
actions.addRouteSharedData('/resources/code-samples/', 'code-samples', 'code-samples');
|
||||
actions.addRouteSharedData('/ja/resources/code-samples/', 'code-samples', 'code-samples');
|
||||
actions.addRouteSharedData('/es-es/resources/code-samples/', 'code-samples', 'code-samples');
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
|
||||
15
_api-examples/path_find/create-followup.json
Normal file
15
_api-examples/path_find/create-followup.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"alternatives": [
|
||||
// ... paths omitted from this example; same format as the initial response ...
|
||||
],
|
||||
"destination_account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
||||
"destination_amount": {
|
||||
"currency": "USD",
|
||||
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
|
||||
"value": "0.001"
|
||||
},
|
||||
"full_reply": true,
|
||||
"id": 8,
|
||||
"source_account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
||||
"type": "path_find"
|
||||
}
|
||||
75
_api-examples/path_find/create-response.json
Normal file
75
_api-examples/path_find/create-response.json
Normal file
@@ -0,0 +1,75 @@
|
||||
{
|
||||
"id": 8,
|
||||
"result": {
|
||||
"alternatives": [
|
||||
{
|
||||
"paths_computed": [
|
||||
[
|
||||
{
|
||||
"currency": "USD",
|
||||
"issuer": "rKiCet8SdvWxPXnAgYarFUXMh1zCPz432Y",
|
||||
"type": 48
|
||||
},
|
||||
{
|
||||
"account": "rKiCet8SdvWxPXnAgYarFUXMh1zCPz432Y",
|
||||
"type": 1
|
||||
},
|
||||
{
|
||||
"account": "rLzpfEnrB2Ro2LtaGd6Af7znRqGxULc4rW",
|
||||
"type": 1
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"currency": "USD",
|
||||
"issuer": "rKiCet8SdvWxPXnAgYarFUXMh1zCPz432Y",
|
||||
"type": 48
|
||||
},
|
||||
{
|
||||
"account": "rKiCet8SdvWxPXnAgYarFUXMh1zCPz432Y",
|
||||
"type": 1
|
||||
},
|
||||
{
|
||||
"account": "rQhbp2h133vD3TJGWkNY5zePHKQUq6vSVm",
|
||||
"type": 1
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"currency": "USD",
|
||||
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
|
||||
"type": 48
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"currency": "USD",
|
||||
"issuer": "rhub8VRN55s94qWKDv6jmDy1pUykJzF3wq",
|
||||
"type": 48
|
||||
},
|
||||
{
|
||||
"account": "rhub8VRN55s94qWKDv6jmDy1pUykJzF3wq",
|
||||
"type": 1
|
||||
},
|
||||
{
|
||||
"account": "r4cjaKtZqP2GDjwK3eT9qua4Hqk9Zk2kSy",
|
||||
"type": 1
|
||||
}
|
||||
]
|
||||
],
|
||||
"source_amount": "390"
|
||||
}
|
||||
],
|
||||
"destination_account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
||||
"destination_amount": {
|
||||
"currency": "USD",
|
||||
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
|
||||
"value": "0.001"
|
||||
},
|
||||
"full_reply": false,
|
||||
"id": 8,
|
||||
"source_account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59"
|
||||
},
|
||||
"status": "success",
|
||||
"type": "response"
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
// @chunk {"steps": ["import-node-tag"]}
|
||||
// Import the library
|
||||
// @chunk {"steps": ["connect-tag"]}
|
||||
import xrpl from "xrpl"
|
||||
// @chunk-end
|
||||
|
||||
// @chunk {"steps": ["connect-tag"]}
|
||||
// Define the network client
|
||||
const SERVER_URL = "wss://s.altnet.rippletest.net:51233/"
|
||||
const client = new xrpl.Client(SERVER_URL)
|
||||
|
||||
62
_code-samples/get-started/py/README.md
Normal file
62
_code-samples/get-started/py/README.md
Normal file
@@ -0,0 +1,62 @@
|
||||
# Get Started Using Python Library
|
||||
|
||||
Connects to the XRP Ledger and gets account information using Python.
|
||||
|
||||
To download the source code, see [Get Started Using Python Library](http://xrpl.org/docs/tutorials/python/build-apps/get-started).
|
||||
|
||||
## Run the Code
|
||||
|
||||
Quick setup and usage:
|
||||
|
||||
```sh
|
||||
python -m venv .venv
|
||||
source .venv/bin/activate
|
||||
pip install -r requirements.txt
|
||||
python ./get-acct-info.py
|
||||
```
|
||||
|
||||
You should see output similar to the following:
|
||||
|
||||
```sh
|
||||
Creating a new wallet and funding it with Testnet XRP...
|
||||
Attempting to fund address ravbHNootpSNQkxyEFCWevSkHsFGDHfyop
|
||||
Faucet fund successful.
|
||||
Wallet: ravbHNootpSNQkxyEFCWevSkHsFGDHfyop
|
||||
Account Testnet Explorer URL:
|
||||
https://testnet.xrpl.org/accounts/ravbHNootpSNQkxyEFCWevSkHsFGDHfyop
|
||||
|
||||
Getting account info...
|
||||
Response Status: ResponseStatus.SUCCESS
|
||||
{
|
||||
"account_data": {
|
||||
"Account": "ravbHNootpSNQkxyEFCWevSkHsFGDHfyop",
|
||||
"Balance": "100000000",
|
||||
"Flags": 0,
|
||||
"LedgerEntryType": "AccountRoot",
|
||||
"OwnerCount": 0,
|
||||
"PreviousTxnID": "3DACF2438AD39F294C4EFF6132D5D88BCB65D2F2261C7650F40AC1F6A54C83EA",
|
||||
"PreviousTxnLgrSeq": 12039759,
|
||||
"Sequence": 12039759,
|
||||
"index": "148E6F4B8E4C14018D679A2526200C292BDBC5AB77611BC3AE0CB97CD2FB84E5"
|
||||
},
|
||||
"account_flags": {
|
||||
"allowTrustLineClawback": false,
|
||||
"defaultRipple": false,
|
||||
"depositAuth": false,
|
||||
"disableMasterKey": false,
|
||||
"disallowIncomingCheck": false,
|
||||
"disallowIncomingNFTokenOffer": false,
|
||||
"disallowIncomingPayChan": false,
|
||||
"disallowIncomingTrustline": false,
|
||||
"disallowIncomingXRP": false,
|
||||
"globalFreeze": false,
|
||||
"noFreeze": false,
|
||||
"passwordSpent": false,
|
||||
"requireAuthorization": false,
|
||||
"requireDestinationTag": false
|
||||
},
|
||||
"ledger_hash": "CA624D717C4FCDD03BAD8C193F374A77A14F7D2566354A4E9617A8DAD896DE71",
|
||||
"ledger_index": 12039759,
|
||||
"validated": true
|
||||
}
|
||||
```
|
||||
@@ -1,34 +1,39 @@
|
||||
# @chunk {"steps": ["connect-tag"]}
|
||||
# Define the network client
|
||||
from xrpl.clients import JsonRpcClient
|
||||
from xrpl.wallet import generate_faucet_wallet
|
||||
from xrpl.core import addresscodec
|
||||
from xrpl.models.requests.account_info import AccountInfo
|
||||
import json
|
||||
|
||||
JSON_RPC_URL = "https://s.altnet.rippletest.net:51234/"
|
||||
client = JsonRpcClient(JSON_RPC_URL)
|
||||
# @chunk-end
|
||||
|
||||
|
||||
# Create a wallet using the testnet faucet:
|
||||
# @chunk {"steps": ["get-account-create-wallet-tag"]}
|
||||
# Create a wallet using the Testnet faucet:
|
||||
# https://xrpl.org/xrp-testnet-faucet.html
|
||||
from xrpl.wallet import generate_faucet_wallet
|
||||
print("\nCreating a new wallet and funding it with Testnet XRP...")
|
||||
test_wallet = generate_faucet_wallet(client, debug=True)
|
||||
|
||||
# Create an account str from the wallet
|
||||
test_account = test_wallet.address
|
||||
|
||||
# Derive an x-address from the classic address:
|
||||
# https://xrpaddress.info/
|
||||
from xrpl.core import addresscodec
|
||||
test_xaddress = addresscodec.classic_address_to_xaddress(test_account, tag=12345, is_test_network=True)
|
||||
print("\nClassic address:\n\n", test_account)
|
||||
print("X-address:\n\n", test_xaddress)
|
||||
test_account = test_wallet.classic_address
|
||||
print(f"Wallet: {test_account}")
|
||||
print(f"Account Testnet Explorer URL: ")
|
||||
print(f" https://testnet.xrpl.org/accounts/{test_account}")
|
||||
# @chunk-end
|
||||
|
||||
|
||||
# @chunk {"steps": ["query-xrpl-tag"]}
|
||||
# Look up info about your account
|
||||
from xrpl.models.requests.account_info import AccountInfo
|
||||
print("\nGetting account info...")
|
||||
acct_info = AccountInfo(
|
||||
account=test_account,
|
||||
ledger_index="validated",
|
||||
strict=True,
|
||||
)
|
||||
|
||||
response = client.request(acct_info)
|
||||
result = response.result
|
||||
print("response.status: ", response.status)
|
||||
import json
|
||||
print("Response Status: ", response.status)
|
||||
print(json.dumps(response.result, indent=4, sort_keys=True))
|
||||
# @chunk-end
|
||||
|
||||
1
_code-samples/get-started/py/requirements.txt
Normal file
1
_code-samples/get-started/py/requirements.txt
Normal file
@@ -0,0 +1 @@
|
||||
xrpl-py==4.3.0
|
||||
@@ -7,7 +7,7 @@ labels:
|
||||
- Tokens
|
||||
---
|
||||
# account_currencies
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/df966a9ac6dd986585ecccb206aff24452e41a30/src/ripple/rpc/handlers/AccountCurrencies.cpp "Source")
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/xrpld/rpc/handlers/AccountCurrenciesHandler.cpp "Source")
|
||||
|
||||
The `account_currencies` command retrieves a list of currencies that an account can send or receive, based on its trust lines. (This is not a thoroughly confirmed list, but it can be used to populate user interfaces.)
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ labels:
|
||||
- XRP
|
||||
---
|
||||
# account_info
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/ripple/rpc/handlers/AccountInfo.cpp "Source")
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/xrpld/rpc/handlers/AccountInfo.cpp "Source")
|
||||
|
||||
The `account_info` command retrieves information about an account, its activity, and its XRP balance. All information retrieved is relative to a particular version of the ledger.
|
||||
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
---
|
||||
html: account_nfts.html
|
||||
parent: account-methods.html
|
||||
seo:
|
||||
description: Get a list of all NFTs for an account.
|
||||
labels:
|
||||
- Non-fungible Tokens, NFTs
|
||||
- Non-fungible Tokens, NFTs
|
||||
---
|
||||
# account_nfts
|
||||
[[Source]](https://github.com/xrplf/rippled/blob/master/src/ripple/rpc/handlers/AccountObjects.cpp "Source")
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/xrpld/rpc/handlers/AccountObjects.cpp "Source")
|
||||
|
||||
The `account_nfts` method returns a list of `NFToken` objects for the specified account.
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ labels:
|
||||
- Decentralized Exchange
|
||||
---
|
||||
# account_offers
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/ripple/rpc/handlers/AccountOffers.cpp "Source")
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/xrpld/rpc/handlers/AccountOffers.cpp "Source")
|
||||
|
||||
The `account_offers` method retrieves a list of [offers](../../../../concepts/tokens/decentralized-exchange/offers.md) made by a given [account](../../../../concepts/accounts/index.md) that are outstanding as of a particular [ledger version](../../../../concepts/ledgers/index.md).
|
||||
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
---
|
||||
html: account_tx.html
|
||||
parent: account-methods.html
|
||||
seo:
|
||||
description: Get a list of transactions affecting an account.
|
||||
labels:
|
||||
- Payments
|
||||
- Accounts
|
||||
- Payments
|
||||
- Accounts
|
||||
---
|
||||
# account_tx
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/ripple/rpc/handlers/AccountTx.cpp "Source")
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/xrpld/rpc/handlers/AccountTx.cpp "Source")
|
||||
|
||||
The `account_tx` method retrieves a list of validated transactions that involve a given account.
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
---
|
||||
html: gateway_balances.html
|
||||
parent: account-methods.html
|
||||
seo:
|
||||
description: Calculate total amounts issued by an account.
|
||||
labels:
|
||||
@@ -8,7 +6,7 @@ labels:
|
||||
- Accounts
|
||||
---
|
||||
# gateway_balances
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/9111ad1a9dc37d49d085aa317712625e635197c0/src/ripple/rpc/handlers/GatewayBalances.cpp "Source")
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/xrpld/rpc/handlers/GatewayBalances.cpp "Source")
|
||||
|
||||
The `gateway_balances` command calculates the total balances issued by a given account, optionally excluding amounts held by [operational addresses](../../../../concepts/accounts/account-types.md).
|
||||
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
---
|
||||
html: noripple_check.html
|
||||
parent: account-methods.html
|
||||
seo:
|
||||
description: Get recommended changes to an account's Default Ripple and No Ripple settings.
|
||||
labels:
|
||||
- Tokens
|
||||
- Tokens
|
||||
---
|
||||
# noripple_check
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/9111ad1a9dc37d49d085aa317712625e635197c0/src/ripple/rpc/handlers/NoRippleCheck.cpp "Source")
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/xrpld/rpc/handlers/NoRippleCheck.cpp "Source")
|
||||
|
||||
The `noripple_check` command provides a quick way to check the status of [the Default Ripple field for an account and the No Ripple flag of its trust lines](../../../../concepts/tokens/fungible-tokens/rippling.md), compared with the recommended settings.
|
||||
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
---
|
||||
html: ledger.html # Watch carefully for clashes w/ this filename
|
||||
parent: ledger-methods.html
|
||||
seo:
|
||||
description: Get info about a ledger version.
|
||||
labels:
|
||||
- Blockchain
|
||||
- Blockchain
|
||||
---
|
||||
# ledger
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/ripple/rpc/handlers/LedgerHandler.cpp "Source")
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/xrpld/rpc/handlers/LedgerHandler.cpp "Source")
|
||||
|
||||
Retrieve information about the public [ledger](../../../../concepts/ledgers/index.md).
|
||||
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
---
|
||||
html: ledger_closed.html
|
||||
parent: ledger-methods.html
|
||||
seo:
|
||||
description: Get the latest closed ledger version.
|
||||
labels:
|
||||
- Blockchain
|
||||
- Blockchain
|
||||
---
|
||||
# ledger_closed
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/ripple/rpc/handlers/LedgerClosed.cpp "Source")
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/xrpld/rpc/handlers/LedgerClosed.cpp "Source")
|
||||
|
||||
The `ledger_closed` method returns the unique identifiers of the most recently closed ledger. (This ledger is not necessarily validated and immutable yet.)
|
||||
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
---
|
||||
html: ledger_current.html
|
||||
parent: ledger-methods.html
|
||||
seo:
|
||||
description: Get the current working ledger version.
|
||||
labels:
|
||||
- Blockchain
|
||||
- Blockchain
|
||||
---
|
||||
# ledger_current
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/ripple/rpc/handlers/LedgerCurrent.cpp "Source")
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/xrpld/rpc/handlers/LedgerCurrent.cpp "Source")
|
||||
|
||||
The `ledger_current` method returns the unique identifiers of the current in-progress [ledger](../../../../concepts/ledgers/index.md). This command is mostly useful for testing, because the ledger returned is still in flux.
|
||||
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
---
|
||||
html: ledger_data.html
|
||||
parent: ledger-methods.html
|
||||
seo:
|
||||
description: Get the raw contents of a ledger version.
|
||||
labels:
|
||||
- Blockchain
|
||||
- Data Retention
|
||||
- Blockchain
|
||||
- Data Retention
|
||||
---
|
||||
# ledger_data
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/ripple/rpc/handlers/LedgerData.cpp "Source")
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/xrpld/rpc/handlers/LedgerData.cpp "Source")
|
||||
|
||||
The `ledger_data` method retrieves contents of the specified ledger. You can iterate through several calls to retrieve the entire contents of a single ledger version.
|
||||
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
---
|
||||
html: ledger_entry.html
|
||||
parent: ledger-methods.html
|
||||
seo:
|
||||
description: Get one element from a ledger version.
|
||||
labels:
|
||||
- Blockchain
|
||||
- Data Retention
|
||||
- Blockchain
|
||||
- Data Retention
|
||||
---
|
||||
# ledger_entry
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/ripple/rpc/handlers/LedgerEntry.cpp "Source")
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/xrpld/rpc/handlers/LedgerEntry.cpp "Source")
|
||||
|
||||
The `ledger_entry` method returns a single ledger entry from the XRP Ledger in its raw format. See [ledger format][] for information on the different types of entries you can retrieve.
|
||||
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
---
|
||||
html: amm_info.html
|
||||
parent: path-and-order-book-methods.html
|
||||
seo:
|
||||
description: Get info about an Automated Market Maker (AMM) instance.
|
||||
labels:
|
||||
- Decentralized Exchange
|
||||
- Cross-Currency
|
||||
- AMM
|
||||
- Decentralized Exchange
|
||||
- Cross-Currency
|
||||
- AMM
|
||||
---
|
||||
# amm_info
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/ripple/rpc/handlers/AMMInfo.cpp "Source")
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/xrpld/rpc/handlers/AMMInfo.cpp "Source")
|
||||
|
||||
The {% code-page-name /%} method gets information about an [Automated Market Maker (AMM)](/docs/concepts/tokens/decentralized-exchange/automated-market-makers) instance.
|
||||
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
seo:
|
||||
description: Get information on order book changes
|
||||
labels:
|
||||
- Decentralized Exchange
|
||||
- Cross-Currency
|
||||
- Decentralized Exchange
|
||||
- Cross-Currency
|
||||
---
|
||||
# book_changes
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/ripple/rpc/BookChanges.h "Source")
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/xrpld/rpc/BookChanges.h "Source")
|
||||
|
||||
The {% code-page-name /%} method reports information about changes to the order books in the [decentralized exchange (DEX)](../../../../concepts/tokens/decentralized-exchange/index.md) compared with the previous ledger version. This may be useful for building "candlestick" charts.
|
||||
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
seo:
|
||||
description: Get info about offers to exchange two currencies.
|
||||
labels:
|
||||
- Decentralized Exchange
|
||||
- Cross-Currency
|
||||
- Decentralized Exchange
|
||||
- Cross-Currency
|
||||
---
|
||||
# book_offers
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/ripple/rpc/handlers/BookOffers.cpp "Source")
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/xrpld/rpc/handlers/BookOffers.cpp "Source")
|
||||
|
||||
The `book_offers` method retrieves a list of [offers](../../../../concepts/tokens/decentralized-exchange/offers.md) between two currencies, also known as an _order book_. The response omits [unfunded offers](../../../../concepts/tokens/decentralized-exchange/offers.md#lifecycle-of-an-offer) and reports how much of each remaining offer's total is currently funded.
|
||||
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
seo:
|
||||
description: Check whether an account is authorized to send money directly to another.
|
||||
labels:
|
||||
- Accounts
|
||||
- Security
|
||||
- Accounts
|
||||
- Security
|
||||
---
|
||||
# deposit_authorized
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/817d2339b8632cb2f97d3edd6f7af33aa7631744/src/ripple/rpc/handlers/DepositAuthorized.cpp "Source")
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/xrpld/rpc/handlers/DepositAuthorized.cpp "Source")
|
||||
|
||||
The `deposit_authorized` command indicates whether one account is authorized to send payments directly to another. See [Deposit Authorization](../../../../concepts/accounts/depositauth.md) for information on how to require authorization to deliver money to your account.
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ labels:
|
||||
- Oracle
|
||||
---
|
||||
# get_aggregate_price
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/ripple/rpc/handlers/GetAggregatePrice.cpp "Source")
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/xrpld/rpc/handlers/GetAggregatePrice.cpp "Source")
|
||||
|
||||
The `get_aggregate_price` method retrieves the aggregate price of specified `Oracle` objects, returning three price statistics: mean, median, and trimmed mean.
|
||||
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
---
|
||||
html: nft_buy_offers.html
|
||||
parent: path-and-order-book-methods.html
|
||||
seo:
|
||||
description: Get a list of all buy offers for a NFToken.
|
||||
labels:
|
||||
- Non-fungible Tokens, NFTs, NFTokens
|
||||
- NFTs
|
||||
---
|
||||
# nft_buy_offers
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/ripple/rpc/handlers/NFTOffers.cpp "Source")
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/xrpld/rpc/handlers/NFTOffers.cpp "Source")
|
||||
|
||||
The `nft_buy_offers` method returns a list of buy offers for a given [NFToken][] object.
|
||||
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
---
|
||||
html: nft_sell_offers.html
|
||||
parent: path-and-order-book-methods.html
|
||||
seo:
|
||||
description: Get a list of all sell offers for a NFToken.
|
||||
labels:
|
||||
- Non-fungible Tokens, NFTs, NFTokens
|
||||
- NFTs
|
||||
---
|
||||
# nft_sell_offers
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/ripple/rpc/handlers/NFTOffers.cpp "Source")
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/xrpld/rpc/handlers/NFTOffers.cpp "Source")
|
||||
|
||||
The `nft_sell_offers` method returns a list of sell offers for a given [NFToken][] object.
|
||||
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
---
|
||||
html: path_find.html
|
||||
parent: path-and-order-book-methods.html
|
||||
seo:
|
||||
description: Find a path for a payment between two accounts and receive updates.
|
||||
labels:
|
||||
- Cross-Currency
|
||||
- Tokens
|
||||
- Cross-Currency
|
||||
- Tokens
|
||||
---
|
||||
# path_find
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/ripple/rpc/handlers/PathFind.cpp "Source")
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/xrpld/rpc/handlers/PathFind.cpp "Source")
|
||||
|
||||
*WebSocket API only!* The `path_find` method searches for a [path](../../../../concepts/tokens/fungible-tokens/paths.md) along which a transaction can possibly be made, and periodically sends updates when the path changes over time. For a simpler version that is supported by JSON-RPC, see the [ripple_path_find method][]. For payments occurring strictly in XRP, it is not necessary to find a path, because XRP can be sent directly to any account.
|
||||
|
||||
@@ -21,7 +19,6 @@ There are three different modes, or sub-commands, of the path_find command. Spec
|
||||
Although the `rippled` server tries to find the cheapest path or combination of paths for making a payment, it is not guaranteed that the paths returned by this method are, in fact, the best paths. Due to server load, pathfinding may not find the best results. Additionally, you should be careful with the pathfinding results from untrusted servers. A server could be modified to return less-than-optimal paths to earn money for its operators. If you do not have your own server that you can trust with pathfinding, you should compare the results of pathfinding from multiple servers run by different parties, to minimize the risk of a single server returning poor results. (**Note:** A server returning less-than-optimal results is not necessarily proof of malicious behavior; it could also be a symptom of heavy server load.)
|
||||
|
||||
## path_find create
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/ripple/rpc/handlers/PathFind.cpp#L50-L56 "Source")
|
||||
|
||||
The `create` sub-command of `path_find` creates an ongoing request to find possible paths along which a payment transaction could be made from one specified account such that another account receives a desired amount of some currency. The initial response contains a suggested path between the two addresses that would result in the desired amount being received. After that, the server sends additional messages, with `"type": "path_find"`, with updates to the potential paths. The frequency of updates is left to the discretion of the server, but it usually means once every few seconds when there is a new ledger version.
|
||||
|
||||
@@ -62,9 +59,8 @@ The request includes the following parameters:
|
||||
| `destination_account` | String - [Address][] | Yes | The account to find a path to. (In other words, the account that would receive a payment.) |
|
||||
| `destination_amount` | [Currency Amount][] | Yes | How much the destination account would receive. **Special case:** You can specify `"-1"` (for XRP) or provide -1 as the contents of the `value` field (for tokens). This requests a path to deliver as much as possible, while spending no more than the amount specified in `send_max` (if provided). |
|
||||
| `domain` | String - [Hash][] | No | The ledger entry ID of a permissioned domain. If provided, only return paths that use the corresponding [permissioned DEX](../../../../concepts/tokens/decentralized-exchange/permissioned-dexes.md). {% amendment-disclaimer name="PermissionedDEX" /%} |
|
||||
| `paths` | Array | No | Array of arrays of objects, representing [payment paths](../../../../concepts/tokens/fungible-tokens/paths.md) to check.
|
||||
| `send_max` | [Currency Amount][] | No | Maximum amount that would be spent. Not compatible with `source_currencies`. |
|
||||
You can use this to keep updated on changes to particular paths you already know about, or to check the overall cost to make a payment along a certain path. |
|
||||
| `paths` | Array | No | Array of arrays of objects, representing [payment paths](../../../../concepts/tokens/fungible-tokens/paths.md) to check. You can use this to keep updated on changes to particular paths you already know about, or to check the overall cost to make a payment along a certain path. |
|
||||
| `send_max` | [Currency Amount][] | No | Maximum amount that would be spent. Not compatible with `source_currencies`. |
|
||||
|
||||
The server also recognizes the following fields, but the results of using them are not guaranteed: `source_currencies`, `bridges`. These fields should be considered reserved for future use.
|
||||
|
||||
@@ -75,392 +71,28 @@ An example of a successful response:
|
||||
{% tabs %}
|
||||
|
||||
{% tab label="WebSocket" %}
|
||||
```json
|
||||
{
|
||||
"id": 1,
|
||||
"status": "success",
|
||||
"type": "response",
|
||||
"result": {
|
||||
"alternatives": [
|
||||
{
|
||||
"paths_computed": [
|
||||
[
|
||||
{
|
||||
"currency": "USD",
|
||||
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
|
||||
"type": 48,
|
||||
"type_hex": "0000000000000030"
|
||||
},
|
||||
{
|
||||
"account": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
|
||||
"type": 1,
|
||||
"type_hex": "0000000000000001"
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"currency": "USD",
|
||||
"issuer": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
|
||||
"type": 48,
|
||||
"type_hex": "0000000000000030"
|
||||
},
|
||||
{
|
||||
"account": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
|
||||
"type": 1,
|
||||
"type_hex": "0000000000000001"
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"currency": "USD",
|
||||
"issuer": "r9vbV3EHvXWjSkeQ6CAcYVPGeq7TuiXY2X",
|
||||
"type": 48,
|
||||
"type_hex": "0000000000000030"
|
||||
},
|
||||
{
|
||||
"account": "r9vbV3EHvXWjSkeQ6CAcYVPGeq7TuiXY2X",
|
||||
"type": 1,
|
||||
"type_hex": "0000000000000001"
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"currency": "USD",
|
||||
"issuer": "rLEsXccBGNR3UPuPu2hUXPjziKC3qKSBun",
|
||||
"type": 48,
|
||||
"type_hex": "0000000000000030"
|
||||
},
|
||||
{
|
||||
"account": "rLEsXccBGNR3UPuPu2hUXPjziKC3qKSBun",
|
||||
"type": 1,
|
||||
"type_hex": "0000000000000001"
|
||||
}
|
||||
]
|
||||
],
|
||||
"source_amount": "251686"
|
||||
},
|
||||
{
|
||||
"paths_computed": [
|
||||
[
|
||||
{
|
||||
"account": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
|
||||
"type": 1,
|
||||
"type_hex": "0000000000000001"
|
||||
},
|
||||
{
|
||||
"currency": "USD",
|
||||
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
|
||||
"type": 48,
|
||||
"type_hex": "0000000000000030"
|
||||
},
|
||||
{
|
||||
"account": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
|
||||
"type": 1,
|
||||
"type_hex": "0000000000000001"
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"account": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
|
||||
"type": 1,
|
||||
"type_hex": "0000000000000001"
|
||||
},
|
||||
{
|
||||
"currency": "USD",
|
||||
"issuer": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
|
||||
"type": 48,
|
||||
"type_hex": "0000000000000030"
|
||||
},
|
||||
{
|
||||
"account": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
|
||||
"type": 1,
|
||||
"type_hex": "0000000000000001"
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"account": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
|
||||
"type": 1,
|
||||
"type_hex": "0000000000000001"
|
||||
},
|
||||
{
|
||||
"currency": "USD",
|
||||
"issuer": "rLEsXccBGNR3UPuPu2hUXPjziKC3qKSBun",
|
||||
"type": 48,
|
||||
"type_hex": "0000000000000030"
|
||||
},
|
||||
{
|
||||
"account": "rLEsXccBGNR3UPuPu2hUXPjziKC3qKSBun",
|
||||
"type": 1,
|
||||
"type_hex": "0000000000000001"
|
||||
}
|
||||
]
|
||||
],
|
||||
"source_amount": {
|
||||
"currency": "BTC",
|
||||
"issuer": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
||||
"value": "0.000001541291269274307"
|
||||
}
|
||||
},
|
||||
{
|
||||
"paths_computed": [
|
||||
[
|
||||
{
|
||||
"account": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
|
||||
"type": 1,
|
||||
"type_hex": "0000000000000001"
|
||||
},
|
||||
{
|
||||
"currency": "USD",
|
||||
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
|
||||
"type": 48,
|
||||
"type_hex": "0000000000000030"
|
||||
},
|
||||
{
|
||||
"account": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
|
||||
"type": 1,
|
||||
"type_hex": "0000000000000001"
|
||||
}
|
||||
]
|
||||
],
|
||||
"source_amount": {
|
||||
"currency": "CHF",
|
||||
"issuer": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
||||
"value": "0.0009211546262510451"
|
||||
}
|
||||
},
|
||||
{
|
||||
"paths_computed": [
|
||||
[
|
||||
{
|
||||
"account": "razqQKzJRdB4UxFPWf5NEpEG3WMkmwgcXA",
|
||||
"type": 1,
|
||||
"type_hex": "0000000000000001"
|
||||
},
|
||||
{
|
||||
"currency": "USD",
|
||||
"issuer": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
|
||||
"type": 48,
|
||||
"type_hex": "0000000000000030"
|
||||
},
|
||||
{
|
||||
"account": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
|
||||
"type": 1,
|
||||
"type_hex": "0000000000000001"
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"account": "razqQKzJRdB4UxFPWf5NEpEG3WMkmwgcXA",
|
||||
"type": 1,
|
||||
"type_hex": "0000000000000001"
|
||||
},
|
||||
{
|
||||
"currency": "USD",
|
||||
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
|
||||
"type": 48,
|
||||
"type_hex": "0000000000000030"
|
||||
},
|
||||
{
|
||||
"account": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
|
||||
"type": 1,
|
||||
"type_hex": "0000000000000001"
|
||||
}
|
||||
]
|
||||
],
|
||||
"source_amount": {
|
||||
"currency": "CNY",
|
||||
"issuer": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
||||
"value": "0.006293562"
|
||||
}
|
||||
},
|
||||
{
|
||||
"paths_computed": [
|
||||
[
|
||||
{
|
||||
"account": "rGwUWgN5BEg3QGNY3RX2HfYowjUTZdid3E",
|
||||
"type": 1,
|
||||
"type_hex": "0000000000000001"
|
||||
},
|
||||
{
|
||||
"currency": "USD",
|
||||
"issuer": "rLEsXccBGNR3UPuPu2hUXPjziKC3qKSBun",
|
||||
"type": 48,
|
||||
"type_hex": "0000000000000030"
|
||||
},
|
||||
{
|
||||
"account": "rLEsXccBGNR3UPuPu2hUXPjziKC3qKSBun",
|
||||
"type": 1,
|
||||
"type_hex": "0000000000000001"
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"account": "rGwUWgN5BEg3QGNY3RX2HfYowjUTZdid3E",
|
||||
"type": 1,
|
||||
"type_hex": "0000000000000001"
|
||||
},
|
||||
{
|
||||
"currency": "USD",
|
||||
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
|
||||
"type": 48,
|
||||
"type_hex": "0000000000000030"
|
||||
},
|
||||
{
|
||||
"account": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
|
||||
"type": 1,
|
||||
"type_hex": "0000000000000001"
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"account": "rGwUWgN5BEg3QGNY3RX2HfYowjUTZdid3E",
|
||||
"type": 1,
|
||||
"type_hex": "0000000000000001"
|
||||
},
|
||||
{
|
||||
"currency": "USD",
|
||||
"issuer": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
|
||||
"type": 48,
|
||||
"type_hex": "0000000000000030"
|
||||
},
|
||||
{
|
||||
"account": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
|
||||
"type": 1,
|
||||
"type_hex": "0000000000000001"
|
||||
}
|
||||
]
|
||||
],
|
||||
"source_amount": {
|
||||
"currency": "DYM",
|
||||
"issuer": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
||||
"value": "0.0007157142857142858"
|
||||
}
|
||||
},
|
||||
{
|
||||
"paths_computed": [
|
||||
[
|
||||
{
|
||||
"account": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
|
||||
"type": 1,
|
||||
"type_hex": "0000000000000001"
|
||||
},
|
||||
{
|
||||
"currency": "USD",
|
||||
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
|
||||
"type": 48,
|
||||
"type_hex": "0000000000000030"
|
||||
},
|
||||
{
|
||||
"account": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
|
||||
"type": 1,
|
||||
"type_hex": "0000000000000001"
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"account": "rLEsXccBGNR3UPuPu2hUXPjziKC3qKSBun",
|
||||
"type": 1,
|
||||
"type_hex": "0000000000000001"
|
||||
},
|
||||
{
|
||||
"currency": "USD",
|
||||
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
|
||||
"type": 48,
|
||||
"type_hex": "0000000000000030"
|
||||
},
|
||||
{
|
||||
"account": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
|
||||
"type": 1,
|
||||
"type_hex": "0000000000000001"
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"account": "rLEsXccBGNR3UPuPu2hUXPjziKC3qKSBun",
|
||||
"type": 1,
|
||||
"type_hex": "0000000000000001"
|
||||
},
|
||||
{
|
||||
"currency": "USD",
|
||||
"issuer": "rLEsXccBGNR3UPuPu2hUXPjziKC3qKSBun",
|
||||
"type": 48,
|
||||
"type_hex": "0000000000000030"
|
||||
},
|
||||
{
|
||||
"account": "rLEsXccBGNR3UPuPu2hUXPjziKC3qKSBun",
|
||||
"type": 1,
|
||||
"type_hex": "0000000000000001"
|
||||
}
|
||||
]
|
||||
],
|
||||
"source_amount": {
|
||||
"currency": "EUR",
|
||||
"issuer": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
||||
"value": "0.0007409623616236163"
|
||||
}
|
||||
},
|
||||
{
|
||||
"paths_computed": [
|
||||
[
|
||||
{
|
||||
"account": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
|
||||
"type": 1,
|
||||
"type_hex": "0000000000000001"
|
||||
},
|
||||
{
|
||||
"currency": "USD",
|
||||
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
|
||||
"type": 48,
|
||||
"type_hex": "0000000000000030"
|
||||
},
|
||||
{
|
||||
"account": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
|
||||
"type": 1,
|
||||
"type_hex": "0000000000000001"
|
||||
}
|
||||
]
|
||||
],
|
||||
"source_amount": {
|
||||
"currency": "JPY",
|
||||
"issuer": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
||||
"value": "0.103412412"
|
||||
}
|
||||
}
|
||||
],
|
||||
"destination_account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
||||
"destination_amount": {
|
||||
"currency": "USD",
|
||||
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
|
||||
"value": "0.001"
|
||||
},
|
||||
"id": 1,
|
||||
"source_account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
||||
"full_reply": false
|
||||
}
|
||||
}
|
||||
```
|
||||
{% code-snippet file="/_api-examples/path_find/create-response.json" /%}
|
||||
{% /tab %}
|
||||
|
||||
{% /tabs %}
|
||||
|
||||
The initial response follows the [standard format](../../api-conventions/response-formatting.md), with a successful result containing the following fields:
|
||||
|
||||
| Field | Type | Description |
|
||||
|:----------------------|:-----------------|:----------------------------------|
|
||||
| `alternatives` | Array | Array of objects with suggested [paths](../../../../concepts/tokens/fungible-tokens/paths.md) to take, as described below. If empty, then no paths were found connecting the source and destination accounts. |
|
||||
| `destination_account` | String | Unique address of the account that would receive a transaction. |
|
||||
| `destination_amount` | String or Object | [Currency Amount][] that the destination would receive in a transaction. |
|
||||
| `source_account` | String | Unique address that would send a transaction. |
|
||||
| `full_reply` | Boolean | If `false`, this is the result of an incomplete search. A later reply may have a better path. If `true`, then this is the best path found. (It is still theoretically possible that a better path could exist, but `rippled` won't find it.) Until you close the pathfinding request, `rippled` continues to send updates each time a new ledger closes. |
|
||||
| Field | Type | Description |
|
||||
|:----------------------|:---------------------|:----------------------------------|
|
||||
| `alternatives` | Array | Array of objects with suggested [paths](../../../../concepts/tokens/fungible-tokens/paths.md) to take, as described below. If empty, then no paths were found connecting the source and destination accounts. |
|
||||
| `destination_account` | String - [Address][] | The account that would receive a transaction. |
|
||||
| `destination_amount` | [Currency Amount][] | How much the destination would receive in a transaction. |
|
||||
| `source_account` | String - [Address][] | The account that would send a transaction. |
|
||||
| `full_reply` | Boolean | If `false`, this is the result of an incomplete search. A later reply may have a better path. If `true`, then this is the best path found. (It is still theoretically possible that a better path could exist, but `rippled` won't find it.) Until you close the pathfinding request, `rippled` continues to send updates each time a new ledger closes. |
|
||||
|
||||
Each element in the `alternatives` array is an object that represents a path from one possible source currency (held by the initiating account) to the destination account and currency. This object has the following fields:
|
||||
|
||||
| Field | Type | Description |
|
||||
|:---------------------|:-----------------|:---------------------------------------|
|
||||
| `paths_computed` | Array | Array of arrays of objects defining [payment paths](../../../../concepts/tokens/fungible-tokens/paths.md) |
|
||||
| `source_amount` | String or Object | [Currency Amount][] that the source would have to send along this path for the destination to receive the desired amount. |
|
||||
| `destination_amount` | String or Object | _(May be omitted)_ [Currency Amount][] that the destination would receive along this path. Only included if the `destination_amount` from the request was the "-1" special case. |
|
||||
| Field | Type | Description |
|
||||
|:---------------------|:--------------------|:---------------------------------------|
|
||||
| `paths_computed` | Array | Array of arrays of objects defining [payment paths](../../../../concepts/tokens/fungible-tokens/paths.md) |
|
||||
| `source_amount` | [Currency Amount][] | How much the source would have to send along this path for the destination to receive the desired amount. |
|
||||
| `destination_amount` | [Currency Amount][] | _(May be omitted)_ How much the destination would receive along this path. Only included if the `destination_amount` from the request was the "-1" special case. |
|
||||
|
||||
### Possible Errors
|
||||
|
||||
@@ -479,28 +111,12 @@ Here is an example of an asynchronous follow-up from a path_find create request:
|
||||
{% tabs %}
|
||||
|
||||
{% tab label="WebSocket" %}
|
||||
```json
|
||||
{
|
||||
"id": 1,
|
||||
"type": "path_find",
|
||||
"alternatives": [
|
||||
/* paths omitted from this example; same format as the initial response */
|
||||
],
|
||||
"destination_account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
||||
"destination_amount": {
|
||||
"currency": "USD",
|
||||
"issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
|
||||
"value": "0.001"
|
||||
},
|
||||
"source_account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59"
|
||||
}
|
||||
```
|
||||
{% code-snippet file="/_api-examples/path_find/create-followup.json" /%}
|
||||
{% /tab %}
|
||||
|
||||
{% /tabs %}
|
||||
|
||||
## path_find close
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/ripple/rpc/handlers/PathFind.cpp#L58-L67 "Source")
|
||||
|
||||
The `close` sub-command of `path_find` instructs the server to stop sending information about the current open pathfinding request.
|
||||
|
||||
@@ -545,7 +161,6 @@ If there was no outstanding pathfinding request, an error is returned instead.
|
||||
* `noPathRequest` - You tried to close a pathfinding request when there is not an open one.
|
||||
|
||||
## path_find status
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/ripple/rpc/handlers/PathFind.cpp#L69-L77 "Source")
|
||||
|
||||
The `status` sub-command of `path_find` requests an immediate update about the client's currently-open pathfinding request.
|
||||
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
---
|
||||
html: ripple_path_find.html
|
||||
parent: path-and-order-book-methods.html
|
||||
seo:
|
||||
description: Find a path for payment between two accounts, once.
|
||||
labels:
|
||||
- Cross-Currency
|
||||
- Tokens
|
||||
- Cross-Currency
|
||||
- Tokens
|
||||
---
|
||||
# ripple_path_find
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/ripple/rpc/handlers/RipplePathFind.cpp "Source")
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/xrpld/rpc/handlers/RipplePathFind.cpp "Source")
|
||||
|
||||
The `ripple_path_find` method is a simplified version of the [path_find method][] that provides a single response with a [payment path](../../../../concepts/tokens/fungible-tokens/paths.md) you can use right away. It is available in both the WebSocket and JSON-RPC APIs. However, the results tend to become outdated as time passes. Instead of making multiple calls to stay updated, you should instead use the [path_find method][] to subscribe to continued updates where possible.
|
||||
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
seo:
|
||||
description: Sign a claim for money from a payment channel.
|
||||
labels:
|
||||
- Payment Channels
|
||||
- Payment Channels
|
||||
---
|
||||
# channel_authorize
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/d4a56f223a3b80f64ff70b4e90ab6792806929ca/src/ripple/rpc/handlers/PayChanClaim.cpp#L41 "Source")
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/xrpld/rpc/handlers/PayChanClaim.cpp "Source")
|
||||
|
||||
The `channel_authorize` method creates a signature that can be used to redeem a specific amount of XRP from a payment channel.
|
||||
|
||||
{% partial file="/docs/_snippets/public-signing-note.md" /%}
|
||||
|
||||
{% amendment-disclaimer name="PayChan" /%}
|
||||
|
||||
## Request Format
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
---
|
||||
html: channel_verify.html
|
||||
parent: payment-channel-methods.html
|
||||
seo:
|
||||
description: Check a payment channel claim's signature.
|
||||
labels:
|
||||
- Payment Channels
|
||||
- Payment Channels
|
||||
---
|
||||
# channel_verify
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/d4a56f223a3b80f64ff70b4e90ab6792806929ca/src/ripple/rpc/handlers/PayChanClaim.cpp#L89 "Source")
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/xrpld/rpc/handlers/PayChanClaim.cpp "Source")
|
||||
|
||||
The `channel_verify` method checks the validity of a signature that can be used to redeem a specific amount of XRP from a payment channel.
|
||||
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
---
|
||||
html: fee.html
|
||||
parent: server-info-methods.html
|
||||
seo:
|
||||
description: Get information about transaction cost.
|
||||
labels:
|
||||
- Fees
|
||||
- Fees
|
||||
---
|
||||
# fee
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/release/src/ripple/rpc/handlers/Fee1.cpp "Source")
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/xrpld/rpc/handlers/Fee1.cpp "Source")
|
||||
|
||||
The `fee` command reports the current state of the open-ledger requirements for the [transaction cost](../../../../concepts/transactions/transaction-cost.md). This requires the [FeeEscalation amendment][] to be enabled.
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
seo:
|
||||
description: Look up the public information about a known validator.
|
||||
labels:
|
||||
- Blockchain
|
||||
- Blockchain
|
||||
---
|
||||
# manifest
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/ripple/rpc/handlers/Manifest.cpp "Source")
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/xrpld/rpc/handlers/DoManifest.cpp "Source")
|
||||
|
||||
The {% code-page-name /%} method reports the current "manifest" information for a given validator public key. The "manifest" is a block of data that authorizes an ephemeral signing key with a signature from the validator's master key pair. {% badge href="https://github.com/XRPLF/rippled/releases/tag/1.7.0" %}Updated in: rippled 1.7.0{% /badge %}
|
||||
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
---
|
||||
html: server_info.html
|
||||
parent: server-info-methods.html
|
||||
seo:
|
||||
description: Retrieve status of the server in human-readable format.
|
||||
labels:
|
||||
- Core Server
|
||||
- Core Server
|
||||
---
|
||||
# server_info (rippled)
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/ripple/rpc/handlers/ServerInfo.cpp "Source")
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/xrpld/rpc/handlers/ServerInfo.cpp "Source")
|
||||
|
||||
The `server_info` command asks the server for a human-readable version of various information about [the `rippled` server](../../../../concepts/networks-and-servers/index.md) being queried. For [Clio servers](../../../../concepts/networks-and-servers/the-clio-server.md), see [`server_info` (Clio)](../clio-methods/server_info-clio.md) instead.
|
||||
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
---
|
||||
html: server_state.html
|
||||
parent: server-info-methods.html
|
||||
seo:
|
||||
description: Retrieve status of the server in machine-readable format.
|
||||
labels:
|
||||
- Core Server
|
||||
- Core Server
|
||||
---
|
||||
# server_state
|
||||
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/ripple/rpc/handlers/ServerState.cpp "Source")
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/xrpld/rpc/handlers/ServerState.cpp "Source")
|
||||
|
||||
The `server_state` command asks the server for various machine-readable information about the `rippled` server's current state. The response is almost the same as the [server_info method][], but uses units that are easier to process instead of easier to read. (For example, XRP values are given in integer drops instead of scientific notation or decimal values, and time is given in milliseconds instead of seconds.)
|
||||
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
seo:
|
||||
description: Retrieve API version information.
|
||||
labels:
|
||||
- Core Server
|
||||
- Core Server
|
||||
---
|
||||
# version
|
||||
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/develop/src/ripple/beast/core/SemanticVersion.cpp "Source")
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/xrpld/rpc/handlers/Version.h "Source")
|
||||
|
||||
The `version` command retrieves the API version information for the rippled server. For `Clio` servers, see [`version` (`clio`)](../clio-methods/version.md) instead.
|
||||
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
---
|
||||
html: unsubscribe.html
|
||||
parent: subscription-methods.html
|
||||
seo:
|
||||
description: Stop listening for updates about a particular subject.
|
||||
labels:
|
||||
- Payments
|
||||
- Blockchain
|
||||
- Accounts
|
||||
- Smart Contracts
|
||||
- Payments
|
||||
- Blockchain
|
||||
- Accounts
|
||||
- Smart Contracts
|
||||
---
|
||||
# unsubscribe
|
||||
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/ripple/rpc/handlers/Unsubscribe.cpp "Source")
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/xrpld/rpc/handlers/Unsubscribe.cpp "Source")
|
||||
|
||||
The `unsubscribe` command tells the server to stop sending messages for a particular subscription or set of subscriptions.
|
||||
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
---
|
||||
html: submit.html
|
||||
parent: transaction-methods.html
|
||||
seo:
|
||||
description: Send a transaction to the network.
|
||||
labels:
|
||||
- Transaction Sending
|
||||
- Payments
|
||||
- Transaction Sending
|
||||
- Payments
|
||||
---
|
||||
# submit
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/ripple/rpc/handlers/Submit.cpp "Source")
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/xrpld/rpc/handlers/Submit.cpp "Source")
|
||||
|
||||
The `submit` method applies a [transaction](../../../protocol/transactions/index.md) and sends it to the network to be confirmed and included in future ledgers.
|
||||
|
||||
|
||||
@@ -1,18 +1,14 @@
|
||||
---
|
||||
html: submit_multisigned.html
|
||||
parent: transaction-methods.html
|
||||
seo:
|
||||
description: Send a multi-signed transaction to the network.
|
||||
labels:
|
||||
- Transaction Sending
|
||||
- Transaction Sending
|
||||
---
|
||||
# submit_multisigned
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/release/src/ripple/rpc/handlers/SubmitMultiSigned.cpp "Source")
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/xrpld/rpc/handlers/SubmitMultiSigned.cpp "Source")
|
||||
|
||||
The `submit_multisigned` command applies a [multi-signed](../../../../concepts/accounts/multi-signing.md) transaction and sends it to the network to be included in future ledgers. (You can also submit multi-signed transactions in binary form using the [`submit` command in submit-only mode](submit.md#submit-only-mode).)
|
||||
|
||||
This command requires the [MultiSign amendment][] to be enabled.
|
||||
|
||||
## Request Format
|
||||
An example of the request format:
|
||||
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
---
|
||||
html: transaction_entry.html
|
||||
parent: transaction-methods.html
|
||||
seo:
|
||||
description: Retrieve info about a transaction from a particular ledger version.
|
||||
labels:
|
||||
- Transaction Sending
|
||||
- Transaction Sending
|
||||
---
|
||||
# transaction_entry
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/ripple/rpc/handlers/TransactionEntry.cpp "Source")
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/xrpld/rpc/handlers/TransactionEntry.cpp "Source")
|
||||
|
||||
The `transaction_entry` method retrieves information on a single transaction from a specific ledger version. (The [tx method][], by contrast, searches all ledgers for the specified transaction. We recommend using that method instead.)
|
||||
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
---
|
||||
html: tx.html
|
||||
parent: transaction-methods.html
|
||||
seo:
|
||||
description: Retrieve info about a transaction from all the ledgers on hand.
|
||||
labels:
|
||||
- Transaction Sending
|
||||
- Payments
|
||||
- Transaction Sending
|
||||
- Payments
|
||||
---
|
||||
# tx
|
||||
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/ripple/rpc/handlers/Tx.cpp "Source")
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/xrpld/rpc/handlers/Tx.cpp "Source")
|
||||
|
||||
The `tx` method retrieves information on a single [transaction](../../../protocol/transactions/index.md), by its [identifying hash][] or its [CTID](../../api-conventions/ctid.md).
|
||||
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
---
|
||||
html: tx_history.html
|
||||
parent: transaction-methods.html
|
||||
seo:
|
||||
description: Retrieve info about all recent transactions.
|
||||
---
|
||||
# tx_history
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/ripple/rpc/handlers/TxHistory.cpp "Source")
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/xrpld/rpc/handlers/TxHistory.cpp "Source")
|
||||
|
||||
The `tx_history` method retrieves some of the most recent transactions made.
|
||||
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
---
|
||||
html: ping.html
|
||||
parent: utility-methods.html
|
||||
seo:
|
||||
description: Confirm connectivity with the server.
|
||||
labels:
|
||||
- Core Server
|
||||
- Core Server
|
||||
---
|
||||
# ping
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/ripple/rpc/handlers/Ping.cpp "Source")
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/xrpld/rpc/handlers/Ping.cpp "Source")
|
||||
|
||||
The `ping` command returns an acknowledgement, so that clients can test the connection status and latency.
|
||||
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
---
|
||||
html: random.html
|
||||
parent: utility-methods.html
|
||||
seo:
|
||||
description: Generate a random number.
|
||||
labels:
|
||||
- Core Server
|
||||
- Core Server
|
||||
---
|
||||
# random
|
||||
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/ripple/rpc/handlers/Random.cpp "Source")
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/xrpld/rpc/handlers/Random.cpp "Source")
|
||||
|
||||
The `random` command provides a random number to be used as a source of entropy for random number generation by clients.
|
||||
|
||||
|
||||
@@ -62,10 +62,10 @@ 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.js`.
|
||||
|
||||
### 1. Install Dependencies
|
||||
|
||||
<!-- Web steps -->
|
||||
{% step id="import-web-tag" when={ "environment": "Web" } %}
|
||||
### 1. Install Dependencies
|
||||
|
||||
To load `xrpl.js` into your project, add a `<script>` tag to your HTML.
|
||||
|
||||
You can load the library from a CDN as in the example, or download a release and host it on your own website.
|
||||
@@ -74,7 +74,8 @@ This loads the module into the top level as `xrpl`.
|
||||
{% /step %}
|
||||
|
||||
<!-- Node.js steps -->
|
||||
{% step id="install-node-tag" when={ "environment": "Node" } %}
|
||||
{% step id="import-node-tag" when={ "environment": "Node" } %}
|
||||
### 1. Install Dependencies
|
||||
|
||||
Start a new project by creating an empty folder, then move into that folder and use [NPM](https://www.npmjs.com/) to install the latest version of xrpl.js:
|
||||
|
||||
@@ -94,7 +95,7 @@ Your `package.json` file should look something like this:
|
||||
{% 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.js`, you create an instance of the `Client` class and use the `connect()` method.
|
||||
To make queries and submit transactions, you need to connect to the XRP Ledger. To do this with `xrpl.js`, you create an instance of the [`Client`](https://js.xrpl.org/classes/Client.html) class and use the [`connect()`](https://js.xrpl.org/classes/Client.html#connect) method.
|
||||
|
||||
{% admonition type="success" name="Tip" %}Many network functions in `xrpl.js` use [Promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) to return values asynchronously. The code samples here use the [`async/await` pattern](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Asynchronous/Async_await) to wait for the actual result of the Promises.{% /admonition %}
|
||||
|
||||
@@ -130,46 +131,48 @@ The sample code shows you how to connect to the Testnet, which is one of the ava
|
||||
{% step id="get-account-create-wallet-tag" %}
|
||||
#### Create and Fund a Wallet
|
||||
|
||||
The `xrpl.js` library has a `Wallet` class for handling the keys and address of an XRP Ledger account. On Testnet, you can fund a new account as shown in the example.
|
||||
The `xrpl.js` library has a [`Wallet`](https://js.xrpl.org/classes/Wallet.html) class for handling the keys and address of an XRP Ledger account. On Testnet, you can fund a new account as shown in the example.
|
||||
{% /step %}
|
||||
|
||||
{% step id="get-account-create-wallet-b-tag" %}
|
||||
#### (Optional) Generate a Wallet Only
|
||||
|
||||
If you want to generate a wallet without funding it, you can create a new `Wallet` instance. Keep in mind that you need to send XRP to the wallet for it to be a valid account on the ledger.
|
||||
If you want to generate a wallet without funding it, you can create a new [`Wallet`](https://js.xrpl.org/classes/Wallet.html) instance. Keep in mind that you need to send XRP to the wallet for it to be a valid account on the ledger.
|
||||
{% /step %}
|
||||
|
||||
{% step id="get-account-create-wallet-c-tag" %}
|
||||
#### (Optional) Use Your Own Wallet Seed
|
||||
|
||||
To use an existing wallet seed encoded in [base58][], you can create a `Wallet` instance from it.
|
||||
To use an existing wallet seed encoded in [base58][], you can create a [`Wallet`](https://js.xrpl.org/classes/Wallet.html) instance from it.
|
||||
{% /step %}
|
||||
|
||||
### 4. Query the XRP Ledger
|
||||
|
||||
{% step id="query-xrpl-tag" %}
|
||||
Use the Client's `request()` method to access the XRP Ledger's [WebSocket API](../../../references/http-websocket-apis/api-conventions/request-formatting.md).
|
||||
{% /step %}
|
||||
### 4. Query the XRP Ledger
|
||||
|
||||
### 5. Listen for Events
|
||||
Use the Client's [`request()`](https://js.xrpl.org/classes/Client.html#request) method to access the XRP Ledger's [WebSocket API](../../../references/http-websocket-apis/api-conventions/request-formatting.md).
|
||||
{% /step %}
|
||||
|
||||
{% step id="listen-for-events-tag" %}
|
||||
You can set up handlers for various types of events in `xrpl.js`, such as whenever the XRP Ledger's [consensus process](../../../concepts/consensus-protocol/index.md) produces a new [ledger version](../../../concepts/ledgers/index.md). To do that, first call the [subscribe method][] to get the type of events you want, then attach an event handler using the `on(eventType, callback)` method of the client.
|
||||
### 5. Listen for Events
|
||||
|
||||
You can set up handlers for various types of events in `xrpl.js`, such as whenever the XRP Ledger's [consensus process](../../../concepts/consensus-protocol/index.md) produces a new [ledger version](../../../concepts/ledgers/index.md). To do that, first call the [subscribe method][] to get the type of events you want, then attach an event handler using the [`on(eventType, callback)`](https://js.xrpl.org/classes/Client.html#on) method of the client.
|
||||
{% /step %}
|
||||
|
||||
{% step id="disconnect-node-tag" when={ "environment": "Node" } %}
|
||||
### 6. Disconnect
|
||||
|
||||
{% step id="disconnect-node-tag" when={ "environment": "Node" } %}
|
||||
Disconnect when done so Node.js can end the process. The example code waits 10 seconds before disconnecting to allow time for the ledger event listener to receive and display events.
|
||||
Call the [`disconnect()`](https://js.xrpl.org/classes/Client.html#disconnect) function so Node.js can end the process. The example code waits 10 seconds before disconnecting to allow time for the ledger event listener to receive and display events.
|
||||
{% /step %}
|
||||
|
||||
{% step id="disconnect-web-tag" when={ "environment": "Web" } %}
|
||||
Disconnect from the ledger when done. The example code waits 10 seconds before disconnecting to allow time for the ledger event listener to receive and display events.
|
||||
### 6. Disconnect
|
||||
|
||||
Call the [`disconnect()`](https://js.xrpl.org/classes/Client.html#disconnect) function to disconnect from the ledger when done. The example code waits 10 seconds before disconnecting to allow time for the ledger event listener to receive and display events.
|
||||
{% /step %}
|
||||
|
||||
{% step id="run-app-node-tag" when={ "environment": "Node" } %}
|
||||
### 7. Run the Application
|
||||
|
||||
{% step id="run-app-node-tag" when={ "environment": "Node" } %}
|
||||
Finally, in your terminal, run the application like so:
|
||||
|
||||
```sh
|
||||
@@ -237,6 +240,8 @@ Disconnected
|
||||
{% /step %}
|
||||
|
||||
{% step id="run-app-web-tag" when={ "environment": "Web" } %}
|
||||
### 7. Run the Application
|
||||
|
||||
Open the `index.html` file in a web browser.
|
||||
|
||||
You should see output similar to the following:
|
||||
|
||||
@@ -1,63 +1,97 @@
|
||||
---
|
||||
seo:
|
||||
description: Build a Python app that interacts with the XRP Ledger.
|
||||
top_nav_name: Python
|
||||
top_nav_grouping: Get Started
|
||||
labels:
|
||||
- Development
|
||||
---
|
||||
|
||||
{% 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"]
|
||||
}
|
||||
]
|
||||
%}
|
||||
|
||||
# Get Started Using Python Library
|
||||
|
||||
This tutorial walks you through the basics of building an XRP Ledger-connected application using [`xrpl-py`](https://github.com/XRPLF/xrpl-py), a pure [Python](https://www.python.org) library built to interact with the XRP Ledger using native Python models and methods.
|
||||
This tutorial walks you through the basics of building an XRP Ledger-connected application using the [`xrpl-py`](https://github.com/XRPLF/xrpl-py) client library, a pure [Python](https://www.python.org) library built to interact with the XRP Ledger using native Python models and methods.
|
||||
|
||||
This tutorial is intended for beginners and should take no longer than 30 minutes to complete.
|
||||
|
||||
## Learning Goals
|
||||
## Goals
|
||||
|
||||
In this tutorial, you'll learn:
|
||||
|
||||
* The basic building blocks of XRP Ledger-based applications.
|
||||
* How to connect to the XRP Ledger using `xrpl-py`.
|
||||
* How to get an account on the [Testnet](/resources/dev-tools/xrp-faucets) using `xrpl-py`.
|
||||
* How to use the `xrpl-py` library to look up information about an account on the XRP Ledger.
|
||||
* How to put these steps together to create a Python app.
|
||||
- The basic building blocks of XRP Ledger-based applications.
|
||||
- How to connect to the XRP Ledger using `xrpl-py`.
|
||||
- How to get an account on the [Testnet](/resources/dev-tools/xrp-faucets) using `xrpl-py`.
|
||||
- How to use the `xrpl-py` library to look up information about an account on the XRP Ledger.
|
||||
- How to put these steps together to create a Python app.
|
||||
|
||||
## Requirements
|
||||
## Prerequisites
|
||||
|
||||
The `xrpl-py` library supports [Python 3.7](https://www.python.org/downloads/) and later.
|
||||
To complete this tutorial, you should meet the following guidelines:
|
||||
|
||||
- Have a basic understanding of Python.
|
||||
- Have installed [Python 3.7](https://www.python.org/downloads/) or later.
|
||||
|
||||
## Installation
|
||||
## Source Code
|
||||
|
||||
The [`xrpl-py` library](https://github.com/XRPLF/xrpl-py) is available on [PyPI](https://pypi.org/project/xrpl-py/). Install with `pip`: <!-- SPELLING_IGNORE: pypi -->
|
||||
Click **Download** on the top right of the code preview panel to download the source code.
|
||||
|
||||
## Steps
|
||||
|
||||
```py
|
||||
pip3 install xrpl-py
|
||||
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:
|
||||
|
||||
```sh
|
||||
# Create and activate a virtual environment
|
||||
python -m venv .venv
|
||||
source .venv/bin/activate
|
||||
|
||||
# Install the xrpl-py library
|
||||
pip install xrpl-py
|
||||
```
|
||||
|
||||
## Start Building
|
||||
Alternatively, if you're using the downloaded source code, you can install all dependencies from the `requirements.txt` file:
|
||||
|
||||
When you're working with the XRP Ledger, there are a few things you'll need to manage, whether you're adding XRP to your [account](../../../concepts/accounts/index.md), integrating with the [decentralized exchange](../../../concepts/tokens/decentralized-exchange/index.md), or [issuing tokens](../../../concepts/tokens/index.md). This tutorial walks you through basic patterns common to getting started with all of these use cases and provides sample code for implementing them.
|
||||
```sh
|
||||
python -m venv .venv
|
||||
source .venv/bin/activate
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
{% /step %}
|
||||
|
||||
Here are the basic steps you'll need to cover for almost any XRP Ledger project:
|
||||
### 2. Connect to the XRP Ledger
|
||||
|
||||
1. [Connect to the XRP Ledger.](#1-connect-to-the-xrp-ledger)
|
||||
1. [Get an account.](#2-get-account)
|
||||
1. [Query the XRP Ledger.](#3-query-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).
|
||||
|
||||
### 1. Connect to the XRP Ledger
|
||||
{% admonition type="info" name="Note" %}
|
||||
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.
|
||||
{% /admonition %}
|
||||
|
||||
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):
|
||||
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).
|
||||
{% /step %}
|
||||
|
||||
{% code-snippet file="/_code-samples/get-started/py/get-acct-info.py" from="# Define the network client" before="# Create a wallet using the testnet faucet:" language="py" /%}
|
||||
|
||||
#### Connect to the production XRP Ledger
|
||||
{% 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:
|
||||
- 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)
|
||||
@@ -65,146 +99,115 @@ The sample code in the previous section shows you how to connect to the Testnet,
|
||||
|
||||
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][]:
|
||||
- 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 %}
|
||||
|
||||
|
||||
### 2. Get account
|
||||
{% 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.
|
||||
|
||||
{% admonition type="success" name="Tip" %}
|
||||
For testing and development purposes, you can use the [XRP Faucets](/resources/dev-tools/xrp-faucets) to generate keys and fund the account on the Testnet or Devnet. For production purposes, you should take care to store your keys and set up a [secure signing method](../../../concepts/transactions/secure-signing.md). Another difference in production is that XRP has real worth, so you can't get it for free from a faucet.
|
||||
{% /admonition %}
|
||||
|
||||
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:
|
||||
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).
|
||||
{% /step %}
|
||||
|
||||
{% code-snippet file="/_code-samples/get-started/py/get-acct-info.py" from="# Create a wallet using the testnet faucet:" before="# Create an account str from the wallet" language="py" /%}
|
||||
|
||||
|
||||
This method returns a [`Wallet` instance](https://xrpl-py.readthedocs.io/en/latest/source/xrpl.wallet.html#xrpl.wallet.Wallet):
|
||||
|
||||
|
||||
```py
|
||||
print(test_wallet)
|
||||
|
||||
# print output
|
||||
|
||||
public_key:: 022FA613294CD13FFEA759D0185007DBE763331910509EF8F1635B4F84FA08AEE3
|
||||
private_key:: -HIDDEN-
|
||||
classic_address: raaFKKmgf6CRZttTVABeTcsqzRQ51bNR6Q
|
||||
```
|
||||
|
||||
#### Using the account
|
||||
|
||||
In this tutorial we only query details about the generated account from the XRP Ledger, but you can use the values in the `Wallet` instance to prepare, sign, and submit transactions with `xrpl-py`.
|
||||
|
||||
##### Prepare
|
||||
|
||||
To prepare the transaction:
|
||||
|
||||
{% code-snippet file="/_code-samples/get-started/py/prepare-payment.py" from="# Prepare payment" before="# print prepared payment" language="py" /%}
|
||||
|
||||
|
||||
|
||||
##### Sign and submit
|
||||
|
||||
To sign and submit the transaction:
|
||||
|
||||
{% code-snippet file="/_code-samples/get-started/py/prepare-payment.py" from="# Sign and submit the transaction" before="# Print tx response" language="py" /%}
|
||||
|
||||
|
||||
##### Derive an X-address
|
||||
|
||||
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:
|
||||
|
||||
{% code-snippet file="/_code-samples/get-started/py/get-acct-info.py" from="# Derive an x-address from the classic address:" before="# Look up info about your account" language="py" /%}
|
||||
|
||||
The X-address format [packs the address and destination tag](https://github.com/XRPLF/XRPL-Standards/issues/6) into a more user-friendly value.
|
||||
|
||||
|
||||
### 3. Query the XRP Ledger
|
||||
{% 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).
|
||||
|
||||
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](#2-get-account) in the previous step.
|
||||
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 format and catch errors sooner.
|
||||
{% /step %}
|
||||
|
||||
{% step id="run-app-tag" %}
|
||||
### 5. Run the Application
|
||||
|
||||
{% code-snippet file="/_code-samples/get-started/py/get-acct-info.py" from="# Look up info about your account" language="py" /%}
|
||||
|
||||
|
||||
|
||||
### 4. Putting it all together
|
||||
|
||||
Using these building blocks, we can create a Python app that:
|
||||
|
||||
1. Gets an account on the Testnet.
|
||||
2. Connects to the XRP Ledger.
|
||||
3. Looks up and prints information about the account you created.
|
||||
|
||||
|
||||
{% code-snippet file="/_code-samples/get-started/py/get-acct-info.py" language="python" /%}
|
||||
|
||||
To run the app, you can copy and paste the code into an editor or IDE and run it from there. Or you could download the file from the [XRP Ledger Dev Portal repo](https://github.com/XRPLF/xrpl-dev-portal/tree/master/_code-samples/get-started/py) and run it locally:
|
||||
|
||||
Finally, in your terminal, run the application like so:
|
||||
|
||||
```sh
|
||||
git clone git@github.com:XRPLF/xrpl-dev-portal.git
|
||||
cd xrpl-dev-portal/_code-samples/get-started/py/get-acct-info.py
|
||||
python3 get-acct-info.py
|
||||
python get-acct-info.py
|
||||
```
|
||||
|
||||
You should see output similar to this example:
|
||||
|
||||
```sh
|
||||
Classic address:
|
||||
Creating a new wallet and funding it with Testnet XRP...
|
||||
Attempting to fund address ravbHNootpSNQkxyEFCWevSkHsFGDHfyop
|
||||
Faucet fund successful.
|
||||
Wallet: ravbHNootpSNQkxyEFCWevSkHsFGDHfyop
|
||||
Account Testnet Explorer URL:
|
||||
https://testnet.xrpl.org/accounts/ravbHNootpSNQkxyEFCWevSkHsFGDHfyop
|
||||
|
||||
rnQLnSEA1YFMABnCMrkMWFKxnqW6sQ8EWk
|
||||
X-address:
|
||||
|
||||
T7dRN2ktZGYSTyEPWa9SyDevrwS5yDca4m7xfXTGM3bqff8
|
||||
response.status: ResponseStatus.SUCCESS
|
||||
Getting account info...
|
||||
Response Status: ResponseStatus.SUCCESS
|
||||
{
|
||||
"account_data": {
|
||||
"Account": "rnQLnSEA1YFMABnCMrkMWFKxnqW6sQ8EWk",
|
||||
"Balance": "1000000000",
|
||||
"Account": "ravbHNootpSNQkxyEFCWevSkHsFGDHfyop",
|
||||
"Balance": "100000000",
|
||||
"Flags": 0,
|
||||
"LedgerEntryType": "AccountRoot",
|
||||
"OwnerCount": 0,
|
||||
"PreviousTxnID": "5A5203AFF41503539D11ADC41BE4185761C5B78B7ED382E6D001ADE83A59B8DC",
|
||||
"PreviousTxnLgrSeq": 16126889,
|
||||
"Sequence": 16126889,
|
||||
"index": "CAD0F7EF3AB91DA7A952E09D4AF62C943FC1EEE41BE926D632DDB34CAA2E0E8F"
|
||||
"PreviousTxnID": "3DACF2438AD39F294C4EFF6132D5D88BCB65D2F2261C7650F40AC1F6A54C83EA",
|
||||
"PreviousTxnLgrSeq": 12039759,
|
||||
"Sequence": 12039759,
|
||||
"index": "148E6F4B8E4C14018D679A2526200C292BDBC5AB77611BC3AE0CB97CD2FB84E5"
|
||||
},
|
||||
"ledger_current_index": 16126890,
|
||||
"queue_data": {
|
||||
"txn_count": 0
|
||||
"account_flags": {
|
||||
"allowTrustLineClawback": false,
|
||||
"defaultRipple": false,
|
||||
"depositAuth": false,
|
||||
"disableMasterKey": false,
|
||||
"disallowIncomingCheck": false,
|
||||
"disallowIncomingNFTokenOffer": false,
|
||||
"disallowIncomingPayChan": false,
|
||||
"disallowIncomingTrustline": false,
|
||||
"disallowIncomingXRP": false,
|
||||
"globalFreeze": false,
|
||||
"noFreeze": false,
|
||||
"passwordSpent": false,
|
||||
"requireAuthorization": false,
|
||||
"requireDestinationTag": false
|
||||
},
|
||||
"validated": false
|
||||
"ledger_hash": "CA624D717C4FCDD03BAD8C193F374A77A14F7D2566354A4E9617A8DAD896DE71",
|
||||
"ledger_index": 12039759,
|
||||
"validated": true
|
||||
}
|
||||
```
|
||||
|
||||
#### Interpreting the response
|
||||
|
||||
The response fields that you want to inspect in most cases are:
|
||||
|
||||
* `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).
|
||||
- `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.
|
||||
|
||||
* `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.
|
||||
|
||||
* `validated` — Indicates whether the returned data is from 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).
|
||||
- `validated` — Indicates whether the returned data is from 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).
|
||||
|
||||
For a detailed description of every response field, see [account_info](../../../references/http-websocket-apis/public-api-methods/account-methods/account_info.md#response-format).
|
||||
{% /step %}
|
||||
|
||||
## See Also
|
||||
|
||||
## Keep on building
|
||||
|
||||
Now that you know how to use `xrpl-py` to connect to the XRP Ledger, get an account, and look up information about it, you can also use `xrpl-py` to:
|
||||
|
||||
* [Send XRP](../../how-tos/send-xrp.md).
|
||||
* [Set up secure signing](../../../concepts/transactions/secure-signing.md) for your account.
|
||||
- **Concepts:**
|
||||
- [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)
|
||||
- **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)
|
||||
|
||||
{% raw-partial file="/docs/_snippets/common-links.md" /%}
|
||||
|
||||
{% /code-walkthrough %}
|
||||
|
||||
2468
package-lock.json
generated
2468
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -15,7 +15,7 @@
|
||||
"@codemirror/state": "6.5.2",
|
||||
"@codemirror/view": "^6.22.2",
|
||||
"@lezer/highlight": "^1.2.0",
|
||||
"@redocly/realm": "0.122.3",
|
||||
"@redocly/realm": "0.126.0",
|
||||
"@uiw/codemirror-themes": "4.21.21",
|
||||
"@uiw/react-codemirror": "^4.21.21",
|
||||
"@xrplf/isomorphic": "^1.0.0-beta.1",
|
||||
|
||||
Reference in New Issue
Block a user