mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-28 15:45:50 +00:00
Resubmit Python2 updates
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
---
|
||||
html: py-broker-sale.html
|
||||
parent: send-payments-using-python.html
|
||||
parent: quickstart-python.html
|
||||
blurb: Broker a sale between a sell offer and a buy offer.
|
||||
labels:
|
||||
- Accounts
|
||||
@@ -9,7 +9,7 @@ labels:
|
||||
- XRP
|
||||
---
|
||||
|
||||
# Broker an NFT Sale Using Python
|
||||
# Broker an NFT Sale (Python)
|
||||
|
||||
Earlier examples showed how to make buy and sell offers directly between two accounts. Another option is to use a third account as a broker for the sale. The broker acts on behalf of the NFT owner. The seller creates an offer with the broker account as its destination. The broker gathers and evaluates buy offers and chooses which one to accept, adding an agreed-upon fee for arranging the sale. When the broker account accepts a sell offer with a buy offer, the funds and ownership of the NFT are transferred simultaneously, completing the deal. This allows an account to act as a marketplace or personal agent for NFT creators and traders.
|
||||
|
||||
@@ -23,7 +23,7 @@ This example shows how to:
|
||||
|
||||
[](img/quickstart-py23.png)
|
||||
|
||||
You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/quickstart/js/quickstart.zip){.github-code-download} archive to try each of the samples in your own browser.
|
||||
You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/quickstart/py/){.github-code-download} archive to try each of the samples in your own browser.
|
||||
|
||||
## Get Accounts
|
||||
|
||||
@@ -96,7 +96,7 @@ After accepting a buy offer, a best practice for the broker is to cancel all oth
|
||||
|
||||
# Code Walkthrough
|
||||
|
||||
You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/quickstart/js/quickstart.zip){.github-code-download} archive to examine the code samples.
|
||||
You can download the [Quickstart Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/quickstart/py/){.github-code-download} archive to examine the code samples.
|
||||
|
||||
## ripplex5-broker-nfts.js
|
||||
<!-- SPELLING_IGNORE: ripplex5 -->
|
||||
@@ -107,7 +107,6 @@ Import dependencies and create a global variable for `testnet_url`.
|
||||
|
||||
```python
|
||||
import xrpl
|
||||
import json
|
||||
from xrpl.clients import JsonRpcClient
|
||||
from xrpl.wallet import Wallet
|
||||
testnet_url = "https://s.altnet.rippletest.net:51234"
|
||||
@@ -125,7 +124,7 @@ def broker_sale(seed, sell_offer_index, buy_offer_index, broker_fee):
|
||||
Get the broker wallet and establish a client connection.
|
||||
|
||||
```python
|
||||
broker_wallet=Wallet(seed, sequence=16237283)
|
||||
broker_wallet=Wallet.from_seed(seed)
|
||||
client=JsonRpcClient(testnet_url)
|
||||
```
|
||||
|
||||
@@ -140,22 +139,16 @@ Define the accept offer transaction, matching a sell offer with the selected buy
|
||||
)
|
||||
```
|
||||
|
||||
Sign and fill the transaction.
|
||||
|
||||
```python
|
||||
signed_tx=xrpl.transaction.safe_sign_and_autofill_transaction(
|
||||
accept_offer_tx, broker_wallet, client)
|
||||
```
|
||||
|
||||
Submit the transaction and report the results.
|
||||
|
||||
```python
|
||||
reply=""
|
||||
try:
|
||||
response=xrpl.transaction.send_reliable_submission(signed_tx,client)
|
||||
response=xrpl.transaction.submit_and_wait(accept_offer_tx,client,broker_wallet)
|
||||
reply=response.result
|
||||
except xrpl.transaction.XRPLReliableSubmissionException as e:
|
||||
reply=f"Submit failed: {e}"
|
||||
return reply
|
||||
```
|
||||
|
||||
## lesson5-broker-nfts.py
|
||||
@@ -882,4 +875,4 @@ btn_op_cancel_offer.grid(row=16, column=3, sticky="nsew")
|
||||
|
||||
# Start the application
|
||||
window.mainloop()
|
||||
```
|
||||
```x
|
||||
Reference in New Issue
Block a user