I am reviewing play to earn contracts and I have come across a contract with this implementation
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
abstract contract BPContract {
function protect(
address sender,
address receiver,
uint256 amount
) external virtual;
}
It seems to be looking for bot detection. But does it really work?
Looking at the functions I get the impression that it is the opposite. That is, to use them within the contract.
I am right?
function setBpAddress(address _bp) external onlyOwner {
require(address(BP) == address(0), "Can only be initialized once");
BP = BPContract(_bp);
emit BPAdded(_bp);
}
function setBpEnabled(bool _enabled) external onlyOwner {
require(address(BP) != address(0), "You have to set BP address first");
bpEnabled = _enabled;
emit BPEnabled(_enabled);
}
/**
* @dev Add the BP handler to prevents the bots.
*
**/
function _transfer(
address sender,
address recipient,
uint256 amount
) internal virtual override {
if (bpEnabled) {
BP.protect(sender, recipient, amount);
emit BPTransfer(sender, recipient, amount);
}
super._transfer(sender, recipient, amount);
}
This is the contract: