Open Source PEK Android Wallet... Hive Dart
The Android App is coming along...

hive_engine_serivce_dart
import 'dart:convert';
import 'package:http/http.dart' as http;
class HiveEngineService {
static const String _apiUrl = 'https://api.hive-engine.com/rpc';
// Get PEK balance for a given account
static Future<double> getPekBalance(String account) async {
final response = await http.post(
Uri.parse(_apiUrl),
headers: {'Content-Type': 'application/json'},
body: jsonEncode({
'jsonrpc': '2.0',
'id': 1,
'method': 'find',
'params': {
'contract': 'tokens',
'table': 'balances',
'query': {'account': account, 'symbol': 'PEK'},
'limit': 1
}
}),
);
if (response.statusCode == 200) {
final data = jsonDecode(response.body);
if (data['result'] != null && data['result'].isNotEmpty) {
return double.tryParse(data['result'][0]['balance'] ?? '0') ?? 0.0;
}
return 0.0;
} else {
throw Exception('Failed to load balance');
}
}
// Transfer PEK tokens
static Future<String> transferPek({
required String from,
required String to,
required String amount,
required String activeKey,
String memo = '',
}) async {
// This is a placeholder. Real transfer requires signing a custom JSON transaction
// with the user's Hive active key, which should be handled securely.
// For a real wallet, use hive_keychain or hive_signer integration.
throw UnimplementedError('Token transfer must be implemented with proper signing.');
}
// Listen for incoming PEK transfers (polling example)
static Future<List<Map<String, dynamic>>> getRecentPekTransfers(String account) async {
final response = await http.post(
Uri.parse(_apiUrl),
headers: {'Content-Type': 'application/json'},
body: jsonEncode({
'jsonrpc': '2.0',
'id': 1,
'method': 'find',
'params': {
'contract': 'tokens',
'table': 'transfers',
'query': {
'
0
0
0.000
0 comments