Transaction Operations

Make a payment and get the results

use onemoney_protocol::PaymentPayload;

// Send a payment
let payment = PaymentPayload {
    recent_epoch: state.epoch,
    recent_checkpoint: state.checkpoint,
    chain_id: 1212101,
    nonce: 2,
    recipient: recipient_address,
    value: TokenAmount::from(500000000000000000u64), // 0.5 tokens
    token: token_address,
};

let result = client.send_payment(payment, private_key).await?;
println!("Payment sent: {}", result.hash);

Get the transaction details

// Get transaction details
let tx = client.get_transaction_by_hash(&result.hash).await?;
println!("Transaction status: {:?}", tx.status);

Poll for Confirmation

// Wait for confirmation
let confirmed_tx = client.wait_for_transaction(
    &result.transaction_hash,
    30, // max attempts
    Duration::from_secs(2) // polling interval
).await?;

Last updated