Bot Protection
Background
The Bot Protection contract was created for dApps looking to protect their contracts from being botted.
Vital for applications on zero-gas fee or low-gas fee chains, Bot Protection is built on-top of OpenZeppelin and Authority.
The contract brings with it a simple, yet flexible set of limits and optional blacklisting capabilities that enables a smart contract to protect itself from being “botted”.
”Botted” - the act of a bots being used to simulate user action.
Installation
Using Bot Protection
API
Solidity API
BotProtection
Contract for rate limiting functionality based on function calls.
ProtectionLevel
Limit
cooldown
level
strikes
useBlacklist
limits
checkForBot
Modifier to check for bot activity and apply rate limiting.
Parameters
Name | Type | Description |
---|---|---|
addr | address | The address to check for bot activity. |
RemoveFromBlacklist
SetProtectionLevel
ToggleBlacklist
constructor
Constructor to initialize the contract with protection level and blacklist usage.
Parameters
Name | Type | Description |
---|---|---|
_level | enum BotProtection.ProtectionLevel | The initial protection level. |
_useBlacklist | bool | Flag indicating whether to use blacklist. |
_setProtectionLevel
Internal function to set protection level parameters.
Parameters
Name | Type | Description |
---|---|---|
protectionLevel | enum BotProtection.ProtectionLevel | The protection level to set. |
removeFromBlacklist
Function to remove addresses from blacklist.
Parameters
Name | Type | Description |
---|---|---|
addresses | address[] | The addresses to remove from blacklist. |
setProtectionLevel
Function to set the protection level.
Parameters
Name | Type | Description |
---|---|---|
protectionLevel | enum BotProtection.ProtectionLevel | The protection level to set. |
toggleBlacklist
Function to toggle the blacklist on/off.
Default Levels
These levels can be overwritten by overriding the the _setProtectionLevel function.
Level | Cooldown | Strikes |
---|---|---|
OFF | 0 | 0 |
LOW | 60 seconds | 5 |
MEDIUM | 5 minutes | 5 |
HIGH | 60 minutes | 5 |
EXTREME | 24 hours | 3 |