0

I am developing an eCommerce application that has on-chain and off-chain components. The off-chain components focus on the compute and storage intensive operation while on-chain smartcontract ensure true decentralized ownership of assets through immutable ledger records.

My usual use-case will involve a browser frontend and offchain component interacting with users. Once the workflow comes to the appropriate juncture, I will call smartcontract function for updates or transfer.

I need to track the submitted transactions and match it against my offchain DB records. I understand submitted transactions may not get executed immediately because miner may not prioritise my transaction. While my offchain system is waiting for the smartcontract function to be executed and transaction to be confirmed, what if my system is shutdown. How do I find the transactions that I sent which may or may not be confirmed when my system is back online? I hope I don't need to scan all transactions for all new blocks.

Extending on this question, in the traditional enterprise system - there is always 2 phase-commit that ensure transaction integrity across multiple components. What is the best practice and design pattern if I want to implement something similar? I understand there is no way to rollback transaction in blockchain so we can forget about the rollback part in the 2 phase-commit, I just need to deal with out-of-sync system states and recover from it.

0

How do I find the transactions that I sent which may or may not be confirmed when my system is back online? I hope I don't need to scan all transactions for all new blocks.

When you create transaction you will have transaction hash where Ethereum clients designed to answer transaction hash queries really really fast. So no; you dont need to scan unless you are designing your own Ethereum client (Geth/Parity). They do it for you. If you are running your application with full node mode of Ethereum client then you need to wait your Ethereum client to synch for the new blocks that have been mined since your client shutdown.

You can also use your Ethereum client in light mode where you can use other full nodes in P2P network. In that case you dont even need to wait for synching. But it is not guaranteed that you can find server nodes for your light one. Another option can be using services like Infura.io, where you can connect Ethereum client remotely with given API keys for free. Lastly you can use blockchain explorer sites like etherscan.io and query your transaction with APIs. They show if you transaction reached them, pending, or whatever.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.