decrypt101
SocialOpen ProjectsSupport me My Resumes
  • Preface
    • Motivation
    • Roadmap’s
  • Introduction to Blockchain
    • A Brief History
    • Growth of Blockchain
    • Structure of Blockchain
    • Types of Blockchain
    • Key Technologies of Blockchain
    • Features of Blockchain
    • How Blockchain Works ?
    • Implementation of Blockchain
    • Summary
  • Components of Blockchain Architecture
    • Distributed Ledger
    • Blocks
    • Transaction
    • Chain
    • Peer-to-Peer Network
    • Blockchain Layers
    • Off-Chain & On-Chain
    • Wallet
    • Mining
    • Tokens
    • Assets
    • State Channels
    • Sidechains
    • Oracles on Blockchain
    • Atomic Swaps
    • Decentralized Identity (DID)
    • Blockchain Data Storage
    • Interoperability
    • Data structures for Scaling Blockchain
    • Maximal Extractable Value (MEV)
  • Consensus Mechanisms
    • Proof of Work (PoW)
      • Implemation Using Rust
    • Proof of Stake (PoS)
    • Proof of Burn (PoB)
    • Proof of Capacity (PoC)
    • Proof of Activity (PoAc)
    • Proof of Weight (PoWe)
    • Proof of Luck (PoL)
    • Proof of Ownership (PoO)
    • Proof of Existence (PoE)
    • Proof of Believability (PoBe)
    • Proof of History (PoH)
    • Proof of Authority (PoA)
    • Proof of Elapsed Time (PoET)
  • Cryptographics
    • Encryption & Decryption
      • Symmetric Encryption
      • Asymmetric Encryption
      • Key Management and Exchange
      • Implementation
    • Cryptographic Hashing
      • Secure Hash Algorithms (SHA)
      • Message Digest Algorithms
      • Ethash
      • Blake2
      • SCrypt
      • RIPEMD-160
    • Digital Signature
      • Digital Signature Algorithms
      • Digital Signature in Blockchain
    • Zero-Knowledge Proofs (ZKPs)
      • Types of Zero-Knowledge Proof and Protocols
      • A Case Study of Polygon Platform
    • Multi-Party Computation (MPC)
    • Cryptanalysis
    • Practical Implementation
  • Decentralized Application (DApp)
    • Design and UX in Web3
  • Smart Contract
    • Development Tools
    • Solidity
    • Testing Smart Contract
    • Developing Smart Contract
    • Interacting & Deploying with Smart Contract
    • Verifying Smart Contracts
    • Upgrading Smart Contracts
    • Securing Smart Contract
    • Smart Contract Composability
    • Testnet and Mainnet
    • Blockchain Platform Using Smart Contract
    • Application of Smart Contract
    • Practical Implementation
  • Blockchain Platforms
    • Ethereum
      • Ethereum Virtual Machine (EVM)
      • ETHER and GAS
      • Ethereum transaction
      • Ethereum Accounts
      • Ethereum Stacking
      • Ethereum Network
      • Ethereum Scaling Solutions
      • Ethereum Use-Cases
      • Getting Started with Ethereum
      • Ethereum Ecosystem and Support
    • Solana
      • Solana Architecture
        • Solana Account Model
        • Solana Wallet
        • Transactions and Instructions
        • Solana Programs
        • Program Derived Address (PDA)
        • Cross Program Invocation (CPI)
        • Tokens on Solana
        • Clusters and Public RPC Endpoints
        • Transaction Confirmation & Expiration
        • Retrying Transactions
        • Versioned Transactions
        • Address Lookup Tables
        • State Compression
        • Actions and Blinks
      • Solana Developments
      • Solana Client
      • Advanced Solana
      • Solana Scaling and Performance Architecture
      • Solana Solutions and cases
      • Practical Implemenation
    • Binance Smart Chain (BSC)
      • Create a BEP20 Token
    • Hyperledger Fabric
    • Cosmos
    • Polkadot
    • Quorum
    • Polygon
    • Algorand
    • Corda
    • Avalanche
    • TRON
    • Summary
  • Decentralized Finance (DeFi)
    • DeFi Components
    • DeFi Protocols
    • DeFi Platforms
    • DeFi Risk Classification
      • Infrastructure-layer Attacks
      • Smart Contract Layer-attacks
      • Application Layer-attacks
      • DeFi Risks
    • DeFi and Blockchain
    • DeFi Impact
  • Decentralized Ecosystem and Digital Innovation
    • Layer 2 Scaling Fundamental
    • Tokenomics
    • Cryptocurrency
    • Quantative Trading
    • NFTs
    • GameFi
    • Metaverse
  • Blockchain as a Service (BaaS)
    • Building Fullstack Blockchain Platform
    • Decentralized Digital Identity
    • Build a Cryptocurrencies Exchange
    • Play-to-Earn Gaming
    • Solana Token Airdrop Manager
    • Smart Contract Development on Solana with Rust
    • Quantitative Trading Platform
    • Insurances protocols
    • Flash Loans
    • Asset Management
    • Tokenized Derivatives
    • Automated Market Makers (AMMs)
    • Staking
    • Lending and Borrowing Platforms
    • Yield Farming
    • Stablecoin System
    • Security Token Offerings (STOs)
    • Initial Coin Offerings (ICOs)
    • On-Chain Voting Systems
    • Decentralized Autonomous Organizations (DAOs)
    • NFT Marketplaces
    • Provenance Verification
    • Supply Chain Tracking
    • Commodities Tokenization
    • Real Estate Tokenization
    • Digital Certificates
    • KYC (Know Your Customer)
  • Blockchain Development Across Languages
    • Blockchain using Go(Golang)
    • Blockchain using Rust
    • Blockchain using Python
    • Blockchain using Cairo
  • Distributed Systems & Infrastructure Technology
    • Classification of Distributed Systems
    • Networked systems versus Distributed systems
    • Parallel systems vs Distributed systems
    • Distributed versus Decentralized systems
    • Processes of Distributed Systems
    • Architecture of Distributed systems
    • Infrastructure Technologies
  • Distributed System Patterns
    • Distributed Agreements Algorithms
      • HoneyBadgerBFT
    • Data Replications
    • Data Partition
    • Consistency
    • Distributed Time
    • Cluster Management
    • Communication between Nodes
    • Fault Tolerance and Resilience
      • How to design better fault tolerance systems
      • Resilience Patterns
    • Coordination systems
      • Clock synchronization
    • Security
      • Trust in distributed systems
      • Design of Principal Security
      • Security threats, policies, and mechanisms
      • Authentication and Authorizations
      • Cryptography
      • Monitoring in Security
  • Distributed System Design
    • Page 1
    • Distributed Shared Memory
    • Distributed Data Management
    • Distributed Knowledge Management
    • Distributed Ledger
  • FAQs
  • Support and Community
