A Flutter Ledger App Plugin for the Cardano blockchain
Report Bug
· Request Feature
· Ledger Cardano Plus
Ledger Nano devices are the perfect hardware wallets for managing your crypto & NFTs on the go. This Flutter package is a plugin for the ledger_flutter_plus package to get accounts and sign transactions using the Cardano blockchain.
Install the latest version of this package via pub.dev:
ledger_cardano_plus: ^latest-version
ledger_flutter_plus: ^latest-versionFor integration with the Ledger Flutter Plus package, check out the documentation here.
Get an instance of an CardanoLedger and then use it to scan and connect to devices.
final CardanoLedger cardanoLedgerConnector = CardanoLedger.ble(
onPermissionRequest: (status) async {
// if ([AvailabilityState.unsupported].contains(status)) {
// return false;
// }
// this is using permission_handler package
Map<Permission, PermissionStatus> statuses = await [
Permission.location,
Permission.bluetoothScan,
Permission.bluetoothConnect,
Permission.bluetoothAdvertise,
].request();
return statuses.values.where((status) => status.isDenied).isEmpty;
},
);
// FOR USB
// final CardanoLedger cardanoLedgerConnector = CardanoLedger.usb();
final devicesStream = cardanoLedgerConnector.scanForDevices();
// Best is to actually listen to the stream and then allow the user to select
// the wanted ledger device
final firstLedgerDevice = await devicesStream.first;
final cardanoApp = cardanoLedgerConnector.connect(firstLedgerDevice);
// To derive receive address
final receiveAddress = await cardanoApp.deriveReceiveAddress(
addressIndex: addressIndex,
network: CardanoNetwork.mainnet(),
);For moe in depth sample including device selection dialog, check out the example project in this repo
Our top sponsors are shown below!
|
|
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag enhancement.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/my-feature) - Commit your Changes (
git commit -m 'feat: my new feature) - Push to the Branch (
git push origin feature/my-feature) - Open a Pull Request
Please read our Contributing guidelines and try to follow Conventional Commits.
To run the integration tests for the ledger-cardano-plus SDK, follow these steps:
-
Set Up Your Environment:
- Ensure that you have Flutter installed on your machine. You can download it from Flutter's official site.
-
Clone the Repository:
- If you haven't already, clone the
ledger-cardano-plusrepository from GitHub:
git clone https://github.com/vespr-wallet/ledger-cardano-plus.git cd ledger-cardano-plus - If you haven't already, clone the
-
Navigate to the Integration Tests Directory:
- Change to the directory containing the integration tests:
cd example/integration_test -
Set up your Ledger device:
- Use the test recovery phrase:
abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about - Open the Cardano app on the device and make sure the device is unlocked.
- For the unrestricted-transaction test, Enable Expert mode (Cardano app → settings).
- Use the test recovery phrase:
-
Choose the target device (
-d):- Integration tests run on a host target (an Android device) that connects to the Ledger over BLE/USB. List available targets:
flutter devices
- Pass the desired target to every test command with
-d, e.g.-d <android-device-id>.
-
Run the Tests:
- Run all integration tests on a chosen target:
cd example flutter test integration_test/*_tests.dart -d <device-id>
- To run a specific integration test file, provide the path to the test file:
cd example flutter test integration_test/sign_message_tests.dart -d <device-id>
- To run a specific test case within a test file, use the
-nflag followed by the test name:
cd example flutter test integration_test/cardano_ledger_serial_version_tests.dart -n "Should correctly get the serial number of the device" -d <device-id>
Expert mode:
sign_tx_unrestricted_tests.dartis split into its own entry point because it needs Expert mode enabled. The*_tests.dartglob above includes it, so either enable Expert mode before a full run, or run it on its own:cd example flutter test integration_test/sign_tx_unrestricted_tests.dart -d <device-id>
Make sure your environment is set up to communicate with the Ledger device, and that the device is connected, unlocked, and running the Cardano app before running the tests.
The ledger_cardano_plus SDK is released under the MIT License (MIT). See LICENSE for details.