1

How can we encode the accountID '5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y' to Hex string using golang for posting in RPC.

3
  • There you go: 0x90b5ab205c6974c9ea841be688864633dc9ca8a357843eeacf2314649965fe22 :) Commented Dec 21, 2022 at 10:25
  • @AdamWierzbicki, I need sample code in golang to do this. I can convert this using online tool.
    – Kumar
    Commented Dec 22, 2022 at 5:53
  • Alright, got you. Please check out the answer below. Commented Dec 22, 2022 at 9:22

1 Answer 1

0

I think you should use go-subkey for this purpose. I don't know Go very well, but I think the code to transform accountID into hex string would look like this.

import (
    "github.com/vedhavyas/go-subkey/v2"
)

addr := "5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y"
_, pubkeyBytes, err := subkey.SS58Decode(addr)
// Handle err somehow
hexString := subkey.EncodeHex(pubkeyBytes)

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.