Clarity Smart contract validate principal calling public function

35 views Asked by At

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.

1

There are 1 answers

0
Kenny On

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 as tx-sender. If contract-call? was used to call into another contract, it will return the calling contract.

https://docs.stacks.co/docs/clarity/language-keywords#contract-caller