2

This question has hanging over my head for long time.

How to tell a crate provided by solana org or third party can be imported and use from on-chain code? Is there any flag in cargo.toml file to tell from?

For example, I once try to use the hash function from anchor-syn crate, but it failed to compile. (See this post) So I draw a conclusion that anchor-syn crate is not compile for sbf-solana-solana target. But it is just my own guest, and unable to justify this.

Another related question, how to set target_os for IDE to high-light the solana code correctly. For example, the vscode in my side obvious not high light the solana code:

enter image description here

1 Answer 1

0

There's no way to easily tell if a crate is usable on-chain unfortunately. You can look through the crate's code and dependencies for things that aren't possible, like rand or net, but past that, it isn't easy.

To be honest, your best bet is to import it, try to use it, and see if the compiler reports an error.

As for your VSCode issue, that might belong in a separate question :-)

1
  • Thanks. It sound reasonable as crate used on-chain. As to VSCode, I will do more search myself. Commented Apr 1 at 5:52

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.