mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-05 04:15:50 +00:00
Use generate_faucet_wallet
This commit is contained in:
@@ -1,29 +1,28 @@
|
||||
from xrpl.clients import JsonRpcClient
|
||||
from xrpl.models.transactions import AccountSet
|
||||
from xrpl.transaction import safe_sign_and_autofill_transaction, send_reliable_submission
|
||||
from xrpl.wallet import Wallet
|
||||
|
||||
myAddr = "rM4vA4uRpc2MtCoc4vdhhTwWqsWcncwaLL"
|
||||
mySeed = "ssJ4QYQLXomJLSKBT----------"
|
||||
|
||||
# Derive and initialize wallet
|
||||
wallet_from_seed = Wallet(mySeed, 0)
|
||||
from xrpl.wallet import Wallet, generate_faucet_wallet
|
||||
|
||||
# Connect to a testnet node
|
||||
JSON_RPC_URL = "https://s.altnet.rippletest.net:51234/"
|
||||
client = JsonRpcClient(JSON_RPC_URL)
|
||||
|
||||
# Generate a wallet and request faucet
|
||||
test_wallet = generate_faucet_wallet(client=client)
|
||||
myAddr = test_wallet.classic_address
|
||||
|
||||
# Construct AccountSet transaction
|
||||
tx = AccountSet(
|
||||
account=myAddr
|
||||
)
|
||||
|
||||
# Sign the transaction locally
|
||||
my_tx_payment_signed = safe_sign_and_autofill_transaction(transaction=tx, wallet=wallet_from_seed, client=client)
|
||||
my_tx_payment_signed = safe_sign_and_autofill_transaction(transaction=tx, wallet=test_wallet, client=client)
|
||||
# Submit transaction and verify its validity on the ledger
|
||||
response = send_reliable_submission(transaction=my_tx_payment_signed, client=client)
|
||||
result = response.result["meta"]["TransactionResult"]
|
||||
|
||||
print(f"Account: {myAddr}")
|
||||
if result == "tesSUCCESS":
|
||||
print("Transaction successful!")
|
||||
elif result == "tefMAX_LEDGER":
|
||||
|
||||
Reference in New Issue
Block a user