Skip to main content

Callable

Callable

Base contract to restrict access to certain functions, allowing calls only from a list of authorized addresses (allowedCallers).

Inherit from this contract and use the mustBeAllowedCaller modifier to protect functions. The list of allowed callers is managed by the contract owner (from Ownable). If ownership is renounced, only previously added allowed callers will be able to call the functions.

allowedCallers

mapping(address => bool) allowedCallers

Mapping storing the addresses authorized to call protected functions. true if the address is allowed, false otherwise.

constructor

constructor() public

Initializes the contract, setting the deployer as the initial owner.

newAllowedCaller

function newAllowedCaller(address allowed) public

Allows the contract owner to add a new address to the list of allowed callers. If ownership is renounced, this function can no longer be performed.

Parameters

NameTypeDescription
allowedaddressThe address to add to the allowed callers list.

isAllowedCaller

function isAllowedCaller(address caller) public view returns (bool)

Checks if a given address is currently in the list of allowed callers.

Parameters

NameTypeDescription
calleraddressThe address to check.

Return Values

NameTypeDescription
[0]boolbool True if the address is an allowed caller, false otherwise.

mustBeAllowedCaller

modifier mustBeAllowedCaller()

Reverts if msg.sender is not an allowed caller.

Modifier to ensure that the function caller (msg.sender) is in the allowedCallers list.

mustBeContractCall

modifier mustBeContractCall(address addr)

Reverts if msg.sender is not addr.

Modifier to ensure that the function caller (msg.sender) is in the addr. It is used to only allow calls from a specific contract address.