When writing a Clarity Smart contract, how can you validate the principal that is calling into a public function.
I don't know where to find the answer to this question.
When writing a Clarity Smart contract, how can you validate the principal that is calling into a public function.
I don't know where to find the answer to this question.
tx-sender
contains the principal that sent the transaction. It can be used to validate the principal that is calling into a public function.You can also use
contract-caller
which works a bit differently. If this is the first contract called by the transaction signer, it will be the same astx-sender
. Ifcontract-call?
was used to call into another contract, it will return the calling contract.https://docs.stacks.co/docs/clarity/language-keywords#contract-caller