I would like to know if the entrypoint of my smart contract is called from an implicit(tz1) or an originated address(KT1). How can i do the check in smartpy?

Looking at the Smartpy documentation, it's said that the address type sp.TAddress is "An address of a contract or implicit account". Further you can't convert the address to string because Michelson doesn't allow type casting.

Am i missing something? How can i differentiate between the address types?

2 Answers 2


If you are specifically interested in the address of your caller there a simpler solution than the one proposed by @rodrigo-quelhas: sp.sender is an implicit account if and only if it is exactly sp.source.


You can use: https://github.com/RomarQ/tezos-sc-utils


Utils = sp.io.import_script_from_url("https://raw.githubusercontent.com/RomarQ/tezos-sc-utils/main/smartpy/utils.py");

# And then inside the entrypoint

Utils.Address.is_kt1(sp.address("tz28QJHLyqvaY2rXAoFZTbxrXeD88NA8wscC")) # False
Utils.Address.is_kt1(sp.address("KT18hYjnko76SBVv6TaCT4kU6B32mJk6JWLZ")) # True

You can check the code here: https://github.com/RomarQ/tezos-sc-utils/blob/main/smartpy/utils.py#L301

Documented here: https://github.com/RomarQ/tezos-sc-utils/blob/main/smartpy/README.md#documentation


  • Addresses of implicit accounts are strictly less than addresses of originated accounts;
  • Addresses of the same type are compared lexicographically;
  • KT1XvNYseNDJJ6Kw27qhSEDF8ys8JhDopzfG is the highest KT1 address;
  • KT18amZmM5W7qDWVt2pH6uj7sCEd3kbzLrHT is the lowest KT1 address;
  • Any address in between (including) those two addresses is an originated account;
  • how and why are those the highest and lowest KT1 addresses?
    – 0x10
    Commented Apr 26, 2022 at 10:08
  • 1
    The addresses that you see are a slice of bytes encoded to base58check. The lowest is [2, 90, 121, 0, 0, 0, ....] and the highest is [2, 90, 121, 255, 255, 255, ....], where the first 3 bytes represent the prefix (KT1). Commented Apr 26, 2022 at 17:12
  • what would the tz version of this look like (in terms of the first n bytes)?
    – 0x10
    Commented Apr 30, 2022 at 6:25

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.