resolveNonce method

Future<BigInt> resolveNonce(
  1. EthereumAddress eoa, [
  2. Executor? executor,
  3. BigInt? nonceOverride
])

Resolves the next transaction nonce for the given externally owned account (EOA).

The returned nonce is computed as the current on-chain nonce (retrieved via getNonce) plus an optional offset supplied by the executor parameter. If nonceOverride is provided, it is returned immediately without querying the network.

The executor parameter defaults to Executor.self, which automatically increments the nonce by 1. Other Executor values may be used to reserve sequential nonces.

Example:

final nonce = await resolveNonce(myEoa, executor: Executor.relayer);
print('Next usable nonce: $nonce');

See also:

  • getNonce – fetches the current on-chain nonce.
  • Executor – enum defining nonce offset strategies.

Implementation

Future<BigInt> resolveNonce(
  EthereumAddress eoa, [
  Executor? executor,
  BigInt? nonceOverride,
]) async {
  if (nonceOverride != null) {
    return nonceOverride;
  }
  final nonce = await getNonce(eoa);
  return nonce + (executor?.value ?? BigInt.zero);
}