How to use the @zilliqa-js/crypto.encodeBase58 function in @zilliqa-js/crypto

To help you get started, we’ve selected a few @zilliqa-js/crypto examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zilpay / zil-pay / extension / inpage / utils.js View on Github external
export function toAccountFormat(address) {
  /**
   * Replace from base16 to (base16, beach32, base58).
   */
  const isAddress = validation.isAddress(address);

  if (!isAddress) {
    throw new Error('input param is not address type');
  }

  return {
    base16: toChecksumAddress(address),
    base58: encodeBase58(address),
    bech32: toBech32Address(address)
  };
}
github zilpay / zil-pay / src / filters / toAddress.js View on Github external
export default function (hex, format, isTrim=true) {
  let address;

  try {
    if (format === 'Base16') {
      address = toChecksumAddress(hex);
    } else if (format === 'Base58') {
      address = encodeBase58(hex);
    } else if (format === 'Bech32') {
      address = toBech32Address(hex);
    }
  } catch(err) {
    return null;
  }

  if (isTrim) {
    address = trim(address);
  }

  return address;
}
github zilpay / zil-pay / extension / inpage / browser / zilPay.js View on Github external
setDefaultAccount(account) {
    if (!this.isEnable || !account || !this.isConnect) {
      return null;
    }

    const isAddress = validation.isAddress(account.address);
    
    if (!isAddress) {
      throw new Error('input param is not address type');
    }
    this.defaultAccount = {
      base16: toChecksumAddress(account.address),
      base58: encodeBase58(account.address),
      bech32: toBech32Address(account.address)
    };
    dispatchEvent(onAddressListing);
  }