FIrst commit
This commit is contained in:
commit
3318602fd2
5292
Cargo.lock
generated
Normal file
5292
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
12
Cargo.toml
Normal file
12
Cargo.toml
Normal file
@ -0,0 +1,12 @@
|
||||
[package]
|
||||
name = "solana_scanner"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
solana-client = "1.17"
|
||||
solana-sdk = "1.17"
|
||||
bs58 = "0.5.0"
|
||||
|
||||
[target.'cfg(target_os = "linux")'.dependencies]
|
||||
libc = "0.2"
|
||||
91
src/main.rs
Normal file
91
src/main.rs
Normal file
@ -0,0 +1,91 @@
|
||||
use solana_client::rpc_client::RpcClient;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use bs58;
|
||||
use solana_sdk::instruction::Instruction;
|
||||
use solana_sdk::message::Message;
|
||||
use solana_client::rpc_response::RpcConfirmedTransactionStatusWithSignature;
|
||||
use solana_client::rpc_response::EncodedConfirmedTransactionWithStatusMeta;
|
||||
use solana_sdk::transaction::Transaction;
|
||||
|
||||
fn base58_to_pubkey(address: &str) -> Result<Pubkey, Box<dyn std::error::Error>> {
|
||||
let decoded = bs58::decode(address).into_vec()?;
|
||||
if decoded.len() != 32 {
|
||||
return Err("Address must be 32 bytes long".into());
|
||||
}
|
||||
let mut bytes = [0u8; 32];
|
||||
bytes.copy_from_slice(&decoded);
|
||||
Ok(Pubkey::new_from_array(bytes))
|
||||
}
|
||||
|
||||
fn is_token_creation(instruction: &Instruction) -> bool {
|
||||
// L'instruction de création de token a un discriminant de 0
|
||||
if instruction.data.len() < 1 {
|
||||
return false;
|
||||
}
|
||||
instruction.data[0] == 0
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let rpc_url = "https://api.mainnet-beta.solana.com";
|
||||
let client = RpcClient::new(rpc_url.to_string());
|
||||
|
||||
// Adresse du programme Token (SPL Token Program)
|
||||
let token_program_address = "pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA";
|
||||
|
||||
match base58_to_pubkey(token_program_address) {
|
||||
Ok(token_program) => {
|
||||
println!("Récupération des transactions pour le programme Token...");
|
||||
|
||||
// Récupérer les transactions associées au programme Token
|
||||
let transactions = client.get_signatures_for_address(&token_program);
|
||||
|
||||
match transactions {
|
||||
Ok(sigs) => {
|
||||
println!("Nombre total de transactions trouvées : {}", sigs.len());
|
||||
for sig in sigs.iter().take(10) { // Limiter à 10 transactions pour commencer
|
||||
// Récupérer les détails de la transaction
|
||||
match client.get_transaction(&sig.signature, solana_client::rpc_config::RpcTransactionConfig {
|
||||
encoding: Some(solana_client::rpc_config::RpcTransactionEncoding::Base64),
|
||||
commitment: Some(solana_client::rpc_config::RpcTransactionLogsConfig {
|
||||
commitment: Some(solana_client::rpc_config::CommitmentConfig::confirmed()),
|
||||
max_supported_transaction_version: Some(0),
|
||||
}),
|
||||
max_supported_transaction_version: Some(0),
|
||||
}) {
|
||||
Ok(tx) => {
|
||||
println!(tx.transaction.meta);
|
||||
|
||||
//if let Some(meta) = tx.transaction.meta {
|
||||
//println!(meta);
|
||||
// Vérifier si c'est une création de token
|
||||
//let is_token_creation = meta.inner_instructions.iter().any(|inner| {
|
||||
// inner.instructions.iter().any(|ix| {
|
||||
//if let Ok(instruction) = ix.try_into() {
|
||||
//is_token_creation(&instruction)
|
||||
//} else {
|
||||
// false
|
||||
//}
|
||||
// })
|
||||
//});
|
||||
|
||||
//if is_token_creation {
|
||||
//println!("Création de token trouvée :");
|
||||
//println!(" Signature: {}", sig.signature);
|
||||
//println!(" Slot: {}", sig.slot);
|
||||
//println!(" Block time: {:?}", sig.block_time);
|
||||
//println!(" Status: {:?}", meta.err);
|
||||
//println!("---");
|
||||
//}
|
||||
// }
|
||||
}
|
||||
Err(err) => eprintln!("Erreur lors de la récupération de la transaction : {:?}", err),
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(err) => eprintln!("Erreur lors de la récupération des transactions : {:?}", err),
|
||||
}
|
||||
}
|
||||
Err(err) => eprintln!("Erreur lors de la conversion de l'adresse : {:?}", err),
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user