Modular Compliance

Description of the Modular Compliance Smart Contract

Functions

addModule

function addModule(address _module) external nonpayable

adds a module to the list of compliance modules

Parameters

NameTypeDescription
_moduleaddressaddress of the module to add there cannot be more than 25 modules bound to the modular compliance for gas cost reasons This function can be called ONLY by the owner of the compliance contract Emits a ModuleAdded event

bindToken

function bindToken(address _token) external nonpayable

binds a token to the compliance contract

Parameters

NameTypeDescription
_tokenaddressaddress of the token to bind This function can be called ONLY by the owner of the compliance contract Emits a TokenBound event

callModuleFunction

function callModuleFunction(bytes callData, address _module) external nonpayable

calls any function on bound modules can be called only on bound modules

Parameters

NameTypeDescription
callDatabytesthe bytecode for interaction with the module, abi encoded
_moduleaddressThe address of the module This function can be called only by the modular compliance owner emits a ModuleInteraction event

canTransfer

function canTransfer(address _from, address _to, uint256 _amount) external view returns (bool)

checks that the transfer is compliant. default compliance always returns true READ ONLY FUNCTION, this function cannot be used to increment counters, emit events, ...

Parameters

NameTypeDescription
_fromaddressThe address of the sender
_toaddressThe address of the receiver
_amountuint256The amount of tokens involved in the transfer This function will call moduleCheck() on every module bound to the compliance If each of the module checks return TRUE, this function will return TRUE as well returns FALSE otherwise

Returns

NameTypeDescription
_0booltrue if the transfer is compliant
false otherwise

created

function created(address _to, uint256 _amount) external nonpayable

function called whenever tokens are created on a wallet this function can update state variables in the modules bound to the compliance these state variables being used by the module checks to decide if a transfer is compliant or not depending on the values stored in these state variables and on the parameters of the modules This function can be called ONLY by the token contract bound to the compliance

Parameters

NameTypeDescription
_toaddressThe address of the receiver
_amountuint256The amount of tokens involved in the minting This function calls moduleMintAction() on each module bound to the compliance contract

destroyed

function destroyed(address _from, uint256 _amount) external nonpayable

function called whenever tokens are destroyed from a wallet this function can update state variables in the modules bound to the compliance these state variables being used by the module checks to decide if a transfer is compliant or not depending on the values stored in these state variables and on the parameters of the modules This function can be called ONLY by the token contract bound to the compliance

Parameters

NameTypeDescription
_fromaddressThe address on which tokens are burnt
_amountuint256The amount of tokens involved in the burn This function calls moduleBurnAction() on each module bound to the compliance contract

getModules

function getModules() external view returns (address[])

getter for the modules bound to the compliance contract returns address array of module contracts bound to the compliance

Returns

NameTypeDescription
_0address[]the addresses of all bound modules

getTokenBound

function getTokenBound() external view returns (address)

getter for the address of the token bound returns the address of the token

Returns

NameTypeDescription
_0addressthe address of bound token

isModuleBound

function isModuleBound(address _module) external view returns (bool)

checks if a module is bound to the compliance contract returns true if module is bound, false otherwise

Parameters

NameTypeDescription
_moduleaddressaddress of the module to check

Returns

NameTypeDescription
_0booltrue if module is bound
false if module not bound

removeModule

function removeModule(address _module) external nonpayable

removes a module from the list of compliance modules

Parameters

NameTypeDescription
_moduleaddressaddress of the module to remove This function can be called ONLY by the owner of the compliance contract Emits a ModuleRemoved event

transferred

function transferred(address _from, address _to, uint256 _amount) external nonpayable

function called whenever tokens are transferred from one wallet to another this function can update state variables in the modules bound to the compliance these state variables being used by the module checks to decide if a transfer is compliant or not depending on the values stored in these state variables and on the parameters of the modules This function can be called ONLY by the token contract bound to the compliance

Parameters

NameTypeDescription
_fromaddressThe address of the sender
_toaddressThe address of the receiver
_amountuint256The amount of tokens involved in the transfer This function calls moduleTransferAction() on each module bound to the compliance contract

unbindToken

function unbindToken(address _token) external nonpayable

unbinds a token from the compliance contract

Parameters

NameTypeDescription
_tokenaddressaddress of the token to unbind This function can be called ONLY by the owner of the compliance contract Emits a TokenUnbound event

Events

ModuleAdded

event ModuleAdded(address indexed _module)

this event is emitted when a module has been added to the list of modules bound to the compliance contract the event is emitted by the addModule function _module is the address of the compliance module

Parameters

NameTypeDescription
_module indexedaddressaddress of the compliance module

ModuleInteraction

event ModuleInteraction(address indexed target, bytes4 selector)

Event emitted for each executed interaction with a module contract. For gas efficiency, only the interaction calldata selector (first 4 bytes) is included in the event. For interactions without calldata or whose calldata is shorter than 4 bytes, the selector will be 0.

Parameters

NameTypeDescription
target indexedaddressaddress of the compliance module
selectorbytes4selector of the function

ModuleRemoved

event ModuleRemoved(address indexed _module)

this event is emitted when a module has been removed from the list of modules bound to the compliance contract the event is emitted by the removeModule function _module is the address of the compliance module

Parameters

NameTypeDescription
_module indexedaddressaddress of the compliance module

TokenBound

event TokenBound(address _token)

this event is emitted when a token has been bound to the compliance contract the event is emitted by the bindToken function _token is the address of the token to bind

Parameters

NameTypeDescription
_tokenaddressaddress of the bound token

TokenUnbound

event TokenUnbound(address _token)

this event is emitted when a token has been unbound from the compliance contract the event is emitted by the unbindToken function _token is the address of the token to unbind

Parameters

NameTypeDescription
_tokenaddressaddress of the token unbound