Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

234
Views
Converting string to Public Key

I am trying to convert a public key saved as a string to an anchor_lang PubKey object in rust. What is the procedure to convert a string to a PubKey object?

about 4 years ago · Santiago Gelvez
3 answers
Answer question

0

If your public key can be static

pub const YOUR_PUBKEY: Pubkey = solana_program::pubkey!("base58_pubkey")

Otherwise

let your_pubkey = Pubkey::from_str("base58_pubkey").unwrap();
about 4 years ago · Santiago Gelvez Report

0

Here is an exact example (the string will vary with what you have) that converts a base58 string to Solana Pubkey:

let pk_key = Pubkey::from_str("SDMHqNqN82QSjEaEuqybmpXsjtX98YuTsX6YCdT99to").unwrap();
about 4 years ago · Santiago Gelvez Report

0

I've never used solana before, so I am not sure exactly how one would do this. Looking through their docs, it looks like PubKey implements the FromStr trait. This has a from_str function that takes a &str and parses it into a PubKey.

about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!