Blockchain 102: Cryptocurrencies, Wallets and DApps

A lot of people own cryptocurrencies today. But holding some tokens on an exchange does not mean interacting with the blockchain. The assets you trade are only numbers stored inside the exchange’s database. It’s because trading assets on-chain at high speed would be slow and super expensive.

To bring your cryptocurrencies to the blockchain and interact with decentralized applications (DApps), you have to create a blockchain account controlled by a private key and send your crypto assets.

This article will introduce you to the concept of tokens, accounts, wallets, and DApps (decentralized applications). It is the second of a series of 3 articles that focuses on the technical fundamentals behind crypto:

Disclaimer: Not a financial advice

Cryptocurrencies, coins and tokens

A cryptocurrency is a virtual currency that has no physical form. Unlike Fiat currencies (e.g. dollar or euro), a cryptocurrency can be hard-capped: its emission will stop when a defined cap is reached (e.g. there will never be more than 21,000,000 Bitcoins). Each cryptocurrency has a symbol that is a few letters, just like stocks:

  • BTC = Bitcoin;
  • ETH = Ethereum;
  • USDT = US Dollar Tether.

We can distinguish 2 types of cryptocurrencies:

  • Coins are the native currencies of blockchains and usually share the same name (e.g. Bitcoin, Ethereum, Solana). They are used to pay the blockchain’s fees (every transaction has a cost) and to reward network nodes (minors or validators, see Blockchain 101 for details).
  • Tokens are currencies built on programmable blockchains (e.g. Ethereum, Solana, Avalanche) and often tied to a DApp (see below) with different usages: reward DApp users, participate in token sales, etc.

Accounts, addresses, private keys and wallets

Account = private key + public key + address

On the blockchain, coins and tokens are held by accounts, each associated with an address.

An account is secured using asymmetric cryptography:

  • The private key gives control over the account: every transaction (e.g. send Bitcoins to another account) is signed using the private key;
  • The public key is used by the network to verify that transactions were issued by the account’s owner;
  • The public address is significantly smaller than the private and public keys and is used to easily interact with accounts (e.g. send tokens).

The private key is made up of 64 character hexadecimal characters. There are 2256 public keys that can be generated, which makes it nearly impossible to gain access to an existing account (1 chance in 1.55 quattuorvigintillion). Fun fact though, every private key is searchable on privatekeys.pw.

The address of the account is generated from the public key (using Keccak-256 hash), which is itself generated from the private key (using ECDSA). But thanks to cryptography, it is impossible to go the other way and find the private key from the address!


private_key = '0x272b77231156c432ece31f26ebd0a176616f7183f8c70ff0ac187b4d66e620ae'

public_key = ecdsa(private_key)


address = keccak_256(public_key)[:40]

Note: Because blockchains are decentralized, there is no such thing as password reset or 2FA! The private key is the single and only way to control an account. It is therefore super important to secure it.

Wallets and seed phrase

Wallets are software or hardware containers for private keys that allow users to submit transactions on the blockchain with their accounts.

HD wallets, seed and mnemonic

Today’s crypto wallets are hierarchical deterministic (HD) wallets that give a user access to multiple accounts using a single key: the seed. From this binary seed, the wallet is able to derive multiple key pairs in a deterministic way (through a cryptographic function). This means that all deterministic wallets will provide access to the same accounts from the same seed.

Example of a binary seed: 304a72b46b3090c97134a33040841d5afc577a6c7392cbc89e7daacb4cebfae7f05fd2178ec781164c0c36c79fb0c4766cc424807be9bbd27485473a6e483566.

As we can see, binary seeds are not very human-friendly: it is very hard to either remember or write down a seed for later reuse without mistake. This is why mnemonic seed phrases (or sentences) were designed. They allow to store the seed in the form of a sentence of 12 or 24 words (128 or 256 bits binary seed):

