How do we implement following solidity code in smartPy.

try this.checkAddress(to) {
catch Error(string memory _err) {
                    errMsg = _err;

1 Answer 1


There is no way to catch exceptions on Tezos.

SmartPy (and Michelson, the language into which it is compiled) is using Some/None system, also known as option.

The sp.contract(<type>, <address>, <entrypoint>) instruction returns an option of a contract.

It returns None if no contract with this entrypoint exists and Some(contract) if the contract exists.

See https://smartpy.io/docs/types/options/ for more info about options.

In general, options can be used everywhere something is supposed to return a value. None can be returned instead of an exception. Some can also return a variant with an error and a variant with the valid value if they want to return an error value.

  • Can you share any work around solutions on this.
    – theBatMan
    Commented Mar 10, 2023 at 5:06
  • I edited my answer.
    – Jordan_tez
    Commented Mar 10, 2023 at 9:22

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.