Powered by GitBook
On this page
  • What Are Tokens?
  • ERC Token Standards
  • a. ERC-20: Fungible Tokens
  • b. ERC-721: Non-Fungible Tokens (NFTs)
  • c. ERC-1155: Multi-Token Standard
  • d. ERC-4626: Tokenized Vaults (Yield-bearing Tokens)
  1. Components of Blockchain Architecture

Tokens

What Are Tokens?

Tokens are digital assets that represent ownership or access to a particular service, asset, or value on a blockchain. Unlike cryptocurrencies like Bitcoin or Ether, which have their own blockchains, tokens are built on existing blockchains like Ethereum. Tokens can have various functions:

  • Currency: Used as a medium of exchange (e.g., stablecoins).

  • Governance: Represent voting power in decentralized organizations (e.g., governance tokens).

  • Access: Represent access to specific services or applications (e.g., utility tokens).

  • Assets: Represent ownership of real-world or digital assets (e.g., NFTs).

How Tokens Work on Ethereum

Tokens on Ethereum follow specific standards that define how they function, allowing for interoperability across platforms. These standards ensure that tokens behave predictably and consistently, especially when interacting with smart contracts, decentralized applications (dApps), and exchanges.

Types of Tokens: Fungible vs. Non-Fungible

  • Fungible Tokens: Interchangeable and have the same value (e.g., 1 ETH = 1 ETH). Examples include ERC-20 tokens.

  • Non-Fungible Tokens (NFTs): Unique and not interchangeable. Each token has distinct properties and value (e.g., ERC-721 tokens).

ERC Token Standards

a. ERC-20: Fungible Tokens

Overview

