How to Use Ledger Nano With Solana CLI

2/17/2023, 11:38:32 AM - Henry Chikwem
How to Use Ledger Nano With Solana CLI

Solana has witnessed some interesting upgrades in recent times with the introduction of the fee market and stake-weighted QoS on its Mainnet.

Moving on, Solana has, as part of its tool suite, the command line interface, which is the first place the Solana core team deploys new functionality. 

The command-line interface is not necessarily the easiest to use, but it provides the most direct, flexible, and secure access to your Solana accounts.

In this article, I’ll show you how to your Ledger Nano wallet with the Solana CLI. It may be a bit challenging but follow through as I simplify the steps.

Blog post image

Key Takeaways

• Solana has over 1000 decentralized applications actively running on it while at the same time having the fastest transaction processing speed.

• Apart from the Ledger Nano, you can use a file system wallet and a paper wallet to connect with Solana CLI.

• The Solana Explorer has an accounts tab, which is excellent for checking the balance of an account address.

• With Solana CLI, investors can manage multiple wallet addresses through qualified keypair URLs.

SEE ALSO: 5 Recommended Wallets to Store Solana NFTs

SEE ALSO: Solana Blockchain Size (All You Need to Know)

SEE ALSO: How Much Do Solana Validators Make?

Using Solana CLI

Solana CLI is a collection of different commands for each action you might want to take. You can view the list of all possible commands by running:

Blog post image

To zoom in on how to use a particular command, run:

Blog post image

where you replace the text <COMMAND> with the name of the command you want to learn more about.

The command’s usage message will typically contain words such as <AMOUNT>, <ACCOUNT_ADDRESS>, or <KEYPAIR>. Each word is a placeholder for the type of text you can execute the command with.

For example, you can replace <AMOUNT> with a number such as 42 or 100.42.

You can replace <ACCOUNT_ADDRESS> with the base58 encoding of your public key, such as 9grmKMwTiZwUHSExjtbFzHLPTdWoXgcg1bZkhvwTrTww.

Keypair Conventions

Many commands using the CLI tools require a value for a <KEYPAIR>. The value you should use for the keypair depends on what type of command line wallet you created.

For example, the CLI help shows that the way to display any wallet’s address (also known as the keypair’s pubkey), is:

Blog post image

Below is how to resolve what you should put in <KEYPAIR> depending on your wallet type.

Paper Wallet

In a paper wallet, the keypair is securely derived from the seed words and optional passphrase you entered when the wallet was created.

To use a paper wallet keypair anywhere the <KEYPAIR> text is shown in examples or help documents, enter the uri scheme prompt://, and the program will prompt you to enter your seed words when you run the command.

To display the wallet address of a paper wallet:

Blog post image

File System Wallet

With a file system wallet, the keypair is stored in a file on your computer. Replace <KEYPAIR> with the complete file path to the keypair file.

For example, if the file system keypair file location is /home/solana/my_wallet.json, to display the address, do:

Blog post image

Hardware Wallet

If you chose a hardware wallet, use your keypair URL, such as usb://ledger?key=0.

Blog post image

Using Ledger Nano with CLI

Before using Ledger Nano with CLI, set up a Nano with the Solana app, then install the Solana command-line tools.

Also, while using the Ledger Nano with Solana CLI, ensure that the following are adhered to:

  • Ensure the Ledger Live application is closed
  • Plug your Nano into your computer’s USB port
  • Enter your pin and start the Solana app on the Nano
  • Ensure the screen reads “Application is ready”

View your Wallet ID

On your computer run:

Blog post image

This confirms your Ledger device is connected properly and in the correct state to interact with the Solana CLI. The command returns your Ledger’s unique wallet ID.

When you have multiple Nano devices connected to the same computer, you can use your wallet ID to specify which Ledger hardware wallet you want to use. 

If you only plan to use a single Nano on your computer at a time, you don’t need to include the wallet ID.

View your Wallet Addresses

Your Nano supports an arbitrary number of valid wallet addresses and signers.

To view any address, use the Solana-keygen pubkey command, as shown below, followed by a valid keypair URL.

Multiple wallet addresses can be useful if you want to transfer tokens between your accounts for different purposes or use different keypairs on the device as signing authorities for a stake account, for example.

All of the following commands will display different addresses, associated with the keypair path given. You must try them all out.

Blog post image

You can use other values for the number after key= as well. Any of the addresses displayed by these commands are valid Solana wallet addresses.

The private portion associated with each address is stored securely on the Nano and is used to sign transactions from this address.

Just make a note of which keypair URL you used to derive any address you will be using to receive tokens.

If you are only planning to use a single address/key pair on your device, a good easy-to-remember path might be to use the address at key=0. View this address with:

Blog post image

Now you have a wallet address (or multiple addresses), you can share any of these addresses publicly to act as a receiving address, and you can use the associated keypair URL as the signer for transactions from that address.

View your Balance

To view the balance of any account, regardless of which wallet it uses, use the Solana balance command:

Blog post image

For example, if your address is 7cvkjYAkUYs4W8XcXsca7cBrEGFeSUjeZmKoNBvEwyri, then enter the following command to view the balance:

Blog post image

You can also view the balance of any account address on the Accounts tab in Explorer and paste the address in the box to view the balance in your web browser.

Note: Any address with a balance of 0 SOL, such as a newly created one on your Ledger, will show as “Not Found” in the explorer.

Empty accounts and non-existent accounts are treated the same in Solana. This will change when your account address has some SOL in it.

Send SOL from a Nano Wallet

To send some tokens from an address controlled by your Nano, you will need to use the device to sign a transaction, using the same keypair URL you used to derive the address. 

To do this, make sure your Nano is plugged in and unlocked with the PIN, Ledger Live is not running, and the Solana App is open on the device, showing “Application is Ready”.

The Solana transfer command is used to specify to which address to send tokens, and how many tokens to send, and uses the –keypair argument to specify which keypair is sending the tokens, which will sign the transaction and the balance from the associated address will decrease.

Blog post image

Below is a full example. First, an address is viewed at a certain keypair URL. Second, the balance of that address is checked. 

Lastly, a transfer transaction is entered to send 1 SOL to the recipient address 7cvkjYAkUYs4W8XcXsca7cBrEGFeSUjeZmKoNBvEwyri.

When you hit Enter for a transfer command, you will be prompted to approve the transaction details on your Ledger device.

On the device, use the right and left buttons to review the transaction details. If they look correct, click both buttons on the “Approve” screen, otherwise push both buttons on the “Reject” screen.

Blog post image

After approving the transaction on your device, the program will display the transaction signature, and wait for the maximum number of confirmations (32) before returning. 

This only takes a few seconds, and then the transaction is finalized on the Solana network. You can view details of this or any other transaction by going to the Transaction tab in Explorer and pasting in the transaction signature.

Frequently Asked Questions (FAQs)

How can I stake SOL?

When you stake your Solana, you have the option of deciding how much of your SOL to delegate to the Validator.

You can stake any amount of SOL and begin earning rewards right away. During this time, you will be able to conduct transactions only with the unspent amount of SOL in your wallet.

Is there a minimum amount of SOL needed to start staking?

No, you don’t need a minimum amount, but make sure that you leave a little in your account for the transaction fees.

Final Thoughts

The Solana network has been making massive improvements over time and it has been felt within its mainnet and even its native token has seen positive performances as well.

With the Solana command line interface (CLI), investors can utilize it in conjunction with their Nano wallets to get process crypto transactions the right way. You only need to go through this article to be well on your way to doing just that.

Read More