resolveChainId method
Resolves and returns the active chain ID for the current context.
If the Eip7702Context.chainId field is already set, it is returned
immediately. Otherwise, the chain ID is fetched lazily from the network
using Web3Client.getChainId and cached inside the context for future
calls.
This method guarantees that builders and transaction utilities operate with a consistent chain ID throughout their lifecycle.
Example:
final chainId = await resolveChainId();
print('Connected to chain: $chainId');
Implementation
Future<BigInt> resolveChainId() async {
ctx.chainId ??= await ctx.web3Client.getChainId();
return ctx.chainId!;
}