ERC-8047 Forensic Tracing Token (Forest) (Forensic Token (Forest))
Draft · Tokens · created 2025-10-15
An ERC-1155 based token standard that records fund movements as a DAG (directed acyclic graph), allowing exactly the tokens linked to a suspicious transaction to be frozen and traced without locking up an entire wallet.
Why it is needed
CBDCs and private digital currencies tout blockchain transparency, but response to actual financial crime is still slow. When a suspicious money-laundering transaction is found, an entire account or wallet must be frozen, which also locks up legitimate funds mingled with the illicit ones. Additionally, tracing which path a given token took requires a separate off-chain investigation, which takes time. Approaches like ERC-20 or ERC-3643, which manage balances as a single pooled figure, blur the flow of individual funds, making it difficult to trace or freeze any specific portion of funds.
What to implement
function latestDAGDepthOf(uint256 id) external view returns (uint256);: Queries the greatest depth reached so far within the DAG the token belongs to.function depthOf(uint256 id) external view returns (uint256);: Queries the depth of the token itself within its DAG.function ownerOf(uint256 id) external view returns (address);: Queries the current owner address of the token.function parentOf(uint256 id) external view returns (uint256);: Queries the parent token ID of the token; returns 0 if it is a root token.function rootOf(uint256 id) external view returns (uint256);: Queries the root token ID of the DAG the token belongs to.function token(uint256 id) external view returns (Token memory);: Queries the full Token struct, containing root, parent, value, depth, and owner.function totalSupply() external view returns (uint256);: Queries the total supply by summing the value of all tokens currently in circulation (an overload of the ERC-5615 totalSupply).event TokenMerged(uint256[] ids, uint256 indexed id, address indexed from, uint8 mergeType);: Emitted when multiple tokens are merged into one new token; mergeType distinguishes same-DAG merges (0) from custom merges.
In depth
Minting
The interface has no dedicated mint function; any action that increases circulating supply is treated as minting. value cannot be 0, and must revert if it is. The caller cannot specify id; it must always be generated internally by the contract. When minting a new token, root is set to the token's own id and parent is set to 0, marking it as the root of a new DAG. In this case, the TokenCreated event must record root as 0, which lets off-chain indexers find the starting point of every DAG by filtering on root=0.
Burning (soft delete)
burn also has no dedicated function and is identified by intent, referring to an action that reduces value from circulating supply. Burning is a soft delete rather than a full deletion: the token id is not removed from the DAG, only its value is reduced by the amount burned (for example, fully burning a value of 1000 leaves the id intact with value reduced to 0). A burned token's ownership must not transfer to the zero address, nor should a new token be created at the zero address. A successful burn must emit a TokenSpent event.
Existence check
For compatibility with ERC-5615, the exists function must return true for any id that has ever been created, even if its value is 0. Existence must always be determined by whether that id's root is nonzero, not by its value. This is because a burned token still retains its id and lineage, with only its value reduced to 0.
Spending and parent-child creation
safeTransferFrom must satisfy all of: the id exists, it reverts if from and to are identical, from is the owner or an approved operator, and it reverts if value is 0 or exceeds the token's value. Spending always mints a new id as a child of the id being consumed; the new token's parent is the spent id, and its depth is one greater than the parent's. If value is less than the token's current value, it is a partial spend (the parent token remains with reduced value); if it equals the current value, it is a full spend (the parent token's value becomes 0). In both cases, two TransferSingle events (one for the parent's deduction/burn, one for the child's minting) along with TokenSpent and TokenCreated events must be emitted, and safeBatchTransferFrom must emit two TransferBatch events following the same ordering rule.
Merging
When multiple tokens are merged into a single new id, the standard TransferBatch (consumed ids to the zero address) and TransferSingle/TokenCreated (for the new merged token) must be emitted. A basic merge requires all input tokens to share the same root; the token with the greatest depth is chosen as the new parent (ties go to whichever token appears first in the input array), and the new token's depth is that parent's depth + 1. A TokenMerged event must be emitted together with all the ids used in the merge. Implementations that allow merges across different roots (cross-DAG merges) must clearly define the root-determination rule and must set mergeType greater than 0 (0 is reserved for same-DAG default merges), and should account for the fact that this merges distinct asset lineages together, complicating forensic tracing.
Metadata URI and JSON schema
All token ids representing the same asset must reference the same metadata URI even if the ids differ (similar to how a serial number differs but the underlying asset is one). Implementations are recommended to follow a JSON schema that includes name, symbol, decimals, description, image, and properties.compliance fields (such as issuer, jurisdiction, policies, and enforcement_authority information about the issuer, jurisdiction, policy, and enforcing authority).
Contract-side ID generation and depth storage optimization
The token id is never specified by the caller and must always be generated directly by the contract. In a UTXO-like structure, allowing the caller to specify the id would open attacks such as id collisions, forged lineage records, and root impersonation. Additionally, the depth field in the Token struct uses the uint96 type, which fits together with the owner address (160 bits) into a single 256-bit storage slot with no waste. Even assuming depth increases by 1 every block at a 250ms block time, the uint96 limit would take about 6.2x10^20 years to overflow, making it a non-issue in practice.
Soft delete and policy enforcement (TPEn) reference implementation
Burned tokens are not fully removed from the DAG because doing so would break the forensic parent-child link. The reference implementation, AbstractTokenPolicyEnforcement (TPEn), groups depths into 256-unit buckets (uint256 bitmasks) and handles freezing/unfreezing of specific depths via bitwise operations (OR/AND NOT), supporting both contiguous-range freezes (beforeDepth, afterDepth) and discrete per-token freezes. This keeps freeze enforcement cost constant (O(1)) regardless of DAG size. This proposal is currently in Draft status and has not been finalized; its details may still change or the proposal may stall.
Things to watch out for
- Denial of service (DoS) from unbounded loops: In operations that iterate over an id array, such as safeBatchTransferFrom or merging multiple tokens, an excessively large array can exceed the block gas limit, causing the transaction to revert and potentially leaving assets temporarily locked up. Implementations and integrating dApps must strictly enforce array length limits, such as a maximum batch length.
- Increased storage and dust accumulation: Because assets are represented as individual token structs rather than aggregated account balances, state storage consumption is higher than with ordinary fungible tokens. If an attacker repeatedly spams transactions in extremely small units, the DAG can balloon in size, making subsequent batch-spend costs disproportionately expensive for the victim, so a minimum transfer limit (dust limit) and similar measures should be considered.
- Lineage contamination on merging: If a custom implementation allows merging tokens with different roots, the merged token ends up carrying the entangled history of both inputs. If wallets or routers merge tokens indiscriminately to save on gas, as in legacy UTXO wallets, clean assets can become mixed with the risk profile of tainted assets, so clients should manage unused tokens separately by root.
- Exposure from graph disclosure: Parent-child links remain in plaintext on the public ledger, making fund flows transparently traceable; in exchange, even though addresses are pseudonymous, a third party can readily trace the path an asset has taken. If transaction confidentiality is required, it must be handled at the application layer or through a separate privacy protocol.