Introducing FunctionX (FX) — Our First Ledger Nano Application
An introduction to FunctionX (FX) and how to use it.
A Ledger Device is a hardware wallet that stores private keys to your cryptocurrencies in an offline or “cold” storage. Even if we make a transaction from the hardware wallet, the hardware wallet is used in an offline environment and the mechanism to sign a transaction and broadcast it back to the blockchain network ensures that our private keys are always protected from the risk of any unauthorized access through the internet.
The f(x)Core blockchain is built on top of the Cosmos SDK and Tendermint protocol. In order to increase compatibility with the Ethereum ecosystem, Ethereum signatures in the f(x)Core and MarginX chains have been introduced since f(x)Core’s EVM upgrade. This EVM integration allows decentralized exchanges (DEXes), liquidity protocols, auto-compounders and other dApps to be deployed on the Function X network. One of the outcomes of the EVM upgrade is the generation of a new type of account that has both fx and 0x wallet types linked; or in other words, the generation of accounts that can support both coin types 118 (ATOM) and 60 (ETH).
At present, as a result of the EVM upgrade, it is not possible for f(x)Core users who are using Ethereum private keys to sign transactions with the Ledger device. To meet this challenge, our development team at Function X have forked and improved the Cosmos Ledger app, and the new Ledger app that we will be launching will allow f(x)Core users to sign transactions on f(x)Core and MarginX chains, and eventually Pundi X chains, with their Ledger devices.
Enter FunctionX (FX).
FunctionX (FX)
FunctionX (FX) is our first Ledger Nano app and it is an app that will run on Ledger Nano devices. The app will be supporting the coin: FX, which is the native utility token of the Function X ecosystem. Users can use the FunctionX app to sign transactions for f(x)Core, MarginX, and Pundi X chains on their Ledger devices.
Note: FunctionX only supports f(x)Core, MarginX and Pundi X chains. Coin types ATOM and ETH cannot be used, which means that other Cosmos chains and Ethereum chains are not supported.
At present, the app can only be installed locally through Function X’s Github repository and a series of CLI command (more below). When the app gets listed on the Ledger app catalog, the app can easily be downloaded through Ledger Live. This article will be updated with a guide on how to install FunctionX through the Ledger app catalog when FunctionX is approved by the team at Ledger.
Requirements
Before installing, make sure that:
- Your Ledger Nano device has been initialized
- The latest firmware for the device has been installed
- Ledger Live is ready to be used
- Your Ledger Nano device is connected to your computer or laptop
- If installing locally, ensure Docker is running and pip3 is installed, and run the installation on a bash shell
Local Installation method (Linux):
The following local installation steps will be carried out on the Ledger Nano S Plus. For Ledger Nano S and Ledger Nano X, please refer to the appropriate commands as described below.
- Pull the code from Github and switch to the “fx” branch of the repository
git clone https://github.com/FunctionX/ledger-cosmos.git
git switch fx
2. Pull the dependent modules
git submodule update --init --recursive
make deps
3. Ensure Docker is running, and build the app
# For Nano S:
make buildS
# For Nano S Pus:
make buildS2
#For Nano X:
make buildX
4. Install the app to the Ledger device. The device must be connected at this point. And a confirmation on the Ledger device will be required
# For Nano S:
make load
# For Nano S Plus:
make loadS2
# For Nano X:
make loadX
5. Close Ledger Live on your computer
6. Open the FunctionX app on the device
FunctionX is now ready to be used on your Ledger Nano device.
Ledger Live installation method (Ledger app catalog):
[To be updated after approval from Ledger]
How the use of Hardware wallets enhances security and user protection
The use of hardware saves us from the anxiety of exposing our funds to cryptocurrency hacks and theft by doing something simple — they keep our private keys offline.
As mentioned in the earlier in the article, Ledger hardware wallet is a device that stores private keys to your cryptocurrencies in an offline or “cold” storage — away from the internet. And even if a transaction is made from the hardware wallet, the hardware wallet signs the transaction in an offline environment. And this process helps to keep the user’s private keys away from any internet exposure at all times. For more information on Ledger, please visit this link.
All hardware wallets are non-custodial wallets, i.e. the user is the only one who has access to his or her private keys and funds. Thus when an individual uses a hardware wallet, the individual will have the private key associated with their cryptocurrency. If you’re reading this and you take crypto seriously, and you understand the (new) risks to such assets, you will understand that this type of storage is the only truly safe option.
There are many types of hardware wallets at present, but among them, the Ledger Nano series is by far the most secure hardware wallet. Ledger provides a pretty comprehensive article on why you should consider using their hardware wallet. In addition to giving the user complete control over their funds and keeping their keys offline, the hardware wallet protects a user’s keys with a higher level chip called Secure Element (SE). SE is a component that is used in a variety of security environments such as credit cards, passports, payment systems, and crypto hardware wallets; and it is known for providing the highest level of security for any system that manages sensitive data.
This means that, besides keeping your private keys offline (and away from hackers), the Ledger Nano device itself is also completely immune to external threats — all thanks to the host of state-of-the-art components inside.
Flowchart
How to Use FunctionX
Currently, the FunctionX app only supports transaction signing on f(x)Core, MarginX and Pundi X chains. Users would also need to have a copy of our fxdexd binaries to use the CLI tool to interact with the FunctionX app. Now that FunctionX is installed, here are some examples of how it can be used with Ledger devices.
1. Import of Key
Check the address of the key imported by the specified derivation path. If an account is imported using the same seed phrase of the Ledger device, you can check to see if the addresses match. Use the fxdexd CLI tool to import the key, and confirm in the FunctionX app.
# ledgerKey is the name of the key, which can be chose arbitrarily
# --ledger is the flag to interact with the Ledger device
# --acount is the flag for the account number in the BIP44 derivation path,
# and the value range is: 0 - 100 (Limitation of the Cosmos app)
fxdexd keys add ledgerKey --ledger --keyring-backend test --algo eth_secp256k1 --account 0
2. Transaction Signature using MarginX
Because all assets on MarginX are cross-chained from f(x)Core, users will need to first receive test tokens from the faucet and then cross-chain the assets through the MarginX cross-chain bridge.
Get the test tokens (f(x)Core-EVM USDT & f(x)Core FX) here.
Import the Ledger seed phrase into the f(x)Wallet app. You should see that your account has USDT on the f(x)Core chain.
Open MarginX’s exchange page and link your f(x)Wallet. Click on “Connect Wallet” and scan the QR code with your f(x)Wallet. You’ll be asked to authorize the connection on f(x)Wallet.
After connecting to MarginX, on the same page, click on “Bridge”, and bridge your tokens to one of the chains of MarginX. Here we will bridge USDT tokens to MarginX’s BTC/USDT chain.
Next, check the transaction status to ensure that the transaction was successfully confirmed and executed correctly; and that the address of the sender of the transaction matches what is displayed on the Ledger device. We will execute the transfer transaction through the CLI tool, and sign the transaction on the Ledger device. Be sure to specify the node RPC at the end of the CLI command and include the appropriate chain-id.
# Transfer transaction. After confirming on the CLI, sign the transaction on the Ledger device
fxdexd tx bank send ledgerKey 0x61bd2030908d658dd5a2139D2C13Af55b9138efb 10USDT --keyring-backend test --ledger --sign-mode "amino-json" --node "https://testnet-btc-json.marginx.io:26657" --chain-id "MarginX-Testnet-BTC"
Next, the transaction will be signed on the Ledger device. When reviewing the transaction, users will be able to review the chain ID, account, sequence, type of the transaction, amount transacted, from address, to address, transaction fees, and gas amount.
Viewing the Transaction on StarScan Explorer
After signing the transaction on the Ledger device, user’s will be able to copy the transaction hash returned in the CLI and view the transaction on our blockchain explorer.
Uninstalling FunctionX
To delete the app on the Ledger device, connect the Ledger device to the computer and run the following command
# For Nano S:
make delete
# For Nano S Plus:
make deleteS2
# For Nano X:
make deleteX
Sample Test Code That Interacts With Ledger Emulator
What’s next?
If you have not heard about Function X or MarginX and would like to find out more, be sure to check us out in the links below :)
We will be working to get FunctionX listed on the Ledger Live app catalog so that f(x)Core users can install the app easily through Ledger Live. Once FunctionX is approved by Ledger, we will update this article on how to install our app through Ledger Live, so stay tuned!
Support
Function X: https://functionx.io/
MarginX: https://marginx.io/
StarScan Explorer: https://starscan.io/
StarScan Forum: https://forum.starscan.io/
Function X on Medium: https://medium.com/functionx
Function X Foundation on Medium: https://medium.com/@functionx_io
Ledger: https://www.ledger.com/
Resources
FunctionX (FX) application Github repository: