0

I have a requirement, there are two contracts Contract A and Contract B.

Contract A calls Contract B , if some error occurs in contract B while calling. Instead of failing of transaction, Contract B should sends some message to Contract A and then Contract A will receive that message and then emits a event saying the contract B gets failed.

I know try catch is not possible on tezos, but is there any way I can handle this scenario?

2 Answers 2

0

I would use an option as a returned value from Contract B:

if something is wrong, Contract B returns None to Contract A
if everything is fine, Contract B returns Some value to Contract A

You can then use pattern matching in Contract A to adapt the behaviour of the contract to the value returned by Contract B.

Answer from Claude Barde in Slack.

0

Unexpected errors might "never" occur because before trying to send your transaction your wallet will tell you that it will fail

It means :

  • you can segregated a bad use case with if..else and tell something back to contract A
  • you are unlucky because an event happened in paralell that changed initial conditions, example "gas_exhausted", so it will not pass but you cannot manage this in another way

Answer from Benjamin Fuentes from Slack.

Your Answer

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