Git Source

Inherits: [RulesEngineClient](/v2(/v2/reference/client/RulesEngineClient.sol/abstract.RulesEngineClient)

Author: @mpetersoCode55, @ShaneDuncan602, @TJ-Everett, @VoR0220

This contract is intended to be inherited and implemented by ERC20 token contracts requiring Rules Engine integration.

Abstract contract containing modifiers and functions for integrating ERC20 token operations with the Rules Engine. This contract provides policy checks for mint, transfer, and transferFrom operations, both before and after execution.

Functions

checksPoliciesERC20TransferBefore

Modifier for checking policies before executing the transfer function.

Calls the _checksPoliciesERC20Transfer function to evaluate policies.

modifier checksPoliciesERC20TransferBefore(
    address to,
    uint256 value,
    uint256 balanceFrom,
    uint256 balanceTo,
    uint256 blockTime
);

Parameters

NameTypeDescription
toaddressThe receiving address.
valueuint256The amount to transfer.
balanceFromuint256The sender’s balance before the transfer.
balanceTouint256The receiver’s balance before the transfer.
blockTimeuint256The current block timestamp.

checksPoliciesERC20TransferAfter

Modifier for checking policies after executing the transfer function.

Calls the _checksPoliciesERC20Transfer function to evaluate policies.

modifier checksPoliciesERC20TransferAfter(
    address to,
    uint256 value,
    uint256 balanceFrom,
    uint256 balanceTo,
    uint256 blockTime
);

Parameters

NameTypeDescription
toaddressThe receiving address.
valueuint256The amount to transfer.
balanceFromuint256The sender’s balance after the transfer.
balanceTouint256The receiver’s balance after the transfer.
blockTimeuint256The current block timestamp.

checksPoliciesERC20TransferFromBefore

Modifier for checking policies before executing the transferFrom function.

Calls the _checksPoliciesERC20TransferFrom function to evaluate policies.

modifier checksPoliciesERC20TransferFromBefore(
    address from,
    address to,
    uint256 value,
    uint256 balanceFrom,
    uint256 balanceTo,
    uint256 blockTime
);

Parameters

NameTypeDescription
fromaddressThe sending address.
toaddressThe receiving address.
valueuint256The amount to transfer.
balanceFromuint256The sender’s balance before the transfer.
balanceTouint256The receiver’s balance before the transfer.
blockTimeuint256The current block timestamp.

checksPoliciesERC20TransferFromAfter

Modifier for checking policies after executing the transferFrom function.

Calls the _checksPoliciesERC20TransferFrom function to evaluate policies.

modifier checksPoliciesERC20TransferFromAfter(
    address from,
    address to,
    uint256 value,
    uint256 balanceFrom,
    uint256 balanceTo,
    uint256 blockTime
);

Parameters

NameTypeDescription
fromaddressThe sending address.
toaddressThe receiving address.
valueuint256The amount to transfer.
balanceFromuint256The sender’s balance after the transfer.
balanceTouint256The receiver’s balance after the transfer.
blockTimeuint256The current block timestamp.

checksPoliciesERC20MintBefore

Modifier for checking policies before executing the mint function.

Calls the _checksPoliciesERC20Mint function to evaluate policies.

modifier checksPoliciesERC20MintBefore(
    address to,
    uint256 amount,
    uint256 balanceFrom,
    uint256 balanceTo,
    uint256 blockTime
);

Parameters

NameTypeDescription
toaddressThe receiving address.
amountuint256The amount to mint.
balanceFromuint256The sender’s balance before the mint.
balanceTouint256The receiver’s balance before the mint.
blockTimeuint256The current block timestamp.

checksPoliciesERC20MintAfter

Modifier for checking policies after executing the mint function.

Calls the _checksPoliciesERC20Mint function to evaluate policies.

modifier checksPoliciesERC20MintAfter(
    address to,
    uint256 amount,
    uint256 balanceFrom,
    uint256 balanceTo,
    uint256 blockTime
);

Parameters

NameTypeDescription
toaddressThe receiving address.
amountuint256The amount to mint.
balanceFromuint256The sender’s balance after the mint.
balanceTouint256The receiver’s balance after the mint.
blockTimeuint256The current block timestamp.

_checksPoliciesERC20Transfer

Calls the Rules Engine to evaluate policies for an ERC20 transfer operation.

Encodes the parameters and invokes the _invokeRulesEngine function.

function _checksPoliciesERC20Transfer(
    address to,
    uint256 value,
    uint256 balanceFrom,
    uint256 balanceTo,
    uint256 blockTime
) internal;

Parameters

NameTypeDescription
toaddressThe receiving address.
valueuint256The amount to transfer.
balanceFromuint256The sender’s balance.
balanceTouint256The receiver’s balance.
blockTimeuint256The current block timestamp.

_checksPoliciesERC20TransferFrom

Calls the Rules Engine to evaluate policies for an ERC20 transferFrom operation.

Encodes the parameters and invokes the _invokeRulesEngine function.

function _checksPoliciesERC20TransferFrom(
    address from,
    address to,
    uint256 value,
    uint256 balanceFrom,
    uint256 balanceTo,
    uint256 blockTime
) internal;

Parameters

NameTypeDescription
fromaddressThe sending address.
toaddressThe receiving address.
valueuint256The amount to transfer.
balanceFromuint256The sender’s balance.
balanceTouint256The receiver’s balance.
blockTimeuint256The current block timestamp.

_checksPoliciesERC20Mint

Calls the Rules Engine to evaluate policies for an ERC20 mint operation.

Encodes the parameters and invokes the _invokeRulesEngine function.

function _checksPoliciesERC20Mint(address to, uint256 amount, uint256 balanceFrom, uint256 balanceTo, uint256 blockTime)
    internal;

Parameters

NameTypeDescription
toaddressThe receiving address.
amountuint256The amount to mint.
balanceFromuint256The sender’s balance.
balanceTouint256The receiver’s balance.
blockTimeuint256The current block timestamp.