estimateDeployGas static method

Future<BigInt> estimateDeployGas({
  1. required String bytecode,
  2. required PublicClient publicClient,
  3. required String from,
  4. List constructorArgs = const [],
  5. BigInt? value,
})

Estimates gas for contract deployment.

Implementation

static Future<BigInt> estimateDeployGas({
  required String bytecode,
  required PublicClient publicClient,
  required String from,
  List<dynamic> constructorArgs = const [],
  BigInt? value,
}) async {
  // For now, we'll keep deployment simple without constructor args
  if (constructorArgs.isNotEmpty) {
    throw UnimplementedError('Constructor arguments not yet supported');
  }

  final deployData = HexUtils.decode(bytecode);

  final request = CallRequest(
    from: from,
    data: deployData,
    value: value,
  );

  return publicClient.estimateGas(request);
}