mnemonic = """
daughter  adult    chronic  estate   kiwi    river  helmet  hole
smoke     gallery  knock    awkward  opera   knock  arch    moon
improve   cigar    poem     monitor  prison  erode  rotate  energy
"""

binary_seed = seed_from_mnemonic(mnemonic)

The wallet is then able to find the binary seed and thus the private keys from the mnemonic seed phrase.

Software (hot) wallets

Software wallets (e.g. Metamask, XDEFI, Frame) are usually browser extensions or mobile apps that allow to easily interact with the blockchain. The user’s private keys are stored on his/her device and protected by a password.

Security best practices strongly discourage storing large amounts of cryptocurrencies using software wallets because they are located on internet-connected devices and are potentially subject to bug exploits.

Hardware (cold) wallets

Hardware wallets (e.g. Ledger, Trezor) are not connected to the internet. Users can sign transactions without having to expose their seed/mnemonic on an unsafe device (only digital signatures are sent through USB/Bluetooth). They rely on highly secure micro-chips to ensure that no one can gain access to the keys without the wallet pin code.

When using a hardware wallet, it is essential to store the backup mnemonic seed phrase offline (in case the wallet is lost).

DApps

A DApp (decentralized application) is an application that relies on a programmable blockchain (e.g. Ethereum, Solana, Avalanche) for all or at least critical parts of its backend. The DApp frontend (usually a website) connects to smart contracts and generates transactions that the user signs with its wallet.

Smart contracts

A smart contract is a program deployed to a blockchain composed of:

  • A state (all the data needed by the app to function);
  • An ensemble of deterministic functions that can be called by users through transactions.

Users have to pay fees to call functions that modify the smart contract’s state, but reading is free.

Like user accounts, a deployed smart contract has an address on the blockchain, but no private key: it cannot initiate transactions, only answer to calls from external entities.

For more on the benefits and drawbacks of DApps, see Benefits/Drawbacks of DApp Development.

DeFi (Decentralized Finance)

By using smart contracts, it is possible to deploy fully decentralized censorship-resistant finance applications that:

  • Cannot directly be shut down by a single entity (e.g. a government or a company);
  • Can be used by anyone, regardless of their social condition, criminal record, etc.

Here are the different types of DApps that we can find in the Decentralized Finance (DeFi) world:

  • Stablecoins are cryptocurrencies that attempt to peg their price to an external “real” asset. The most used ones are pegged to fiat money, namely the U.S. dollar (e.g. USDT, USDC, DAI).
  • Decentralized EXchanges (DEX) allow users to trade cryptocurrencies without any intermediary. Unlike on a Centralized EXchange (CEX) where all the liquidity is held by a single company, anyone can provide liquidity to a DEX. DEXes incentivize liquidity providers by paying them with their tokens (e.g. Uniswap rewards with UNI tokens, SpookySwap with BOO tokens).
  • Lending platforms (e.g. Aave, Anchor) allow users to borrow assets after depositing a collateral. This differs from lending to a bank because the amount you can borrow is not based on your salary, age, etc. but on the amount you deposited as collateral.
  • Yield Farming DApps aim to offer the best interest rates on crypto assets (e.g. Convex, Yearn)
  • Launchpads (e.g. DAO Maker, Avalaunch) allow users to invest early in projects that are not yet released. It is comparable to crowdfunding where users receive tokens as counterparts for their investment.
  • Play-to-Earn (GameFi) (e.g. Axie Infinity) is a kind of video game where users are rewarded with tokens when playing. Those tokens can then be sold against fiat money.

At the date of writing, more than one-tenth of all crypto market cap (in US dollar) is deposited on DeFi applications. A good website to track leading DApps by blockchain is Defi Llama.

Conclusion

You now know how users can interact with distributed ledgers using wallets and what type of applications are enabled by programmable blockchains! In the next article, I will focus on the broad EVM Ecosystem, that is becoming the de facto standard for the programming interface of blockchains.

Note: This article being long enough, I will not talk about NFTs (Non-Fungible Tokens)!

To go further

Leave a Reply