Ledger Integration for fxcored
Last updated
Last updated
Using a hardware wallet to store your keys greatly improves the security of your crypto assets. The Ledger device acts as an enclave of the seed and private keys, and the process of signing transaction takes place within it. No private information ever leaves the Ledger device. The following is a short tutorial on using the Cosmos Ledger app with the Pundi AIFX CLI.
At the core of a Ledger device there is a mnemonic seed phrase that is used to generate private keys. This phrase is generated when you initialize your Ledger. The mnemonic is compatible with Cosmos and can be used to seed new accounts.
Before you use a ledger to set up your validator, do make sure you understand this setup. You will need:
Your ledger to have the Cosmos app installed
Pundi AIFX CLI installed on your local machine but this does not have to be a full-node or validator-node if you are remoting into a cloud server. (because your ledger is connected to your local machine, you will need Pundi AIFX installed locally and we will be using this to send commands to the cloud server.)
Your cloud server to be a full-node/validator node.
2 terminals opened, one to run the ssh port forwarding command.
The other with fxcored opened locally and we will be using this terminal to run our commands
Installing the Cosmos
application on your ledger device is required before you can use it with our Pundi AIFX CLI. To do so, you need to:
Open Ledger Live and navigate to the Manager tab.
Connect and unlock your Ledger device.
If asked, allow the manager on your device.
Search for the Cosmos (ATOM) app in the app catalog.
Click the Install button to install the app on your Ledger device.
Your Ledger device displays Processing.
Ledger Live displays Installed.
To see the
Cosmos
application when you search for it, you might need to activate theDeveloper Mode
, located in the Experimental features tab of the Ledger Live application.
The tool used to generate addresses and transactions on the Pundi AIFX network is fxcored
. You will be using fxcored CLI commands for creating transactions and then using your Ledger to sign off before broadcasting the transaction to a specified node using the fxcored CLI.
Connect and unlock your Ledger device.
Open the Cosmos app on your Ledger.
Create an account in fxcored from your ledger key.
Be sure to change the
_name
parameter to be a meaningful name. The--ledger
flag tellsfxcored
to use your Ledger to seed the account.
Additionally and ⚠⚠ importantly, if you wish to have an added layer of protection on your keys, you may add the --keyring-backend
flag and specify the file name. Setting your key up this way will ensure another layer of protection for signing any transactions.
--keyring-backend string Select keyring's backend (os|file|test) (default "test")
for example:
you will be prompted for a keyring passphrase (password must be at least 8 characters) :
In the future, whenever you use this account to sign off on a transaction, you will have to add the --keyring-backend <file_name>
flag and enter the keyring passphrase.
Run this command to display your address on your Ledger device. Use the _name
you gave your ledger key. The -d
flag is supported in version 1.5.0
and higher.
Confirm that the address displayed on the device matches the address displayed when you first added the key above.
Next, you need to configure fxcored with the URL of a Pundi AIFX full node and the appropriate chain_id
. In this example we connect to the public load balanced full node operated by Function X on the dhobyghaut
chain. But you can point your fxcored
to any Pundi AIFX
full node. Be sure that the chain-id
is set to the same chain as the full node.
Test your connection with a query such as:
You are now ready to start signing and sending transactions. Send a transaction with fxcored using the tx bank send
command.
Assuming you added the --keyring-backend <file>
flag earlier, an example of a transaction would look like the following:
You will be prompted to enter the passphrase for the --keyring-backend
flag:
Once inputted the correct passphrase:
To receive funds to the fx
account on your Ledger device, retrieve the address for your Ledger account (the ones with TYPE ledger
) with this command:
Not sure what fxcored
can do? Simply run the command without arguments to output documentation for the commands in supports.
The
fxcored
help commands are nested. So$ fxcored
will output docs for the top level commands (status, config, query, and tx). You can access documentation for sub commands with further help commands.
For example, to print the query
commands:
Or to print the tx
(transaction) commands:
chain-id
: The chain to which you are broadcasting the tx, such as the fxcore
dhobyghaut or fxcore
: mainnet.
account_number
: The global id of the sending account assigned when the account receives funds for the first time.
sequence
: The nonce for this account, incremented with each transaction.
fee
: JSON object describing the transaction fee, its gas amount and coin denomination
memo
: optional text field used in various ways to tag transactions.
msgs_<index>/<field>
: The array of messages included in the transaction. Double click to drill down into nested fields of the JSON.
To run the
Install on your machine.
Using Ledger Live, /.
More information on how to set up your Ledger device can be found .
Note: You need to on your Ledger Nano before moving on to this section
You need to before you proceed further
Cosmos uses . This means you can setup multiple accounts using the same Ledger seed. To create another account from your Ledger device, run the following, (changing the integer <i> to some value >= 0 to choose the account for HD derivation):
To run your own full node locally read more .
After inputting y
, you will be prompted to review and approve the transaction on your Ledger device.View Transaction
on your Ledger, be sure to inspect the transaction JSON displayed on the screen. You can scroll through each field and each message. You may refer to read more about the data fields of a standard transaction object. When prompted with confirm transaction before signing
, Answer Y
.
Transactions in fxcore embed the from the Cosmos SDK. The Ledger device displays a serialized JSON representation of this object for you to review before signing the transaction. Here are the fields and what they mean: