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:
ERC1155, ReentrancyGuard, ERC1155Burnable, RulesEngineClientERC1155
Author:
@mpetersoCode55, @ShaneDuncan602, @TJ-Everett, @VoR0220
This contract demonstrates how to integrate the Rules Engine with an ERC1155 token for policy enforcement.
This contract is an example implementation of an ERC1155 token integrated with the Rules Engine. It extends the
OpenZeppelin ERC1155 and ERC1155Burnable 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. It also includes a withdrawal function for Ether stored in the contract.
Functions
constructor
Constructor for the Example ERC1155 token.
Initializes the token with a base uri.
constructor(string memory _uri) ERC1155(_uri);
Parameters
| Name | Type | Description |
|---|
_uri | string | The base uri of the token. |
mint
Mints new tokens to the specified address.
function mint(address to, uint256 tokenId, uint256 value, bytes memory data)
public
payable
virtual
checksPoliciesERC1155MintAfter(to, tokenId, value, data);
Parameters
| Name | Type | Description |
|---|
to | address | The address of the recipient. |
tokenId | uint256 | The ID of the token to transfer. |
value | uint256 | The value of tokenId being transfered. |
data | bytes | Additional data to pass to the recipient contract. |
mintBatch
Mints new tokens to the specified address.
function mintBatch(address to, uint256[] memory tokenIds, uint256[] memory values, bytes memory data)
public
payable
virtual
checksPoliciesERC1155BatchMintAfter(to, tokenIds, values, data);
Parameters
| Name | Type | Description |
|---|
to | address | The address of the recipient. |
tokenIds | uint256[] | The IDs of the tokens to transfer. |
values | uint256[] | The values of tokenIds being transfered. |
data | bytes | Additional data to pass to the recipient contract. |
safeTransferFrom
Safely transfers a token from one address to another.
This function overrides the ERC1155-safeTransferFrom function and interacts with the Rules Engine to ensure
compliance with transfer policies. It includes additional checks for policy compliance.
function safeTransferFrom(address from, address to, uint256 tokenId, uint256 value, bytes memory data)
public
override
checksPoliciesERC1155SafeTransferFromBefore(from, to, tokenId, value, data);
Parameters
| Name | Type | Description |
|---|
from | address | The address of the current token owner. |
to | address | The address of the recipient. |
tokenId | uint256 | The ID of the token to transfer. |
value | uint256 | The value of tokenId being transfered. |
data | bytes | Additional data to pass to the recipient contract. |
safeBatchTransferFrom
Safely transfers a token from one address to another.
This function overrides the ERC1155-safeTransferFrom function and interacts with the Rules Engine to ensure
compliance with transfer policies. It includes additional checks for policy compliance.
function safeBatchTransferFrom(
address from,
address to,
uint256[] memory tokenIds,
uint256[] memory values,
bytes memory data
) public override checksPoliciesERC1155SafeBatchTransferFromBefore(from, to, tokenIds, values, data);
Parameters
| Name | Type | Description |
|---|
from | address | The address of the current token owner. |
to | address | The address of the recipient. |
tokenIds | uint256[] | The IDs of the tokens to transfer. |
values | uint256[] | The values of tokenIds being transfered. |
data | bytes | Additional data to pass to the recipient contract. |
supportsInterface
Returns true if this contract implements the interface defined by
interfaceId. See the corresponding
https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
to learn more about how these ids are created.
This function call must use less than 30 000 gas.
function supportsInterface(bytes4 interfaceId) public view override(ERC1155) returns (bool);
withdraw
Withdraws Ether stored in the contract.
This function allows only App Administrators to withdraw Ether. It uses the appManagerAddress to enforce
access control. The function is payable to allow flexibility in child contracts.
function withdraw() public payable virtual;