requestWriteContract method
Future
requestWriteContract({
- required String? topic,
- required String chainId,
- required DeployedContract deployedContract,
- required String functionName,
- required Transaction transaction,
- List parameters = const [],
- 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 = ReownAppKitModalNetworks.getCaip2Chain(chainId);
} else {
throw Errors.getSdkError(
Errors.UNSUPPORTED_CHAINS,
context: 'chainId should conform to "CAIP-2" format',
);
}
}
//
_appKit.core.logger.i(
'[$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;
}
}