mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-21 04:05:49 +00:00
Update create_check.py
This commit is contained in:
@@ -7,31 +7,25 @@ from xrpl.transaction import (safe_sign_and_autofill_transaction,
|
|||||||
from xrpl.utils import datetime_to_ripple_time, str_to_hex, xrp_to_drops
|
from xrpl.utils import datetime_to_ripple_time, str_to_hex, xrp_to_drops
|
||||||
from xrpl.wallet import generate_faucet_wallet
|
from xrpl.wallet import generate_faucet_wallet
|
||||||
|
|
||||||
client = JsonRpcClient("https://s.altnet.rippletest.net:51234") # connect to the testnetwork
|
client = JsonRpcClient("https://s.altnet.rippletest.net:51234") # Connect to the testnetwork
|
||||||
|
|
||||||
"""Create a token check"""
|
"""Create a token check"""
|
||||||
|
|
||||||
# check receiver address
|
check_receiver_addr = "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe" # Example: send back to Testnet Faucet
|
||||||
receiver_addr = "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe" # Example: send back to Testnet Faucet
|
|
||||||
|
|
||||||
# token name
|
token_name = "USD"
|
||||||
token = "LegitXRP"
|
|
||||||
|
|
||||||
# amount of token to deliver
|
amount_to_deliver = 10.00
|
||||||
amount = 10.00
|
|
||||||
|
|
||||||
# token issuer address
|
token_issuer = "r9CEVt4Cmcjt68ME6GKyhf2DyEGo2rG8AW"
|
||||||
issuer = "r9CEVt4Cmcjt68ME6GKyhf2DyEGo2rG8AW"
|
|
||||||
|
|
||||||
# check expiry date
|
# Set check to expire after 5 days
|
||||||
# check will expire after 5 days
|
|
||||||
expiry_date = datetime_to_ripple_time(datetime.now() + timedelta(days=5))
|
expiry_date = datetime_to_ripple_time(datetime.now() + timedelta(days=5))
|
||||||
|
|
||||||
|
# Generate wallet
|
||||||
# generate wallet from seed
|
|
||||||
sender_wallet = generate_faucet_wallet(client=client)
|
sender_wallet = generate_faucet_wallet(client=client)
|
||||||
|
|
||||||
# build check create transaction
|
# Build check create transaction
|
||||||
check_txn = CheckCreate(account=sender_wallet.classic_address, destination=receiver_addr,
|
check_txn = CheckCreate(account=sender_wallet.classic_address, destination=receiver_addr,
|
||||||
send_max=IssuedCurrencyAmount(
|
send_max=IssuedCurrencyAmount(
|
||||||
currency=str_to_hex(token),
|
currency=str_to_hex(token),
|
||||||
@@ -39,54 +33,46 @@ send_max=IssuedCurrencyAmount(
|
|||||||
value=amount),
|
value=amount),
|
||||||
expiration=expiry_date)
|
expiration=expiry_date)
|
||||||
|
|
||||||
# sign transaction
|
# Sign, submit transaction and wait for result
|
||||||
stxn = safe_sign_and_autofill_transaction(check_txn, sender_wallet, client)
|
stxn = safe_sign_and_autofill_transaction(check_txn, sender_wallet, client)
|
||||||
|
|
||||||
# submit transaction and wait for result
|
|
||||||
stxn_response = send_reliable_submission(stxn, client)
|
stxn_response = send_reliable_submission(stxn, client)
|
||||||
|
|
||||||
# parse response for result
|
# Parse response for result
|
||||||
stxn_result = stxn_response.result
|
stxn_result = stxn_response.result
|
||||||
|
|
||||||
# print result and transaction hash
|
# Print result and transaction hash
|
||||||
print(stxn_result["meta"]["TransactionResult"])
|
print(stxn_result["meta"]["TransactionResult"])
|
||||||
print(stxn_result["hash"])
|
print(stxn_result["hash"])
|
||||||
|
|
||||||
|
|
||||||
|
############### CREATE XRP CHECK ################################
|
||||||
############# CREATE XRP CHECK ################################
|
|
||||||
"""Create xrp check"""
|
"""Create xrp check"""
|
||||||
|
|
||||||
|
|
||||||
# check receiver address
|
check_receiver_addr = "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe" # Example: send back to Testnet Faucet
|
||||||
receiver_addr = generate_faucet_wallet(client=client).classic_address
|
|
||||||
|
|
||||||
# amount of xrp to deliver
|
amount_to_deliver = 10.00
|
||||||
amount = 10.00
|
|
||||||
|
|
||||||
# check expiry date
|
# Set check to expire after 5 days
|
||||||
# check will expire after 5 days
|
|
||||||
expiry_date = datetime_to_ripple_time(datetime.now() + timedelta(days=5))
|
expiry_date = datetime_to_ripple_time(datetime.now() + timedelta(days=5))
|
||||||
|
|
||||||
|
|
||||||
# generate wallet from seed
|
# Generate wallet
|
||||||
sender_wallet = generate_faucet_wallet(client=client)
|
sender_wallet = generate_faucet_wallet(client=client)
|
||||||
|
|
||||||
# build check create transaction
|
# Build check create transaction
|
||||||
check_txn = CheckCreate(account=sender_wallet.classic_address,
|
check_txn = CheckCreate(account=sender_wallet.classic_address,
|
||||||
destination=receiver_addr,
|
destination=receiver_addr,
|
||||||
send_max=xrp_to_drops(amount),
|
send_max=xrp_to_drops(amount),
|
||||||
expiration=expiry_date)
|
expiration=expiry_date)
|
||||||
|
|
||||||
# sign transaction
|
# Sign, submit transaction and wait for result
|
||||||
stxn = safe_sign_and_autofill_transaction(check_txn, sender_wallet, client)
|
stxn = safe_sign_and_autofill_transaction(check_txn, sender_wallet, client)
|
||||||
|
|
||||||
# submit transaction and wait for result
|
|
||||||
stxn_response = send_reliable_submission(stxn, client)
|
stxn_response = send_reliable_submission(stxn, client)
|
||||||
|
|
||||||
# parse response for result
|
# Parse response for result
|
||||||
stxn_result = stxn_response.result
|
stxn_result = stxn_response.result
|
||||||
|
|
||||||
# print result and transaction hash
|
# Print result and transaction hash
|
||||||
print(stxn_result["meta"]["TransactionResult"])
|
print(stxn_result["meta"]["TransactionResult"])
|
||||||
print(stxn_result["hash"])
|
print(stxn_result["hash"])
|
||||||
|
|||||||
Reference in New Issue
Block a user