Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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),
);
}