openlv 0.0.2
openlv: ^0.0.2 copied to clipboard
Dart bindings for Open Lavatory (openlv), a secure peer-to-peer wallet connectivity protocol. Wraps the openlv Rust crate via UniFFI.
Secure peer-to-peer connectivity between dApps and wallets
Features #
- Privacy-first, end-to-end encrypted, no metrics, no tracking
- No central dependency, rather a variety of signaling layers
- Peer-to-peer transport via WebRTC (or other transport layers)
- Reuse of existing infrastructure and p2p standards
- User control over connection & configuration
Quickstart #
dApp (host) #
import 'package:openlv/openlv.dart';
final dapp = await OpenLv.dapp(
info: PeerInfo(identity: 'com.example.dapp', name: 'Example dApp'),
onRequest: (message) async {
final request = message as Map<String, dynamic>;
return {
'jsonrpc': '2.0',
'id': request['id'],
'error': {'code': -32601, 'message': 'Method not found'},
};
},
);
await dapp.connect();
print('Connection URL: ${dapp.uri}'); // share with the wallet
await dapp.waitForLink();
final response = await dapp.send({
'jsonrpc': '2.0',
'id': 1,
'method': 'eth_chainId',
'params': [],
});
print('Response: $response');
await dapp.close();
Wallet (client) #
final wallet = await OpenLv.wallet(
'openlv://...', // connection URL from the dApp
info: PeerInfo(identity: 'com.example.wallet', name: 'Example Wallet'),
onRequest: (message) async {
final request = message as Map<String, dynamic>;
return {
'jsonrpc': '2.0',
'id': request['id'],
'error': {'code': -32601, 'message': 'Method not found'},
};
},
);
await wallet.connect();
await wallet.waitForLink();
print('Connected!');
await wallet.close();
See example/ for a small Flutter app exercising both roles.
Native builds & platform setup #
openlv supports Android, iOS, Linux, macOS, and Windows.
Make sure you have a rust toolchain setup.
And for cross-compilation you'll also need Android NDK or Xcode.
You can also adjust the hooks.user_defines.openlv.profile in your application's pubspec.yaml to debug for development.
Consumer Flutter apps need network access:
- Android: add
<uses-permission android:name="android.permission.INTERNET" />toandroid/app/src/main/AndroidManifest.xml. - macOS: enable
com.apple.security.network.clientin bothDebugProfile.entitlementsandRelease.entitlementswhen using App Sandbox.