Getting started in web3

Getting started: Blockchain, Wallets, DeFi and Uniswap

If you’re new to the world of blockchain and decentralised finance (DeFi) you may be wondering how to get started. In this short article I will explain what web3 and decentralised finance (DeFi) are, how to create a wallet, and some popular providers you can use to access DeFi services.

What is blockchain?

Blockchains are simply decentralised networks that implement a digital ledger used to record transactions across a bunch of computers. Each “block” in the chain contains a list of transactions and once a block has been submitted to the chain, it cannot be altered or reversed. This makes blockchains the ideal infrastructure for various applications such as DeFi.

Are you looking for a more detailed explanation? There are various articles and videos available that dive deeper into this topic. I would suggest checking out this video on YouTube!

Decentralised Finance (DeFi)

Decentralised Finance or DeFi is a new financial system built on top of blockchain networks generally through the use of smart contracts. Some notable examples of blockchain networks which allow for the deployment of smart contracts are Ethereum, Optimism, Avalance and zk-sync. There are also many other blockchain networks available today including private networks run by private entities such as banks. The latter could be argued to not be a decentralised network since they do not adhere to the principles of DeFi.

What are some principles of DeFi?

  1. Decentralisation: DeFi applications should be built on top of decentralised networks which means the network or application should not be controlled by a central authority. This allows users to access financial services without intermediaries like banks.
  2. Accessibility: DeFi applications should be open and accessible to anyone that has an internet connection allowing anyone in the world to access these services.
  3. Transparency: Since DeFi applications are built on top of blockchains this makes all transactions transparent and verifiable ensuring the integrity of the network which builds trust amongst users. Reputable DeFi applications have code that is readable by anyone (open-source) – this allows anyone to review the code and ensure the application is decentralised and trustworthy.
  4. Security: DeFi applications should rely on cryptography to protect users funds and ensure the integrity of the network. This means DeFi applications should not have any centralised control allowing bad actors to manipulate user funds.
  5. Non-Custodial: Funds deposited into DeFi applications should not be held in custody by any person or entity but rather be deposited directly into smart contracts.

Smart contracts are terms of agreement between participants written directly into lines of code. Users can execute particular terms (functions) in the smart contract to achieve a goal. Let’s look at a very simple and abstract example of a smart contract:

  • A smart contract developed by a third party (or could be developed by Alice or Bob!) automatically updates the exchange rate between USD and GBP. In this example, we will use an exchange rate of 0.8 USD for every GBP.
  • Alice wants to sell 100,000 USD for GBP. Instead of going through a traditional exchange where Alice would need to place trust in the exchange’s terms and agreements and hope the exchange is reputable, Alice can deposit these funds into a smart contract. The smart contract keeps track of who deposited these funds as well as other information pertinent to the functionality offered by the smart contract.
  • Alice’s funds are now sitting inside the smart contract waiting for a buyer.
  • Bob comes along and executes the trade function within the smart contract which automatically:
    • Transfers 45,000 GBP from his wallet (an amount chosen by Bob) into the smart contract
    • Determines there are sufficient funds to cover this conversion and determines that 45,000 GBP is worth 56,250 USD.
    • Transfers this 45,000 GBP directly into Alice’s wallet and withdraws 56,250 USD from the smart contract directly into Bob’s wallet.
  • Alice then determines she does not want to convert the remaining 43,750 USD into GBP and executes a withdraw function in the smart contract which withdraws the remaining 43,750 USD back to Alice.

The smart contract in this example allowed Alice and Bob to exchange their funds between two different currencies without the need for any intermediary! Smart contracts are a key component within the DeFi space and can be used to create increasingly complex financial agreements between an unlimited number of participants greatly increasing the efficiency, scalability and accessibility of financial services.

There are a vast number of applications available today including the ability to borrow and lend cryptocurrencies via providers such as AAVE, Compound and Liquity. You can checkout some of these DeFi applications on defiprime.

How do I get started?

This article will be focusing on the Ethereum network but is applicable to the vast majority of digital wallets including but not limited to Optimism, Avalanche and zk-sync.

Accessing web3 and DeFi services requires a “wallet”. A wallet is simply a digital wallet that allows you to store, manage and transfer cryptocurrencies between individuals, entities and smart contracts. Creating a wallet requires you to choose a provider since there are plenty available all with their advantages and disadvantages.

A digital wallet is simply a private key and public key used to perform cryptographic operations to prove you (and only you!) own the funds being transferred. Don’t worry, you won’t need to perform any of these cryptographic functions yourself!

Since the digital wallet is just a private key and public key (which is basically just a very large number), the vast majority of wallet providers allow you to generate these upon the creation of your new wallet. They typically generate the private key on the device you use to create the wallet (eg your phone) and provide you with a mnemonic phrase which is a series of words that can be used to represent your private key. This means you could take your mnemonic phrase from one wallet provider to another and not risk losing any funds.

Please note: It is crucial you keep your private key and mnemonic phrase secure and private since anyone who has access to this can restore your wallet and access your assets.

There are many digital wallet providers available today but they can be broken down into two categories:

  • Software Wallets: These are simply pieces of software that you can install and run on your devices such as your computer or mobile phone. The private key is stored on the device which can introduce security concerns – for example, if there is an application installed on your device that searches and extracts sensitive information (viruses, malware, etc). Notable examples of software wallet providers include Metamask and MyEtherWallet
  • Hardware Wallet: These are physical devices with the sole purpose to store your private key and ensure the private key never leaves the physical device. Hardware wallets are the most secure way to store your private key. Notable examples of hardware wallet providers include Ledger and Trezor

