I'm trying to get Solana transaction status using Rust. You can get the transaction status using explorer.solana.com, but I want to get it via code.
There is the get_signature_status function in the Rust SDK: https://github.com/solana-labs/solana/blob/master/client/src/rpc_client.rs#L1119
The function above expect a signature object: https://docs.rs/solana-sdk/0.16.2/src/solana_sdk/signature.rs.html#25
So I tried using it:
let sig_s = String::from("...");
let sig: Signature = Signature(sig_s.as_bytes());
let stat = self.client.get_signature_status(&sig);
println!("{:?}", stat);
But I get an error of: "constructor is not visible here due to private fields"
I'm trying to understand if there is another way to create Signature object, I guess there should be a way to create Signature object and get its status.
First of all, you linked to a massively outdated version of the docs (v0.16.2, the latest is v1.9.6). See https://docs.rs/solana-sdk for the latest version.
In the latest version, Signature
implements FromStr
so you can do the following:
let sig = Signature::from_str(sig_s).unwrap();
And that'll get you a Signature
you can use.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.