Documentation Index
Fetch the complete documentation index at: https://thrackle.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Git Source
Inherits:
ERC20, ERC20Burnable, ReentrancyGuard, RulesEngineClientERC20
Author:
@mpetersoCode55, @ShaneDuncan602, @TJ-Everett, @VoR0220
This contract demonstrates how to integrate the Rules Engine with an ERC20 token for policy enforcement.
This contract is an example implementation of an ERC20 token integrated with the Rules Engine. It extends the
OpenZeppelin ERC20 and ERC20Burnable contracts and includes additional functionality for interacting with the
Rules Engine. The contract ensures compliance with policies defined in the Rules Engine for minting, transferring,
and transferring tokens on behalf of others.
Functions
constructor
Constructor for the Example ERC20 token.
Initializes the token with a name and symbol.
constructor(string memory _name, string memory _symbol) ERC20(_name, _symbol);
Parameters
| Name | Type | Description |
|---|
_name | string | The name of the token. |
_symbol | string | The symbol of the token. |
mint
Mints new tokens to a specified address.
This function interacts with the Rules Engine to ensure compliance with minting policies.
function mint(address to, uint256 amount)
public
virtual
checksPoliciesERC20MintBefore(to, amount, balanceOf(msg.sender), balanceOf(to), block.timestamp);
Parameters
| Name | Type | Description |
|---|
to | address | The recipient address. |
amount | uint256 | The number of tokens to mint. |
transfer
Transfers tokens to a specified address.
This function overrides the IERC20-transfer function and interacts with the Rules Engine to ensure compliance
with transfer policies. It includes a reentrancy guard to prevent reentrancy attacks.
function transfer(address to, uint256 amount)
public
virtual
override
nonReentrant
checksPoliciesERC20TransferBefore(to, amount, balanceOf(msg.sender), balanceOf(to), block.timestamp)
returns (bool);
Parameters
| Name | Type | Description |
|---|
to | address | The recipient address. |
amount | uint256 | The number of tokens to transfer. |
Returns
| Name | Type | Description |
|---|
<none> | bool | bool True if the transfer is successful, false otherwise. |
transferFrom
Transfers tokens on behalf of another address.
This function overrides the IERC20-transferFrom function and interacts with the Rules Engine to ensure compliance
with transfer policies. It includes a reentrancy guard to prevent reentrancy attacks.
function transferFrom(address from, address to, uint256 amount)
public
virtual
override
nonReentrant
checksPoliciesERC20TransferFromBefore(from, to, amount, balanceOf(msg.sender), balanceOf(to), block.timestamp)
returns (bool);
Parameters
| Name | Type | Description |
|---|
from | address | The address to transfer tokens from. |
to | address | The recipient address. |
amount | uint256 | The number of tokens to transfer. |
Returns
| Name | Type | Description |
|---|
<none> | bool | bool True if the transfer is successful, false otherwise. |