How to use the @zilliqa-js/crypto.getAddressFromPublicKey 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 Zilliqa / Zilliqa-JavaScript-Library / packages / zilliqa-js-account / src / wallet.ts View on Github external
sign(tx: Transaction): Promise {
    if (tx.txParams && tx.txParams.pubKey) {
      // attempt to find the address
      const senderAddress = zcrypto.getAddressFromPublicKey(tx.txParams.pubKey);

      if (!this.accounts[senderAddress]) {
        throw new Error(
          `Could not sign the transaction with ${senderAddress} as it does not exist`,
        );
      }

      return this.signWith(tx, senderAddress);
    }

    if (!this.defaultAccount) {
      throw new Error('This wallet has no default account.');
    }

    return this.signWith(tx, this.defaultAccount.address);
  }
github Zilliqa / Zilliqa-JavaScript-Library / packages / zilliqa-js-account / src / account.ts View on Github external
constructor(privateKey: string) {
    this.privateKey = this.normalizePrivateKey(privateKey);
    this.publicKey = zcrypto.getPubKeyFromPrivateKey(this.privateKey);
    this.address = zcrypto.getAddressFromPublicKey(this.publicKey);
    this.bech32Address = zcrypto.toBech32Address(this.address);
  }
github Zilliqa / Zilliqa-JavaScript-Library / packages / zilliqa-js-account / src / transaction.ts View on Github external
get senderAddress(): string {
    if (!this.pubKey) {
      return '0'.repeat(40);
    }

    return getAddressFromPublicKey(this.pubKey);
  }