hyperledger / solang

Solidity Compiler for Solana and Polkadot
https://solang.readthedocs.io/
Apache License 2.0
1.22k stars 207 forks source link

PDA calculation and verification #1606

Closed kupermind closed 7 months ago

kupermind commented 7 months ago

Hi guys,

This is NOT a bug, but just a question, as we could not find where we could post it. Is there a way to check if the account is a PDA one? If not, is it possible to calculate the PDA based on a programId and seeds in the solidity code itself, similar to how it could be done via the findProgramAddress() method in TS?

Thank you for your reply!

LucasSte commented 7 months ago

This is NOT a bug, but just a question, as we could not find where we could post it.

There is a stack overflow for Solang: https://solana.stackexchange.com/questions/tagged/solang

Is it possible to calculate the PDA based on a programId and seeds in the solidity code itself.

Yes, it is. You can create or find a PDA in Solidity.

kupermind commented 7 months ago

Thank you so much for such a swift and very spot on reply! Indeed, now I remember seeing the try_find_program_address function.

Also, thank you for the stack overflow link.