Transaction Finality

On Circular, transactions are final as soon as the block is minted. There is no need to wait for multiple block confirmations since Circular is designed to prevent forking, ensuring blocks are final. This approach maintains strong security while offering fast transaction finality.

async function sendAndCheckTransaction(
    ID, 
    From, 
    To, 
    Timestamp, 
    Type, 
    Payload, 
    Nonce, 
    Signature, 
    Blockchain
) {
    try {
        // Submitting transaction
        const data = await Circular.SendTransaction(
            ID, 
            From, 
            To, 
            Timestamp, 
            Type, 
            Payload, 
            Nonce, 
            Signature, 
            Blockchain
        );

        // If the transaction is correctly received
        if (data.Result === 200) {
            // Extracts the TxID
            var TxID = data.Response.TxID;

            // Waits for the transaction to be finalized
            const transaction = await Circular.GetTransactionOutcome(
                Blockchain, // Blockchain
                TxID,       // Transaction waited on
                25          // 25 seconds timeout
            );

            // If the transaction is found
            if (transaction) {
                // Extracts the transaction status
                if (transaction.Status) {
                    const Status = transaction.Status;

                    // Calculation of the total fee paid
                    var TxFee = transaction.NagFee + 
                                transaction.BroadcastFee + 
                                transaction.ProcessingFee + 
                                transaction.ProtocolFee;

                    // Extraction of the BlockID where the transaction is
                    var Block = transaction.BlockID;

                    // Posts a message with the details
                    alert(`TxID: ${TxID}\n Tx Status: ${Status}\n Fees: ${TxFee} CIRX\n BlockID: ${Block}`);
                } else {
                    console.log('Status field is missing in the transaction response.');
                }
            } else {
                console.log('Transaction not successful or Response was "Transaction Not Found".');
            }
        } else {
            alert('Transaction Rejected: ' + data.Reponse);
        }
    } catch (error) {
        console.error('Error:', error.message);
    }
}

Last updated