Package Sequencing and Submission on DogeCoin
Each Package Submitted on Dogecoin is a formatted JSON which allows the package to be readable and be verified by anyone, this package is inscribed onto Dogecoin blockchain just like Doginals, thus keeping the data permanently stored on the blockchain.
Package Format
{
"blockHash": "0x...", // Hash of the L2 block containing the batched transactions
"transactions": [
{
"id": "0x...", // Unique identifier for the L2 transaction
"data": "..." // Encoded L2 transaction data
},
// ... more transactions within the batch
],
"proof": "0x..." // Proof representing the entire transaction batch
}
Package Submission
For each package submission the UTXO chain is progressed further
Current UTXO Retrieval: The code retrieves the most recent UTXO for the sequencer address, ensuring the UTXO chain is maintained.
Balance Validation: It checks if the current UTXO has sufficient balance to cover transaction costs before proceeding.
UTXO Selection: The
selectUTXOsForBatch
function is responsible for selecting UTXOs for the batch, considering factors like efficiency and fee optimization.New Transaction Construction: The code constructs a new transaction spending the current UTXO as input.
UTXO Chain Update: The
deriveUTXOFromTransaction
function extracts the output of the new transaction, effectively creating the next UTXO in the chain.L2 Data Inclusion: The L2 transaction data is encoded and included within the new transaction.
Batch Creation: Finally, a batch containing the newly constructed transaction is created.
// Function to retrieve the current UTXO for the sequencer (implementation detail)
function getCurrentUTXO(address sequencerAddress) -> UTXO {
// This function should interacts with a Dogecoin node or service
// to retrieve the most recent UTXO associated with the sequencer address.
}
// Function to build a transaction batch
function buildTransactionBatch(transactions) {
currentUTXO <- getCurrentUTXO(sequencerAddress);
// Validate if currentUTXO has sufficient balance for transactions and fees
if (currentUTXO.value < calculateTotalBatchCost(transactions)) {
// Handle insufficient balance scenario
return;
}
// Select UTXOs for the batch (consider efficiency and fee optimization)
selectedUTXOs <- selectUTXOsForBatch(currentUTXO, transactions);
// Construct new transaction spending the current UTXO
newTransaction <- createTransaction(currentUTXO, transactions, selectedUTXOs);
// Update the UTXO chain by deriving the new UTXO from the transaction output
newUTXO <- deriveUTXOFromTransaction(newTransaction);
// Include L2 transaction data within the new transaction
newTransaction.data <- encodeL2TransactionData(transactions);
// Create a batch containing the newly constructed transaction
batch <- [newTransaction];
return batch;
}
Last updated