writeAddress static method

String writeAddress(
  1. String address
)

Implementation

static String writeAddress(String address) {
  var bs58checkdata = bs58check.decode(address).sublist(3);
  var _hex = hex.encode(bs58checkdata);
  if (address.startsWith("tz1")) {
    return "0000" + _hex;
  } else if (address.startsWith("tz2")) {
    return "0001" + _hex;
  } else if (address.startsWith("tz3")) {
    return "0002" + _hex;
  } else if (address.startsWith("KT1")) {
    return "01" + _hex + "00";
  } else {
    throw new Exception(
        'Unrecognized address prefix: ${address.substring(0, 3)}');
  }
}