0

I am trying to integrate security.txt https://github.com/neodyme-labs/solana-security-txt into a project, and while from the repo it is clear how to access it from rust, I am at a loss as to how to do this in either python or javascript.

I can see the solana python library includes the parsing functionality for this, but I have no idea how to get to the program data from within python.

In rust you have to jump through a few hoops:

let program_account = client.get_account(&pubkey)


let program: UpgradeableLoaderState = bincode::deserialize_from(&program_account.data[..])?;

let program_data_address = if let UpgradeableLoaderState::Program {
programdata_address,
} = program
{
programdata_address
} else {
return Ok(());
};

let program_data_account = client.get_account(&program_data_address);


let offset = UpgradeableLoaderState::programdata_data_offset()?;
let program_data = &program_data_account.data[offset..];

let security_txt = solana_security_txt::find_and_parse(program_data)?;
println!("{}", security_txt);

but in python I really have no idea how to do all this stuff.. has anyone been able to do this?

Thanks

2 Answers 2

-1

Here's Solana labs official TS way: https://github.com/solana-labs/explorer/blob/master/src/utils/security-txt.ts

Unsure about Python.

-1

I would consider using the Solana.py as Python API library: https://michaelhly.github.io/solana-py/

The particular security.txt processing is here (while I haven't tried): https://github.com/michaelhly/solana-py/blob/v0.29.0/src/solana/utils/security_txt.py

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.