Blockchain 102: Cryptocurrencies, Wallets and DApps

Many people own cryptocurrencies today. But holding some tokens on an exchange means not interacting with the blockchain. The assets you trade are only numbers stored in the exchange's database. That's because trading assets on the chain at high speed would be slow and super expensive.

To bring your cryptocurrencies to the blockchain and interact with decentralized applications (DApps), you must 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's the second of a three-part series focusing on the technical basics behind crypto:

Disclaimer: Not a financial advice

Cryptocurrencies, coins and tokens

A cryptocurrency is a virtual currency which has no physical form. Unlike Fiat currencies (eg dollars or euros), a cryptocurrency can be hard cut: its emission will stop when a defined cap is reached (eg there will never be more than 21,000,000 Bitcoins). Every cryptocurrency has one symbol it's a few letters, just like stocks:

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

We can distinguish two types of cryptocurrencies:

  • Coin are they domestic currencies blockchains and usually have the same name (e.g Bitcoin, Ethereum, Solana). They are used to pay the blockchain's fees (each transaction has a cost) and to reward network nodes (minors or validators, see Blockchain 101 for details).
  • Tokens are currencies based on programmable blockchains (for example Ethereum, Solana, Avalanche) and often tied to a DApp (see below) with various uses: rewarding DApp users, participating in token sales, etc.

Accounts, addresses, private keys and wallets

Account = private key + public key + address

On the blockchain are coins and tokens held by accountseach associated with an address.

An account is secured using asymmetric cryptography:

  • The private key provides control over the account: every transaction (eg sending Bitcoins to another account) is signed with the private key;
  • The public key used by the network to verify that transactions have been issued by the owner of the account;
  • 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 consists of 64 hexadecimal characters. There is 2256 public keys that can be generated, making it almost impossible to access 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: Since blockchains are decentralized, there is no such thing as password recovery or 2FA! The private key is the one and only way to control an account. It is therefore super important to secure it.

Wallets and seed phrase

Wallets are software or hardware container for private keys which allows users to submit transactions on the blockchain with their accounts.

HD wallets, seed and mnemonic

Today's crypto wallets are hierarchical deterministic (HD) wallets which gives a user access to multiple accounts using one single key: the seed. From this binary seed the wallet can 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 is seeds not very human friendly: it is very difficult to either remember or write down a seed for later reuse without mistake. This is why mnemonic seed phrases (or sentences) were formed. They allow to store the seed in form of a sentence of 12 or 24 words (128 or 256 bit 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 can then find the binary seed and thus the private keys from the mnemonic seed phrase.

Software (hot) wallets

Software wallets (for example Metamask, XDEFI, Frame) is usually browser extensions or mobile apps which makes it easy to interact with the blockchain. User's private keys are stored on his/her device and protected by a password.

Security best practices strong advise against storing large amounts of cryptocurrencies use software wallets because they are on internet connected devices and is potential subject to bug abuse.

Hardware (cold) wallets

Hardware wallets (for example Ledger, Treasury) is not connected to the internet. Users can sign transactions without having to reveal their seed/mnemonic on an unsecured device (only digital signatures are sent via USB/Bluetooth). They rely on highly secure microchips to ensure that no one can access the keys without the wallet PIN.

When using a hardware wallet it is important 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 (for example Ethereum, Solana, Avalanche) for all or at least critical parts of it backend. The DApp interface (usually a website) connects to smart contracts and generates transactions that the user signs with their wallet.

Smart contracts

A smart contract is one programs that are distributed to a blockchain consisting of:

  • A State (any data that the app needs to function);
  • An ensemble of deterministic functions which can be called by users through transactions.

Users must pay fees to call functions like change the state of the smart contractbut 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 calls from external devices.

For more on the pros and cons of DApps, see Advantages/disadvantages of DApp development.

DeFi (decentralized economy)

By using smart contracts it is possible to distribute fully decentralized censorship-resistant financial applications that:

  • Cannot be shut down directly by a single entity (eg, a government or corporation);
  • Can be used by anyone, regardless of social status, criminal record, etc.

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

  • Stablecoins are cryptocurrencies that attempt to tie their price to an external “real” asset. The most used are in association with fiat moneynamely the US dollar (eg USDT, USDC, DAI).
  • Decentralized Exchanges (DEX) allow users to trade cryptocurrencies without any intermediary. Unlike on a centralized exchange (CEX) where all liquidity is held by a single company, anyone can provide liquidity to a DEX. DEXs incentivize liquidity providers by paying them with their tokens (eg Uniswap rewards with UNI tokens, SpookySwap with BOO tokens).
  • Lending platforms (for example Aave, Anchor) allows users to borrow assets after depositing collateral. This is different from bank lending as the amount you can borrow is not based on your salary, age etc but on the amount you deposited as collateral.
  • Yield cultivation DApps strive to offer the best interest rates on crypto assets (e.g Convex, Long)
  • Launchpads (for example DAO Maker, Avalaunch) allows users to invest early in projects that have not yet been released. It is comparable to crowdfunding where users receive tokens as equivalents for their investment.
  • Play to earn (GameFi) (e.g Axie Infinity) is a type of video game where users are rewarded with tokens as they play. These tokens can then be sold for fiat money.

At the time of writing, more than a tenth of all crypto market capitalization (in US Dollars) are deposited on DeFi applications. A good website to track leading DApps via blockchain is Defi Lama.

Conclusion

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

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

To go further

#Blockchain #Cryptocurrencies #Wallets #DApps

Source link

Leave a Reply