This commit is contained in:
Wo Jake
2022-09-05 11:20:06 +00:00
committed by GitHub
parent 0fc587e777
commit 828f7e282f

View File

@@ -1,16 +1,13 @@
from xrpl.clients import JsonRpcClient
from xrpl.models.transactions import TicketCreate, AccountSet
from xrpl.account import get_next_valid_seq_number
from xrpl.transaction import safe_sign_and_submit_transaction
from xrpl.core import keypairs
from xrpl.wallet import Wallet
from xrpl.models.requests.account_info import AccountInfo
from xrpl.models.requests.account_objects import AccountObjects, AccountObjectType
myAddr = "rfaNymVS1fEREj4FpNroXVEcVVMph6k2Mt"
mySeed = "ss3GZzmyEBxvwB3LUvsqfa-------"
myAddr = "rLugkhsRxNHroDVJ29anq9UoTcNQdDjXCR"
mySeed = "sARIIQ06xLZulXC1MBeE---------"
# Derive and initialize wallet
public, private = keypairs.derive_keypair(mySeed)
wallet_from_seed = Wallet(mySeed, 0)
# Connect to a testnet node
@@ -20,23 +17,20 @@ client = JsonRpcClient(JSON_RPC_URL)
# Construct a TicketCreate transaction, 1 ticket created for future use
tx = TicketCreate(
account=myAddr,
fee="10",
ticket_count=1,
sequence=get_next_valid_seq_number(address=myAddr, client=client)
ticket_count=1
)
# Sign transaction locally and submit
my_tx_payment_signed = safe_sign_and_submit_transaction(transaction=tx, wallet=wallet_from_seed, client=client)
# Get ticket Sequence
get_ticket = AccountInfo(
# Get a Ticket Sequence
get_ticket_sequence = AccountObjects(
account=myAddr,
ledger_index="current",
strict=True
type=AccountObjectType.TICKET
)
response = client.request(get_ticket)
ticket_sequence = response.result["account_data"]["Sequence"]-1
response = client.request(get_ticket_sequence)
ticket_sequence = response.result["account_objects"][0]["TicketSequence"]
# Construct Transaction using a Ticket
tx_1 = AccountSet(
@@ -48,8 +42,8 @@ tx_1 = AccountSet(
)
# Send transaction (w/ Ticket)
result = safe_sign_and_submit_transaction(transaction=tx_1, client=client, wallet=wallet_from_seed)
result = result.result["engine_result"]
tx_result = safe_sign_and_submit_transaction(transaction=tx_1, client=client, wallet=wallet_from_seed)
result = tx_result.result["engine_result"]
if result == "tesSUCCESS":
print("Transaction successful!")