ERC-20 is the most commonly used token standard for creating fungible tokens on Ethereum. These tokens are interchangeable, and each unit has the same value and properties.

Key Functions in ERC-20

  • totalSupply(): Returns the total supply of tokens.

  • balanceOf(address): Returns the balance of a particular address.

  • transfer(to, value): Transfers a certain amount of tokens to another address.

  • approve(spender, value): Approves another address to spend a certain amount of tokens on behalf of the owner.

  • transferFrom(from, to, value): Transfers tokens on behalf of an address (using the approved amount).

Example Use Case

Stablecoins like USDC and DAI are built using the ERC-20 standard, allowing users to send and receive them just like they would with Ether.

Code Example:

// A simple ERC-20 token
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract MyToken is ERC20 {
    constructor(uint256 initialSupply) ERC20("MyToken", "MTK") {
        _mint(msg.sender, initialSupply);
    }
}

b. ERC-721: Non-Fungible Tokens (NFTs)

Overview

ERC-721 is a standard for creating non-fungible tokens (NFTs). Each ERC-721 token is unique and cannot be replaced with another, making it ideal for assets like digital art, collectibles, and property.

Key Functions in ERC-721

  • ownerOf(tokenId): Returns the owner of a specific NFT.

  • transferFrom(from, to, tokenId): Transfers ownership of an NFT.

  • approve(to, tokenId): Allows another address to transfer a specific token.

Example Use Case

Projects like CryptoKitties and Bored Ape Yacht Club use ERC-721 tokens to represent unique digital assets (e.g., individual kitties or apes).

Code Example:

// A simple ERC-721 NFT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";

contract MyNFT is ERC721 {
    constructor() ERC721("MyNFT", "NFT") {}

    function mintNFT(address recipient, uint256 tokenId) public {
        _mint(recipient, tokenId);
    }
}

c. ERC-1155: Multi-Token Standard

Overview

ERC-1155 is a versatile token standard that allows for the creation of both fungible and non-fungible tokens within the same contract. This makes it ideal for gaming and applications where both types of assets are needed (e.g., in-game currency and unique items).

Key Functions in ERC-1155

  • balanceOf(address, tokenId): Returns the balance of a specific token for an address.

  • safeTransferFrom(from, to, tokenId, amount, data): Transfers tokens safely.

  • setApprovalForAll(operator, approved): Allows or revokes an operator to transfer all tokens on behalf of the owner.

Example Use Case

Games like Gods Unchained use ERC-1155 tokens to represent both in-game currency (fungible) and special items or cards (non-fungible).

Code Example:

// A simple ERC-1155 token contract
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";

contract MyMultiToken is ERC1155 {
    constructor() ERC1155("https://api.example.com/{id}.json") {}

    function mint(address account, uint256 id, uint256 amount, bytes memory data) public {
        _mint(account, id, amount, data);
    }
}

d. ERC-4626: Tokenized Vaults (Yield-bearing Tokens)

Overview

ERC-4626 is a new standard designed for tokenized vaults, specifically for DeFi protocols that issue interest-bearing tokens. This standard allows users to deposit tokens into a vault, which is then used in various yield-generating strategies (e.g., lending, staking). In return, users receive an ERC-4626 token that represents their share in the vault.

Key Functions in ERC-4626

  • deposit(amount, to): Deposits tokens into the vault and issues yield-bearing tokens in return.

  • withdraw(amount, to): Withdraws tokens from the vault by redeeming yield-bearing tokens.

  • totalAssets(): Returns the total assets held in the vault.

Example Use Case

Yearn Finance and Aave could use ERC-4626 to manage yield-bearing tokens that represent deposits in yield-generating protocols.

Code Example:

// A simplified ERC-4626 vault
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol";

contract MyVault is ERC4626 {
    constructor(ERC20 _asset) ERC4626(_asset) {}
    
    // Other vault-specific logic can be added here
}

Conclusion

Understanding the different ERC token standards is crucial to navigating the Ethereum ecosystem. Each token standard serves specific use cases, from basic fungible tokens (ERC-20) to complex multi-token standards (ERC-1155) and yield-bearing vaults (ERC-4626). By using real-world examples and code snippets, developers can better grasp the functionality and applications of these tokens.

PreviousMiningNextAssets

Last updated 8 months ago