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

How to decode account data using Rust?

$
0
0

I'm trying to get the account data using Rust and the solana_sdk.I have the following code where account.data is a Vec.

    let pubkey = Pubkey::from_str("...").unwrap();    let account = client.get_account(&pubkey).unwrap();    println!("{:?}", account.data);    enter code here

When trying to decode the byte array:

    let data = String::from_utf8(account.data).unwrap();

I get an error:

error: Utf8Error { valid_up_to: 1, error_len: Some(1) } }

How can I decode account data using Rust?


Viewing all articles
Browse latest Browse all 8063

Latest Images

Trending Articles



Latest Images

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