0

Given that we have a Blockchain with smart contracts. We have end users operating the platform for some time. Now one user wants to verify the claim of a transaction.

Example, I have to prove that last month I have transferred some amount from my account to another user account.

I know that the blocks are mined and synced with all nodes in the blockchain. In order for me to prove the above transaction, hope do I prove.

Should I write a separate smart contract to validate our how can we get this proved. I have searched the internet and found ways of generating the blocks, but not on validation.

1 Answer 1

0

Given that we have a Blockchain with smart contracts. We have end users operating the platform for some time. Now one user wants to verify the claim of a transaction. Example, I have to prove that last month I have transferred some amount from my account to another user account.

This is a little unclear because you say with smart contracts and then claim of a transaction which sounds like any transaction - not necessarily to your contract.

To contract

A contract state will update when the transaction is observed. For example, from Alice to Bob, transfer X tokens in an ERC20 contract. The fact of this transaction is implied in the balances of both users, in the contract. There is nothing further to prove. So click your heels together. You're already home.

There are some smart contract design nuances that may or may not exist. Suffice it to say that whatever is important for the use-case ought to be conveniently provable. That wouldn't include going out of one's way to check arbitrary transactions because other patterns already exist:

  • Event emitters should fire for every on-chain state change, so users can subscribe to those. Didn't hear about it? It didn't happen.
  • There is a protocol-level facility to check the status of a specific transaction.

Any transaction

Common cases exist where one wants to confirm the existence of a specific transaction. For example, you bought my boat and before you sail away I want to be sure you haven't tricked me. In those cases, the transaction hash is the unique identifier for the transaction in question. You would give me the transaction hash, off-chain, so I can verify it myself. We just have to get the receipt and confirm it is mined in a block some time ago and the transaction was successful (e.g. it wasn't rejected for some reason).

A block explorer can help check specific transactions with no code or command line. It depends, of course, on trusting the source.

https://etherscan.io/

If one wants to personally verify or programmatically check then the CLI or a script can use a Web3.js method:

https://web3js.readthedocs.io/en/v1.2.11/web3-eth.html#gettransactionreceipt

Deep down, these libraries (there are several in various languages) interact with the JSON-RPC interface of the Ethereum node which one can talk to directly.

Hope it helps.

2
  • 1
    Thanks a lot Rob, I had the question because we are always mining the blocks based on the accepted transactions. However, I was curios if we might require a case where we need to go through the history (looping through the blocks) and wanting to verify if the transaction has occurred for sure. As you pointed out I can use the transaction id in a off-chain and do a lookup in case of any verification required.
    – Saravanan
    Commented Mar 1, 2021 at 4:42
  • There certainly is a case, because we hear about new blocks at the head of the chain but there can be competing heads. If one wants to wait for, say ... 6 confirmations, then just wait for newer blocks to arrive and then circle back to confirm the transaction still exists. Also check the block because it might have moved, so you want to make sure it didn't get picked up in a later block if you are strict about the number of confirmations. Commented Mar 1, 2021 at 9:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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