requestWriteContract method

  1. @override
Future requestWriteContract({
  1. required String? topic,
  2. required String chainId,
  3. required DeployedContract deployedContract,
  4. required String functionName,
  5. required Transaction transaction,
  6. List parameters = const [],
  7. String? method,
})
override

Implementation

@override
Future<dynamic> requestWriteContract({
  required String? topic,
  required String chainId,
  required DeployedContract deployedContract,
  required String functionName,
  required Transaction transaction,
  List<dynamic> parameters = const [],
  String? method,
}) async {
  if (_currentSession == null) {
    throw ReownAppKitModalException('Session is null');
  }
  String reqChainId = chainId;
  final isValidChainId = NamespaceUtils.isValidChainId(chainId);
  if (!isValidChainId) {
    if (selectedChain!.chainId == chainId) {
      reqChainId = '${CoreConstants.namespace}:$chainId';
    } else {
      throw Errors.getSdkError(
        Errors.UNSUPPORTED_CHAINS,
        context: 'chainId should conform to "CAIP-2" format',
      );
    }
  }
  //
  _logger.d('[$runtimeType] requestWriteContract, chainId: $reqChainId');

  try {
    return await _appKit.requestWriteContract(
      topic: topic ?? '',
      chainId: reqChainId,
      deployedContract: deployedContract,
      functionName: functionName,
      transaction: transaction,
      parameters: parameters,
      method: method,
    );
  } catch (e) {
    rethrow;
  }
}