The main function of both software and hardware wallets is to sign messages cryptographically which are then broadcasted onto the blockchain network. Overall the choice between the two depends on your individual needs and preferences. If you want maximum security, a hardware wallet may be the best choice. If you favour ease of access from multiple devices, a software wallet may be the best choice. It’s important that you understand the differences and compare the two before deciding which type of wallet is right for you.

There are many popular cryptocurrency exchanges that exist such as Binance and Coinbase who act as custodians for your cryptocurrency assets. Note that when storing your cryptocurrency with these centralised entities you are trusting them entirely. There have been many examples of such exchanges being hacked or becoming bankrupt which has resulted in the loss of user funds. Notable examples are MtGox and more recently FTX. This is why it’s important to ensure you take control of your assets by storing them in your own digital wallet where you own the private key and have ultimate control.

Let’s take a look at how you can quickly get started using Metamask, a software wallet. If you are simply testing a software wallet is sufficient although not secure. If you are looking to manage a substantial amount of funds you may want to consider investing in a hardware wallet.

Getting started with Metamask

  • First, we will download Metamask onto our computer or mobile device. I would suggest using a mobile device since they are generally more secure than computers due to the limited number of applications on the device. You can do this by navigating to Metamask on your device’s application store. iOS/Apple Users, Android Users
  • Second, we will follow the prompts inside the Metamask application which will guide you through the process of creating a wallet. Please ensure you have your mnemonic securely stored since this can be used by anyone to restore your wallet.
  • That’s it! You now have a web3 wallet that can be used with any EVM-compatible blockchain network such as Ethereum, Avalanche, Optimism and zk-sync!

This is a reminder that the article is focusing on Ethereum specifically. The next steps are only if you are looking to interact with applications deployed on Ethereum!

Now that you have a digital wallet, you will need to acquire some ETH. You will need some ETH because this is the native cryptocurrency used to pay for transactions – also known as gas. You can read more about this in the ethereum documentation.

You only want to buy a small amount of ETH to start playing around with web3 and DeFi. At the time of writing (Dec 2022), purchasing 0.2 ETH is enough to follow along with this tutorial.

There are many ways to purchase ETH but you will need to ensure the ETH is withdrawn or delivered directly into your wallet. You can find your wallet address by opening your Metamask application and clicking on “Account 1” which will copy your wallet address (also known as your public key) to your clipboard. Here is an article by Metamask which explains this further.

The easiest way to purchase ETH is via the Metamask app by clicking “Buy” and following the instructions. Please note that you may not receive the best exchange rate via this method but it’s sufficient for testing and playing around with DeFi applications. Here is an article by Metamask which explains how to purchase ETH using their app.

You will know that you have purchased ETH successfully when your wallet within Metamask shows a balance greater than 0!

Uniswap

Uniswap is an open-source DeFi protocol known as a decentralised exchange (DEX) which allows users to exchange cryptocurrency tokens directly with each other without a central authority or matching engine.

The Uniswap protocol is built on a system of liquidity pools which are simply pools of cryptocurrency tokens managed by smart contracts. Whenever a user wants to trade one cryptocurrency for another, they can do this by sending funds to the liquidity pool which allows the smart contract to automatically match the trade with another user who wants to trade the opposite pair.

Uniswap has recently released support for non-fungible tokens (NFTs). This article will not be diving deeper into NFTs but if you are interested you can read this article by the Ethereum Foundation.

Uniswap is known for its simplicity and accessibility. The application has a user-friendly user interface and does not require you to sign up or go through any Know-Your-Customer (KYC) process.

How do I use Uniswap?

This example is going to focus on trading a small amount of ETH into DAI. DAI is a decentralised stablecoin pegged to the US dollar and used by many users within the cryptocurrency industry. You can read more about DAI and how its collateralized in a decentralised way in this Kraken article.

  1. Visit the Uniswap website at https://app.uniswap.org/
  2. Connect your digital wallet
    1. Mobile users: Click the “Connect” button on the top right, hit WalletConnect then click Metamask which will open the Metamask application on your mobile device and ask you to connect your digital wallet to Metamask.
    2. Computer users: Click the “Connect” button on the top right.
      1. If you are using Metamask also on your computer, click Metamask. Please note you will need to use the same browser where you installed and configured Metamak
      2. If you are using Metamask on mobile (as advised in this article), click WalletConnect which will bring up a QR code. Open your Metamask application on your mobile device and hit the scan button on the top right. Scan the QR code and hit Connect.
  3. Well done! You have now successfully connected your digital wallet to Uniswap, a decentralised finance application. It is important to note that although your digital wallet is now connected to Uniswap, the application cannot perform any transactions without your digital signature.
  4. You can now pick ETH from the first dropdown and USDC from the second. Type in a small number of ETH you want to swap for USDC and hit the Swap button!
    1. Review the details of the trade, including the number of tokens you are trading and the transaction fees. If everything looks good/reasonable, click on the “Swap” button
  5. This will initiate the transaction on your Metamask wallet which will require you to sign the message cryptographically. You can do this by simply clicking”continue” or”sign” in the Metamask app!
  6. After a short period of time, the amount of ETH you specified will be swapped for USDC

That’s it! You have now successfully traded some ETH for USDC using Uniswap, a decentralised finance application running on Ethereum, a decentralised network. Notice how this entire process was completed without using any custodian whilst maintaining the security of your assets.

You now possess a basic understanding of wallets, DeFi and Uniswap! Take a look at all the different types of DeFi applications on defiprime!

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.