I am attempting to write a simple function to check if an address is an account (e.g tz1, tz2 etc) or contract address (KT).
I want to write something like this:
function isAddressContract(ad: address) : bool {
const adString = address_to_string(ad);
const firstTwo = slice(adString, 0, 2);
return (firstTwo = "KT" ? true : false)
}
But of course address_to_string
is not a real archetype builtin.
I attempted to leverage address_to_contract
but I do not really understand what this is for and I wasn't able to get the syntax right anyway and received a parsing error. My attempt:
function isAddressContract(ad: address) : bool {
return ((address_to_contract(ad) <> unit) ? true : false)
}
How can I convert an address to a string or otherwise solve this simple problem?
Thankyou in advance for any assistance!