Generate address from publid key with symbol sdk

What’s the right way to get the address from its public key (as published in the opt-in transaction)?
I tried

Address.createFromPublicKey(Convert.utf8ToHex("${publicKey}"), NetworkType.MAIN_NET)

but it doesn’t match. What’s the wrong in this code?

Why are you using NEM sdk? Shouldnt be it Symbol sdk since this is Symbol public key (in tx)?

Sorry, it’s a habit of typing nem sdk, I meant symbol sdk indeed, and I edited the subject. Thanks for the notice, I might have missed it and wonder why I don’t get answers :slight_smile:

I found it, I needed to use PublicAccount:

var pa = PublicAccount.createFromPublicKey("${publicKey",NetworkType.MAIN_NET)
1 Like