ORC20 Index: The Inside Theory
The core of the ORC20 Index is a UTXO Engine, which verifies the legitimacy of transactions by tracking the inputs and outputs of each expenditure. Therefore, it is necessary to review what the UTXO model is.
- In the UTXO model, an account balance is composed of a series of unspent transaction outputs (UTXOs).
- The core of the UTXO model is to maintain the UTXO set and record and verify the owners and ownership transfer process of the UTXOs.
- When verifying the ownership transfer of UTXOs, the input of a transaction must be the UTXO of the previous transaction. At the same time, each UTXO belongs to a unique account address. Therefore, only the owner of the UTXO can use it for transactions.
- When verification is successful, all UTXOs of the inputs of the current transaction will be spent, and therefore removed from the UTXO set.
The UTXO model can be easily implemented using Ordinal Inscription because each Ordinal Inscription is uniquely linked to an account address. To verify a transaction, it is only necessary to confirm that the initiating account address holds the Ordinal Inscriptions that record the UTXOs.
Once the initiating account's authority is established, the validity of the UTXOs of the current transaction input can be further verified to securely validate the transaction.
Since Ordinal Inscription data is stored in the BTC network, any verification node can demonstrate the validity of the transaction process in a reliable way by tracing the UTXOs recorded in the Ordinal Inscription on the chain.
About UTXO Engine
Once the above description is understood, implementing the UTXO Engine based on Ordinal Inscription is a straightforward process.
- The UTXO Engine first constructs the initial UTXO set based on the "inscribe mint" inscription.
- When an account inscribes an inscription (either "inscribe send" or "inscribe send remaining balance"), the UTXO Engine creates a transaction with the inputs being the UTXO inscription held by the account and validates the UTXO's legitimacy.
- If the verification is successful, the UTXO inscription used as input is removed from the account's UTXO set, and new UTXO inscriptions are created as outputs, signifying the completion of a valid transaction.
- When new inscriptions are received, steps 2 and 3 are recursively applied.
Verification nodes can easily verify the UTXO Engine's execution results. They can accomplish this by maintaining a valid UTXO set and verifying each inscription recording action on the chain. If the verification is successful, the valid UTXO set is updated, but if it fails, an arbitration instruction is issued.
Reuse of UTXOs
While the UTXO model in the BTC network prohibits UTXO reuse, implementing the UTXO model using Ordinal Inscription enables UTXO reuse since each UTXO is associated with an inscription. Transaction verification only requires proving the validity of the inscription transfer process.
When implementing a UTXO model based on Ordinal Inscription, the validation of nodes can snapshot the valid UTXO inscriptions of all accounts at a given moment and use it as a basis for verifying subsequent transactions.
As the ORC20 protocol is still very early and evolving, this is the recommended approach, which greatly simplifies the implementation logic of the validation node.
UTXO Input At present, it is not possible to select specific UTXOs as inputs when inscribing an inscription, which differs from the BTC network.
During the early testing phase, the UTXO engine only used the UTXO of the "inscribe remaining balance" inscription as the default input. However, this method had a significant flaw in that newly inscribed inscriptions could not be split or combined, particularly after supporting UTXO reuse. Even with off-chain virtual account maintenance, reuse inscriptions would be unable to be split or merged.
To prioritize the security of P2P transactions, we opted to use all of the user's UTXO inscriptions (including "inscribe send", "inscribe remaining balance" etc). as the default input. Additionally, to improve the optimization potential of using all UTXO inscriptions as inputs, we proposed solutions through OIP-12 and OIP-13:
- OIP-12: Prevents double-spending attacks in PSBT transactions by using a multi-account model.
- OIP-13: Optimizes the efficiency of inscription usage.
OIP-11 prohibits the transfer of UTXOs by transferring the "inscribe remaining balance" inscription. As per this rule, if an account transfers the "inscribe remaining balance" inscription, the balance on that inscription must still belong to that account.
Since the account no longer holds the "inscribe remaining balance" inscription on the chain, its balance cannot be discovered through on-chain data. To ensure that the complete transaction of UTXOs can still be traced, the UTXO engine will off-chain record a virtual inscription for the account.
This would significantly affect the effectiveness of the verification process. Although the UTXOs of inscriptions on the chain are trustworthy, they are not complete. Verification nodes need to request balances that are not recorded on the chain from off-chain indexing services. This violates the principle of minimal trust. However, once OIP-11 is formally adopted, this risk can be fixed.
- Unspent transaction output. https://en.wikipedia.org/wiki/Unspent_transaction_output
- BRC20. https://domo-2.gitbook.io/brc-20-experiment/
- ORC-20. https://docs.orc20.org/