# Ternoa Ledger App
## Introduction
When storing your crypto, it's best to keep it in a hardware wallet to safeguard it against hacks. Ternoa's native currency CAPs can now be stored on Ledger devices.Ledger devices are hardware wallets that keep your secret key secured on a physical device that does not expose it to your computer or the internet. As the private keys associated with your tokens are stored on a secure element inside of the Ledger, they will never be leaked even if you connect to your computer.
Ledger devices are also hierarchical deterministic wallets (HD wallets),
* Deterministic means that there is only one seed phrase to generate all the accounts on different blockchain networks.
* Hierarchical means that the accounts are generated in a tree-like structure for different purposes.
Ledger devices can be equipped with blockchain-specific applications. These are usually developed by third parties and they enable the user to transact securely on the blockchain network.
The Ternoa Ledger application allows you to manage Ternoa’s native token, CAPS. It supports most of the transaction types of the network, including batch transactions from the Utility pallet.
:::warning
⚠️ **LEDGER APPS MAY NOT SUPPORT ALL TRANSACTION TYPES****
Please check [Ledger Ternoa App](https://github.com/capsule-corp-ternoa/ledger-ternoa/tree/dev) specifications for the list of transactions supported. Some transactions might only be supported on a specific version of the app and some transactions are not supported at all by any version.
:::
## Requirements/ Getting started
Before you can start using Ternoa with Ledger ensure that you have:
* A Ledger Nano X or Nano S plus (recommended for Ternoa Ledger App space requirements). The Ledger Nano S has limited memory and is no longer produced.
* Installed the latest firmware of the Ternoa Ledger App installed (always check for updates in Ledger Live under the "Manager" tab, you will need to allow access with your nano).
* Installed Ledger Liveat version 2.1 or higher (see settings -> about to find out if you're up to date).
* Installed a Chromium-based web browser you can use to access the [Polkadot-JS UI](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fmainnet.ternoa.network#/accounts). Because of required WebUSB support, Ledger wallets currently only work on Chromium-based browsers like Brave and Chrome.
## Using Ledger with Polkadot-JS Apps
### Loading Your Account
:::warning
⚠️ Please turn off Ledger Live while using your Ledger with PolkadotJS as it can interfere with normal operations.
:::
Start by importingt your Ledger account to the [Polkadot-JS UI](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fmainnet.ternoa.network#/accounts). You can find instructions on how to import your Ledger accounts to the Polkadot Extension in [this support article](https://support.polkadot.network/support/solutions/articles/65000175387-how-to-add-your-ledger-through-the-polkadot-extension). To import Ledger accounts to the Polkadot JS UI follow the steps outlined in [this article](https://support.polkadot.network/support/solutions/articles/65000170812-how-to-add-ledger-account-through-the-polkadot-js-ui).
### Derivation paths
When adding a Ledger account using the extension or the UI, you will be asked to select an <span style="color:DeepPink">account type</span> and an <span style="color:DeepPink">account index</span>. The first lets you select an account, while the second lets you pick a derivation path from that account. You can think of it as a formula from which child accounts are generated. When you are creating a Ternoa ledger account for the first time on Ledger Live with the name <span style="color:DeepPink">Ternoa 1</span>, this can be added to Polkadot JS using the 0/0 derivation path (i.e. account type = 0 and account index = 0). If then you add a second account called <span style="color:DeepPink">Ternoa 2</span>, this will correspond to the 1/0 derivation path, and so on.
We thus have multiple parent accounts that can be viewed and used in both Ledger Live and Polkadot JS. Additionally, we can use Polkadot-JS UI to create multiple children accounts from each parent account. For example, <span style="color:DeepPink">Ternoa 1</span> with 0/0 derivation path can have child 0/1, 0/2, etc. that can be used within the UI. However, such children accounts cannot be used in Ledger Live, as it only scans through the parent accounts. Keep in mind that the balances on the children's accounts cannot be viewed, and you will not be able to transact with those accounts on Ledger Live.
### Connecting your ledger device
When using a ledger device to sign transactions, you might need to confirm the USB connection through a popup like the one below:

If you are adding your Ledger Nano for the first time,pick your device (Nano S in this case) and the "Connect" button will become available.
:::warning
⚠️ **SIGNATURE ERROR MESSAGE**
If you already connected your device but an error message appears before signing a transaction, make sure you have opened the Ternoa application on your Ledger Nano device. Visit [this support page](https://support.polkadot.network/support/solutions/articles/65000181994) for more information about signing transactions using your ledger.
:::
### Confirming the Address on your Device
One of the security features hardware wallets offer is that they ask you to confirm your account address on the device to ensure that what you see on your computer is the correct address and hasn't been changed neither by the UI nor after copying it. This way you're sure that when you send tokens to your account, they'll arrive at the correct destination.
1. On the [Accounts](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fmainnet.ternoa.network#/accounts) page on Polkadot-JS UI, click on the three dots next to your Ledger account and select "Show address on hardware device"

2. On your Ledger the "Please review" message will appear. Click the right button to view your address and compare it to the one shown in the UI or to the one you just pasted in order to receive funds.

3. Then click the right button again and "Approve" to discard the message on your device.
### Checking the Balance of Your Account
You can see your balance in the [accounts](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fmainnet.ternoa.network#/accounts) section of Polkadot-JS UI.

### Sending a Transfer
:::info
💡 Here is a video of how to transfer funds with your Ledger: https://jmp.sh/g1xSDOfJ
:::
Whether your account is in the <span style="color:DeepPink">Polkadot extension</span> or created/added directly on the <span style="color:DeepPink">Polkadot-JS UI</span>, you'll need to use the Polkadot-JS UI interface to send funds or issue any extrinsic. The Polkadot extension is an account manager, not a wallet, so it requires a UI to interact with
Signing a transaction is the final step of any transaction, it approves sending funds out of your account. A transaction will not be broadcasted to the blockchain until you sign it. You sign a transaction with your private key, proving that you own this account. The signing process, however, depends on the wallet or account manager you use.
1. Connect your Ledger to the computer, unlock it, and open the Ternoa app

2. On Polkadot-JS UI, initiate a transaction and click <span style="color:DeepPink">"Sign and Submit":</span>


4. The message <span style="color:DeepPink">"Balance transfer"</span> will appear on your Ledger device. Press the right button to check the transaction details. After you have checked and confirmed the transaction details, you will see <span style="color:DeepPink">"Approve"</span> on your Ledger device. To sign the transaction, press both buttons on this screen

To reject the transaction, move to the next screen that says <span style="color:DeepPink">"Reject"</span> and press both buttons to confirm.
6. Congratulations, you have signed a transaction! It will be included in the blockchain within a few seconds.
:::warning
⚠️ For big transfers, consider doing a test transaction before sending large sums.
:::
### Receiving a Transfer
In order to receive funds to an account, you need to copy your account address and either share it with the sender or use it yourself. when sending funds from an exchange or another one of your accounts for example.
1. Go to the [Accounts](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fmainnet.ternoa.network#/accounts) page Polkadot-JS UI. That's where you can see all your accounts, regardless of type.
2. Click on the icon next to your account. This will <span style="color:DeepPink">copy</span> the account's address.

3. Paste the account to the proper destination.
* If you are receiving funds from someone else, share the address with them.
* If you are withdrawing funds from an exchange, paste the address in the appropriate field on the exchange's withdrawal page and select the proper Network (Ternoa CAPS)
* If you are sending funds from a different wallet, paste the address in the recipient's field on that wallet.
:::warning
⚠️ Before giving anyone your address, make sure it matches what's really on the Ledger by [confirming the address on your device](#Confirming-the-Address-on-your-Device). Some malware will intercept clicks and clipboard requests and can change your copied value in-flight, so being extra vigilant around copy-paste operations makes sense.
:::
## Ledger Developer Release
::: info
💡 This section is for developers only. It is recommended to install the application from Ledger Live unless you know exactly what you're doing.
:::
### Why you might need the Developer Release
The Ternoa Ledger app is developed by Capsule corp. When new functionalities are added to the Ledger apps, they are made available as a developer release for testing purposes. After a successful audit and review, the apps will then be made available for download and installation using [Ledger Live](https://www.ledger.com/ledger-live). As it takes some time for Ledger to audit and review every release, the app upgrade option may not be available on Ledger Live when the new runtime is deployed on the network. When this happens, users cannot use Ledger devices with the Polkadot-JS UI, and while signing for a transaction, they will most likely incur the error message "txn version not supported".
Please do not panic if this happens, as there are solutions to this problem. If you cannot wait a couple of days until the app passes the Ledger audit, you can install the developer release from the shell using the latest version published on the [Ternoa GitHub repository](https://github.com/capsule-corp-ternoa/ledger-ternoa).
### Install the Developer Release
Currently, the developer release can be installed only on the Nano S and S plus devices and can't be installed on the Nano X.
To install the developer version make sure you have the latest <span style="color:DeepPink">pip</span> version and follow the steps below:
* Install ledgerblue running the command
```bash=
python3 -m pip install ledgerblue
```
* Download the developer release from the [Ternoa GitHub repository](https://github.com/capsule-corp-ternoa/ledger-ternoa). The file will be named ```installer_nanos_plus.sh``` or similar depending on the ledger device you are using.
* Locate the downloaded shell script and make it executable in your shell by typing the command
```bash=
chmod +x installer_nanos_plus.sh
```
* You can now use the command ```--help``` to visualize the available options
```bash=
./installer_nanos_plus.sh --help
```

* Next plug your Ledger Nano to your computer, enter the PIN code and run the command
```bash=
./installer_nanos_plus.sh load
```
* Scroll with the right button until you see "Allow unsafe manager", left and right press to confirm.
You will be asked to confirm the action of uninstalling the app, and subsequently installing the newer version. After confirming both actions the shell script will proceed to install the version on your device. You will need to insert the PIN code to use the device after the installation.
:::info
💡 If you wish to revert the version back to stable release just go to Ledger Live, the app will automatically detect the developer release and give the option to install the previous stable release.
:::