I am new to smart contract development so any help or guidance is appreciated.

I am thinking of creating a contract that checks if a certain transaction has already been done for validation. Is that possible? If possible, any example code or resource to one would be really helpful.

For instance, Bob transferred Alice 1 ETH. The transaction is written and spits out a transaction id. Bob then input the transaction id to my contract, my contract then checks if Bob did transferred Alice 1 ETH. If true, then my contract sends something to Bob's wallet. If false, then nothing happens.

The reason why my contract has to check the transaction is because the action that I am using for validation (in this case, transferring of ETH) is done from another contract that I have no control over. It is someone else's contract.

Or is there another approach to this?

1 Answer 1


Logs are the intended solution: the EVM cannot access transactions. The other contract should be emitting event (logs) that your contract can then verify: see Proving the Existence of Logs to the Blockchain

If the other contract is not using or missing logs, you might be out of luck and rewrite that other contract. That is a reason why well-written contracts emit events, such as a token contract emitting a Transfer event. (If you rewrite the other contract and get users for it, then you can integrate more easily too; it's still good to emit events so that others can use your contract more easily.)

  • I see. Thank you for the insights! That might be a problem as I would be working with multiple contract that I have no control over. Some might have logs and some might not. Would it be possible if my smart contract use etherscan to verify the transaction id? I heard about chainlink and how it enables smart contract to connect to off chain data. What do you think of this approach? Commented Jan 27, 2022 at 16:19
  • You can use an oracle but they are not as secure or reliable: they can get hacked or go offline. It depends how trustless and secure you want to be, and how much implementation you want to do. It's probably better to monitor the chain yourself (be your own oracle) than assume etherscan is always running and correct, but the tradeoff is you have to implement more.
    – eth
    Commented Jan 30, 2022 at 4:54

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.