Can I emit an event in case a transaction doesn't take place?

For example, I have a function checking whether the wallet is allowed to buy the token. If yes, the transaction takes place and an event gets out. But what if the function doesn't allow the transaction? I can't emit an event and access the log from my Dapp. Correct? What should I do then to inform the user? PancakeSwap just shows a random error message. That doesn't help either.

Thank you!

1 Answer 1


I'm not clear on what you're asking ... is it your contract code? You can emit from the contract but it would have to be before throwing an error/reverting.

If it's not your contact then you're stuck with whatever you're passed by the contract. Hopefully there's a meaningful message in the thrown error that you can use, or if you're lucky it emits an event.

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.