MetaMask & DeFi

This tutorial explains how to use your Keystone & MetaMask to interact with DeFi platforms (dapps) using Uniswap as an example. The same method would apply for other dapps.

I. Preparation

1. Firmware version M-5.0 (Multi-Cion) running on Keystone Essential or Pro.

(Please read How to upgrade firmware for more details.)

2. Bind MetaMask extension V10.8.0 or newer with the Keystone Hardware Wallet (Tutorial).

3. Uniswap: https://app.uniswap.org/#/swap.

II. Connect Uniswap to "MetaMask Extension

1. Visit Uniswap website: https://app.uniswap.org/#/swap. Switch to the [Swap] tab and click [Connect wallet].

2. Select [MetaMask] as your wallet, Then click [Next] to connect.

3. Uniswap should now be successfully connected with your MetaMask (Keystone account).

III. Swap from ETH to Tokens (e.g. USDT)

1. Select a Token (e.g. USDT) and set the amount you want to swap, then click [Swap].

2. Confirm the transaction details and click [Confirm Swap].

3. Click [Confirm] on MetaMask Extension to get the unsigned transaction data in QR code format.

4. Keystone: Touch the “Scan” icon and scan the QR code shown on MetaMask Extension.

5. Confirm the transaction details on Keystone Hardware Wallet. Touch [Sign] and enter the password to verify. Get the signed transaction data in QR code format.

6. Click [Get Signature] on MetaMask Extension and scan the QR code shown on the Keystone device.

7. Transaction submitted automatically after the scanning is finished.

IV. Swap from Tokens to ETH/Tokens

1. Approve

If it is the first time you are swapping from Token A to ETH or Token B, you will be required to authorize [Approve] the third party (e.g. the smart contract of Token A) to spend Token A in your wallet before you can [Swap].

1) Uniswap: Select the coin type and set the amount you want to swap. Click [Approve]. Then click [Confirm] on MetaMask Extension to get the unsigned transaction data in QR code format.

2) On Keystone: Touch the “scan” icon and scan the QR code that is shown on MetaMask Extension. Confirm the transaction details on Keystone. Touch [Sign] and enter your password/fingerprint to verify. It will then show the signed transaction data in QR code format.

3) Click [Get Signature] on MetaMask Extension and scan the QR code shown on the Keystone device to broadcast the transaction.

2. Swap

The process of “Swap from Tokens to ETH / Tokens” is the same as the one of “Swap from ETH to Tokens”. The only difference is the methods of calling contracts.

V. Add Liquidity (e.g. ETH + UNI)

This part of the tutorial will explain how to add V2 liquidity on the Rinkeby testnet as an example. And the process of "add liquidity" on mainnet is the same as on testnet.

1. Approve

If it is the first time you are adding liquidity to a pair, you will be required to click [Approve] to authorize the third party (e.g. the smart contract of Token A) to spend Token A in your wallet before you can [Supply].

1) Switch to the “Pool” tab on Uniswap. Click [More] > [V2 Liquidity ] > [Add V2 Liquidity].

2) Select the coin type and set the amount you want to supply. Then click [Approve UNI].

(Tip: You can set fee tier and price range yourself If you are adding V3 liquidity).

3) Click [Confirm] on MetaMask Extension to get the unsigned transaction data in QR code format.

4) Keystone Hardware Wallet: Touch the “scan” icon and scan the QR code shown on MetaMask Extension.

5) Confirm the transaction details on the Keystone device. Touch [Sign] and enter a password or fingerprint to verify. This will then show the signed transaction data in QR code format.

6) Click [Get Signature] on MetaMask Extension and scan the QR code shown on Keystone device.

7) The transaction will be submitted automatically after the scanning has finished.

2. Supply

1) Once the approving transaction is confirmed, click [Supply].

2) Confirm the transaction details and click [Confirm Supply].

3) Click [Confirm] on MetaMask Extension to get the unsigned transaction data in QR code format.

4) Keystone Hardware Wallet: Touch the “Scan” icon and scan the QR code shown on MetaMask Extension.

5) Confirm the transaction details on the Keystone device. Touch [Sign] and enter your password or fingerprint to verify. The device will then show the signed transaction data in QR code format.

6) Click [Get Signature] on MetaMask Extension and scan the QR code shown on the Keystone device.

7) The transaction is submitted automatically after the scanning has finished.

VI. Remove Liquidity

This part of the tutorial will explain how to remove liquidity on the Rinkeby testnet as an example. And the process of "remove liquidity" on mainnet is the same as on testnet.

1. Approve

If it is the first time you are removing the liquidity of a given liquidity pair, you will be required to click [Approve] to authorize the third party (e.g. the smart contract of Token A) to spend Token A in your wallet before you can [Remove] liquidity.

1) Switch to the “Pool” tab on Uniswap. Click [Manage] -> [Remove].

2) Set the amount and click [Approve].

3) Click [SIGN] on MetaMask Extension to get the unsigned message in QR code format.

4) Keystone Hardware Wallet: Touch the “scan” icon and scan the QR code shown on MetaMask Extension.

5) Confirm the message on the Keystone device. Touch [Sign] and enter your password or fingerprint to verify. After signing, you will then receive the sign message in a QR code format.

6) Click [Get Signature] on MetaMask Extension and scan the QR code shown on your Keystone device.

7) Approval has been completed.

2. Remove

1) Once the approval is completed, click [Remove].

2) Confirm the transaction details and click [Confirm].

3) Click [Confirm] on MetaMask Extension to get the unsigned message in QR code format.

4) Keystone Hardware Wallet: Touch the “Scan” icon and scan the QR code shown on MetaMask Extension.

5) Confirm the transaction data on your Keystone device. Touch [Sign] and enter your password or fingerprint to verify. The device will then show the signed transaction data in QR code format.

6) Click [Get Signature] on MetaMask Extension and scan the QR code shown on your Keystone device.

7) The transaction is submitted automatically after the scanning has finished.

Instructions recommended:

pageDecoding DeFi Transactions

Last updated