mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-04 11:55:50 +00:00
Update cash_check.py
This commit is contained in:
@@ -5,34 +5,34 @@ from xrpl.transaction import (safe_sign_and_autofill_transaction,
|
||||
from xrpl.utils import str_to_hex, xrp_to_drops
|
||||
from xrpl.wallet import generate_faucet_wallet
|
||||
|
||||
# create a client
|
||||
# Connect to a network
|
||||
client = JsonRpcClient("https://s.altnet.rippletest.net:51234")
|
||||
|
||||
|
||||
# cash an xrp check
|
||||
# Cash an xrp check
|
||||
|
||||
# check id
|
||||
# Check id
|
||||
check_id = "F944CB379DEE18EFDA7A58A4F81AF1A98C46E54A8B9F2D268F1E26610BC0EB03"
|
||||
|
||||
# amount to cash
|
||||
# Amount to cash
|
||||
amount = 10.00
|
||||
|
||||
# generate wallet
|
||||
# Generate wallet
|
||||
sender_wallet = generate_faucet_wallet(client=client)
|
||||
|
||||
# build check cash transaction
|
||||
# Build check cash transaction
|
||||
check_txn = CheckCash(account=sender_wallet.classic_address, check_id=check_id, amount=xrp_to_drops(amount))
|
||||
|
||||
# sign transaction
|
||||
# Sign transaction
|
||||
stxn = safe_sign_and_autofill_transaction(check_txn, sender_wallet, client)
|
||||
|
||||
# submit transaction and wait for result
|
||||
# Submit transaction and wait for result
|
||||
stxn_response = send_reliable_submission(stxn, client)
|
||||
|
||||
# parse response for result
|
||||
# Parse response for result
|
||||
stxn_result = stxn_response.result
|
||||
|
||||
# print result and transaction hash
|
||||
# Print result and transaction hash
|
||||
print(stxn_result["meta"]["TransactionResult"])
|
||||
print(stxn_result["hash"])
|
||||
|
||||
@@ -40,35 +40,35 @@ print(stxn_result["hash"])
|
||||
|
||||
#################### cash token check #############################
|
||||
|
||||
# cash token check
|
||||
# Cash token check
|
||||
|
||||
# token name
|
||||
token = "LegitXRP"
|
||||
# Token name
|
||||
token = "USD"
|
||||
|
||||
# amount of token to deliver
|
||||
# Amount of token to deliver
|
||||
amount = 10.00
|
||||
|
||||
# token issuer address
|
||||
# Token issuer address
|
||||
issuer = generate_faucet_wallet(client=client).classic_address
|
||||
|
||||
# create sender wallet object
|
||||
# Create sender wallet object
|
||||
sender_wallet = generate_faucet_wallet(client=client)
|
||||
|
||||
# build check cash transaction
|
||||
# Build check cash transaction
|
||||
check_txn = CheckCash(account=sender_wallet.classic_address, check_id=check_id, amount=IssuedCurrencyAmount(
|
||||
currency=str_to_hex(token),
|
||||
issuer=issuer,
|
||||
value=amount))
|
||||
|
||||
# sign transaction
|
||||
# Sign transaction
|
||||
stxn = safe_sign_and_autofill_transaction(check_txn, sender_wallet, client)
|
||||
|
||||
# submit transaction and wait for result
|
||||
# Submit transaction and wait for result
|
||||
stxn_response = send_reliable_submission(stxn, client)
|
||||
|
||||
# parse response for result
|
||||
# Parse response for result
|
||||
stxn_result = stxn_response.result
|
||||
|
||||
# print result and transaction hash
|
||||
# Print result and transaction hash
|
||||
print(stxn_result["meta"]["TransactionResult"])
|
||||
print(stxn_result["hash"])
|
||||
|
||||
Reference in New Issue
Block a user