How to use the @zilliqa-js/util.bytes.intToHexArray function in @zilliqa-js/util

To help you get started, we’ve selected a few @zilliqa-js/util 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-contract / src / factory.ts View on Github external
static getAddressForContract(tx: Transaction): string {
    // always subtract 1 from the tx nonce, as contract addresses are computed
    // based on the nonce in the global state.
    const nonce = tx.txParams.nonce ? tx.txParams.nonce - 1 : 0;

    return toChecksumAddress(
      hash
        .sha256()
        .update(tx.senderAddress, 'hex')
        .update(bytes.intToHexArray(nonce, 16).join(''), 'hex')
        .digest('hex')
        .slice(24),
    );
  }