Data Object
The IDataObject
interface defines methods for managing data in Data Objects linked to Data Points. It provides functionality for managing fungible fraction data objects, such as ERC20Fractions and ERC1155WithERC20Fractions Data Managers.
Core functions include balanceOf()
, totalSupply()
, exists()
, transferFrom()
, mint()
, burn()
, and their batch variants. Designed for integration with a DataManager contract, it may also offer features like approvals, access control, and metadata management, often aligning with ERC1155 token standards.
Fungible Fractions DO
Contract Explanation
Let’s begin with how this Data Object manages fungible token information. The following code shows the DataPoint storage structure, which saves the reference to its DataIndex, content, and additional user-specific data:
The diidData
variable stores user-specific data, with the user ID retrievable via the _diid()
method from the Data Index implementation.
Here, DpData
contains token-specific information, while DiidData
handles user balances.
Let’s look at how the Data Object, specifically the minimalistic fungible implementation, handles a user request that passes through the Data Index.
The Data Index contract is the first to act, forwarding the write()
operation from the Data Manager (e.g., ERC20FractionsDataManager).
After passing through the modifier, the internal method _dispatchWrite()
decodes the operation using the standard fungible operations interface.
Next, the storage modification step occurs. Using methods like _diid()
and _diidData()
, we retrieve specific user information for the request, such as the balance of the ERC1155 token ID.
Finally, _decreaseBalance()
and _increaseBalance()
update the balances for the transfer's origin and destination. Other Data Managers (ERC20, ERC1155, etc.) will access the updated user information on the next read()
operation.