Skip to content

Conversation

@cctdaniel
Copy link
Contributor

No description provided.

@vercel
Copy link

vercel bot commented Oct 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
api-reference ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 28, 2024 5:26am
proposals ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 28, 2024 5:26am
staking ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 28, 2024 5:26am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
component-library ⬜️ Ignored (Inspect) Oct 28, 2024 5:26am

Comment on lines +279 to +312
let recent_blockhash = rpc_client.get_latest_blockhash()?;
transaction.sign(signers, recent_blockhash);

// Simulate the transaction
let simulation_result = rpc_client.simulate_transaction(&transaction)?;

// Check if simulation was successful
if let Some(err) = simulation_result.value.err {
println!("Transaction simulation failed: {:?}", err);
if let Some(logs) = simulation_result.value.logs {
println!("Simulation logs:");
for (i, log) in logs.iter().enumerate() {
println!(" {}: {}", i, log);
}
}
return Err(anyhow::anyhow!("Transaction simulation failed"));
}

// If simulation was successful, send the actual transaction
let config = RpcSendTransactionConfig {
skip_preflight: true,
..RpcSendTransactionConfig::default()
};
let transaction_signature = rpc_client.send_transaction_with_config(&transaction, config)?;
println!("Transaction sent: {transaction_signature:?}");

// Wait for confirmation
rpc_client.confirm_transaction_with_spinner(
&transaction_signature,
&recent_blockhash,
rpc_client.commitment(),
)?;

println!("Transaction confirmed: {transaction_signature:?}");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add more logs to troubleshoot when tx fails

@cctdaniel cctdaniel merged commit 6999fb9 into main Oct 28, 2024
7 checks passed
@cctdaniel cctdaniel deleted the atlas-testnet branch October 28, 2024 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants