Nerif Docs
Search
K

Security checks

In order to ensure that transactions from trusted senders, including the gateway contract, are accepted, certain logic needs to be incorporated into the smart contract code. This involves checking whether the sender of a given transaction is the gateway contract. One approach to implementing this logic is through the use of modifiers:
// _gatewayAddress is my Nerif Network Gateway contract address
address internal _gatewayAddress;
// onlyNerifGateway permits transactions coming from Nerif Network Gateway contract
modifier onlyNerifGateway() {
require(msg.sender == _gatewayAddress, "Operation is not permitted");
_;
}
This is just one way to implement the desired functionality, and the choice of implementation ultimately rests with the smart contract developer.