call method

Future<Uint8List> call(
  1. CallRequest request, [
  2. String block = 'latest'
])

Executes a call without creating a transaction.

Supports EIP-3668 (CCIP-Read) off-chain lookups.

Implementation

Future<Uint8List> call(CallRequest request, [String block = 'latest']) async {
  try {
    final result = await provider.ethCall(request.toJson(), block);
    return HexUtils.decode(result);
  } on RpcError catch (e) {
    if (e.data != null && e.data is String) {
      final errorData = HexUtils.decode(e.data as String);
      if (errorData.length >= 4 &&
          BytesUtils.equals(
            errorData.sublist(0, 4),
            CCIPReadHandler.offchainLookupSelector,
          )) {
        return ccipHandler.handle(request.to ?? '', errorData, block);
      }
    }
    rethrow;
  }
}