Quantcast
Channel: Recent Questions - Solana Stack Exchange
Viewing all articles
Browse latest Browse all 7881

How can I get the program_id from the last transaction response Solana Blockchain Rust

$
0
0

I have a code

fn main() {let rpc_url = String::from("https://api.mainnet-beta.solana.com/");let client = RpcClient::new(rpc_url);

let pk = Pubkey::from_str("adresshere").unwrap();let signatures = client.get_signatures_for_address(&pk).unwrap();if let Some(last_signature) = signatures.first() {    let signature = Signature::from_str(&last_signature.signature).unwrap();    let trx = client.get_transaction(&signature,        UiTransactionEncoding::JsonParsed    ).unwrap();    match trx.transaction.transaction {        EncodedTransaction::Json(json) => {            match json.message {                UiMessage::Parsed(message) => {                    //println!("{:?}", &message.instructions[0]);                    match &message.instructions[0] {                        UiInstruction::Parsed(inst) => {                            match inst {                                UiParsedInstruction::Parsed(d) => {                                    println!("{:?}", d);                                }                                _ => panic!()                            }                        }                        _ => panic!()                    }                }                _ => panic!()            }        }        _ => panic!()    }} else {    println!("Not found");}

}

But I'm having trouble getting the program_id. I walk JSON response and using struct and enum-methods from solana_transaction_status I get the answersPlease help


Viewing all articles
Browse latest Browse all 7881

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>