Module functions
Modules
Functions
- Private and public functions can require an authorization check to be performed before execution. This is typically the case when the function allows performing an action on behalf of someone who is not the caller. This macro injects the necessary code to perform the check via the authwit mechanism and additionally emit the authorization request as an offchain effect, so a user/wallet can verify what are they being asked to sign. This check also emits a nullifier with the provided nonce argument, so authorizations are valid once and only once, preventing replay attacks.
- Same as in Solidity external functions are functions that our callable from outside the contract.
- An initializer function is similar to a constructor:
- it can only be called once
- if there are multiple initializer functions, only one of them can be called
- no non-initializer functions can be called until an initializer has ben called (except
noinitcheckfunctions)
- Same as in Solidity internal functions are functions that are callable from inside the contract. Unlike #only_self functions, internal functions are inlined (e.g. akin to EVM's JUMP and not EVM's CALL).
- Functions with noinitcheck can be called before contract initialization.
- Functions marked with #nophasecheck will handle phase changes internally
- Functions marked with #only_self attribute can only be called by the contract itself.
- View functions can only be called in a static execution context.