getMessage method

Future<Map<String, String>> getMessage(
  1. String address
)

Implementation

Future<Map<String, String>> getMessage(
  String address,
) async {
  try {
    final Map<String, String> headers = {'Content-Type': 'application/json'};
    final Map<String, dynamic> requestBody = {
      "json": {'address': address}
    };
    final response = await http.post(
      Uri.parse('https://sdk-iriko.huddle01.com/trpc/auth.signMessage'),
      headers: headers,
      body: jsonEncode(requestBody),
    );
    if (response.statusCode == 200) {
      final Map<String, dynamic> responseData = jsonDecode(response.body);
      final String text =
          responseData['result']['data']['json']['message'] as String;
      return {'message': text};
    } else {
      throw Exception('failed to get message');
    }
  } catch (error) {
    throw Exception('error getting message => $error');
  }
}