ledger_cardano_plus 0.5.10 copy "ledger_cardano_plus: ^0.5.10" to clipboard
ledger_cardano_plus: ^0.5.10 copied to clipboard

A Ledger App Plugin for the Cardano blockchain, using Ledger Cardano Plus for device communication.


ledger-cardano-plus

A Flutter Ledger App Plugin for the Cardano blockchain
Report Bug · Request Feature · Ledger Cardano Plus



Overview #

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.

Getting started #

Installation #

Install the latest version of this package via pub.dev:

ledger_cardano_plus: ^latest-version
ledger_flutter_plus: ^latest-version

For integration with the Ledger Flutter Plus package, check out the documentation here.

Setup and Usage #

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

Sponsors #

Our top sponsors are shown below!

Project Catalyst

Contributing #

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.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/my-feature)
  3. Commit your Changes (git commit -m 'feat: my new feature)
  4. Push to the Branch (git push origin feature/my-feature)
  5. Open a Pull Request

Please read our Contributing guidelines and try to follow Conventional Commits.

Running Integration Tests #

To run the integration tests for the ledger-cardano-plus SDK, follow these steps:

  1. Set Up Your Environment:

  2. Clone the Repository:

    • If you haven't already, clone the ledger-cardano-plus repository from GitHub:
    git clone https://github.com/vespr-wallet/ledger-cardano-plus.git
    cd ledger-cardano-plus
    
  3. Navigate to the Integration Tests Directory:

    • Change to the directory containing the integration tests:
    cd example/integration_test
    
  4. 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).
  5. 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>.
  6. 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 -n flag 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.dart is split into its own entry point because it needs Expert mode enabled. The *_tests.dart glob 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.

License #

The ledger_cardano_plus SDK is released under the MIT License (MIT). See LICENSE for details.

1
likes
150
points
297
downloads

Documentation

API reference

Publisher

verified publishervespr.xyz

Weekly Downloads

A Ledger App Plugin for the Cardano blockchain, using Ledger Cardano Plus for device communication.

Repository (GitHub)
View/report issues
Contributing

License

MIT (license)

Dependencies

base_x, bech32, collection, flutter, freezed_annotation, ledger_flutter_plus

More

Packages that depend on ledger_cardano_plus