# Verifier Function
Verifier function is a function of dApp script that is responsible for verification of transactions and orders sent from dApp account. The verifier function does the same as an account script.
dApp script can have only one verifier function. The verifier function should be adorned with the @Verifier(tx)
annotation, where tx: Transaction|Order
is the transaction or the order that the function is currently checking.
Verifier function has no arguments.
Verifier function can have one of the following execution results:
true
(the transaction or the order is allowed),false
(the transaction or the order is denied),- an error (the transaction or the order is denied).
dApp that has no verifier function performs default verification, that is, checking that the first proof of the transaction/order has the correct sender's signature. The following function does the same as the default implementation:
@Verifier(tx)
func verify() = {
sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
}
If the verifier function is defined, only verification by this function is performed, proofs are not checked additionally.
⚠️ If the the complexity of the verifier function exceeds the sender complexity threshold, the minimum fee for transactions sent on behalf of the account is increased by 0.004 WAVES. (Before activation of feature #16 “Ride V5, dApp-to-dApp invocations”, the extra fee was required regardless of the presence and complexity of the verifier function.)
# Data Accessible to Verifier Function
Fields of the current verified transaction/order, including
proofs
. The built-in variabletx
contains this transaction or order. The set of fields depends on the type of transaction/order, see the Transaction Structures chapter and Order article.Blockchain data: current height, account balances, entries in account data storages, parameters of tokens, etc.
⚠️ Blockchain data is available only when checking a transaction and not available when checking an order (
case t: Order
).
# Example
dApp with the verifier function listed below only allows transfer transactions with amount of token less than 100. Orders and other transactions are denied. The match operator is used to specify verification rules depending on the type of the transaction/order.
@Verifier(tx)
func verify() = {
match tx {
case ttx:TransferTransaction => ttx.amount < 100 && sigVerify(ttx.bodyBytes, ttx.proofs[0], ttx.senderPublicKey)
case _ => false
}
}