ExampleERC20
Inherits: ERC20, ERC20Burnable, ReentrancyGuard, [RulesEngineClientERC20](/v2(/v2/reference/client/RulesEngineClientERC20.sol/abstract.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.
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.
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](/v2(/v2/reference/example/ExampleUserContract.sol/contract.ExampleUserContract.md#transfer) function and interacts with the Rules Engine to ensure compliance with transfer policies. It includes a reentrancy guard to prevent reentrancy attacks.
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.
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. |