ITurtleShellFirewall
ITurtleShellFirewall Interface
The ITurtleShellFirewall
is an interface for a firewall contract that can be used to protect individual accounts on the Ethereum network. This document describes the methods provided by the interface and provides examples of how to integrate these into your contracts.
This interface was written in Solidity, a statically-typed programming language used for Ethereum smart contracts.
Contract Methods
setParameter(uint256 newParameter)
setParameter(uint256 newParameter)
This function allows a user to update their security parameter.
If the new parameter exceeds the preset threshold, the firewall will be activated automatically. However, if the firewall is already active, the parameter will be updated regardless.
On successful execution, it emits a ParameterChanged
event and a FirewallStatusUpdate
event. The function returns true
if the firewall was activated, or had already been active.
contract MyContract {
ITurtleShellFirewall firewall;
function updateParameter(uint256 newParam) public {
bool status = firewall.setParameter(newParam);
}
}
setUserConfig(uint8 thresholdPercentage, uint256 blockInterval, uint256 startParameter, uint256 cooldownPeriod)
setUserConfig(uint8 thresholdPercentage, uint256 blockInterval, uint256 startParameter, uint256 cooldownPeriod)
This function is for setting the configuration values for a firewall user. These values are:
thresholdPercentage
: The threshold percentage to set for the firewallblockInterval
: The block interval to set for the firewallstartParameter
: The start parameter for the firewallcooldownPeriod
: The cooldown period for the firewall
This function also emits a ParameterChanged
event.
contract MyContract {
ITurtleShellFirewall firewall;
function setConfig(uint8 percent, uint256 interval, uint256 startParam, uint256 cooldown) public {
firewall.setUserConfig(percent, interval, startParam, cooldown);
}
}
setFirewallStatus(bool newStatus)
setFirewallStatus(bool newStatus)
This function can be used to manually change the firewall status for a user. It can be used to manually activate or deactivate the firewall for a user, and it should particularly be used to deactivate the firewall if it has been triggered.
On successful execution, it emits a FirewallStatusUpdate
event.
contract MyContract {
ITurtleShellFirewall firewall;
function setStatus(bool status) public {
firewall.setFirewallStatus(status);
}
}
getFirewallStatusOf(address user)
getFirewallStatusOf(address user)
This function can be used to retrieve the firewall status for a user.
It returns a boolean value indicating whether the firewall is active for the given user.
contract MyContract {
ITurtleShellFirewall firewall;
function getStatusOf(address user) public view returns (bool) {
return firewall.getFirewallStatusOf(user);
}
}
getParameterOf(address user)
getParameterOf(address user)
This function can be used to retrieve the security parameter for a firewall user.
It returns the security parameter as a uint256 value.
contract MyContract {
ITurtleShellFirewall firewall;
function getParameterOf(address user) public view returns (uint256) {
return firewall.getParameterOf(user);
}
}
getSecurityParameterConfigOf(address user)
getSecurityParameterConfigOf(address user)
This function can be used to retrieve the security parameters for a given address.
It returns the threshold and block interval set as security parameters for the address.
contract MyContract {
ITurtleShellFirewall firewall;
function getConfigOf(address user) public view returns (uint8, uint256) {
return firewall.getSecurityParameterConfigOf(user);
}
}
Remember, to use this interface you should have the contract address of the deployed ITurtleShellFirewall implementation. You should instantiate the ITurtleShellFirewall with this address:
ITurtleShellFirewall firewall = ITurtleShellFirewall(deployed_firewall_address_here);
Last updated
Was this helpful?