code: async function getAccountNonce (accountId, nonce) {
    if (nonce) return nonce
    const { nonce: accountNonce } = await this.api.getAccountByPubkey(accountId).catch(() => ({ nonce: 0 }))
    return accountNonce + 1
  }
docs: Get the next nonce to be used for a transaction for an account
  
  @param {string} accountId
  @param {number} nonce
  @return {number} Next Nonce