Skip to main content
Hugo’s IT journal Hugo's IT journal

Blockchain Introduction

·
blockchain
Resources>

Resources #

Notes>

Notes #

what is blockchain>

what is blockchain #

blockchain

  • The blockchain solution in IoT / Supply chain are changing “Mesh” network to a “Star Network
  • each parties access and write to the “blockchain network”. not more api integration between parties
Mest Network

Star Network

How to use it>

How to use it #

How it work>

How it work #

  • use cryptography methods to ensure the integrity of a public writable database
  • proof of work, proof of stake, proff
How to implement>

How to implement #

  • solidity
  • node.js
  • truffle
  • web3.js
Any product (e.g crypto currency/ nft)>

Any product (e.g crypto currency/ nft) #

Networks>

Networks #

Public>
Public #
Private (have acl)>
Private (have acl) #
  • each parties setup servers to join the blockchain network

  • all parties hold the data but they can set access right to the data

  • Hyperledger Fabric

Decentralized Storage>

Decentralized Storage #

Staking>

Staking #

CrowdSale>

CrowdSale #

user -> sale contract -> nft contract

Lottery>

Lottery #

NFT>

NFT #

Swap / Farming>

Swap / Farming #

  • ask people input proportion of coin into the pool, like eth:bnb. so people can trade between eth and bnb

  • use Oracles for pricing…a smart contract which referencing different sources from other swap exchange & their coin pair pool size

  • pancakeswap(bsc)

  • uniswap(eth)

What is ECR20 721 1155>

What is ECR20 721 1155 #

ECR20 vs ECR721

  • ECR20 = coin
  • ECR721 = NFT
  • ECR1155 = 1 contract with multi token, eg: game item

ERC1155 Swap

ECR115 Batch

What is smart contract>

What is smart contract #

Demo>

Demo #

NFT Contract>

NFT Contract #

Common Functions

  • Mintable (increase supply)
  • Burnable (reduce supply)
  • Pausable (freeze the contract, for upgrade)
  • Access control: Roles (multi ac, multi actions) / Ownable (single ac, all actions)
  • Upgradeability (Transpart / UUPS) - proxy pattern
  • Timelock
  • Votes

NFT metadata #

{
  "boosterId": 10000000195586,
  "id": "10000586756",
  "txHash": "0xff318896b78fd77aadf19f94b7434d1a0ea5ffddfc88b6966d92d75c69f80dd1",
  "randomNumber": "0xc55ec3b26d0bdec23fd2f9e29ae34d54e0d457ef1d413b5c537b0383330575f0",
  "image": "https://assets.polkamon.com/images/Unimons_T08C02H06B04G00.jpg",
  "external_url": "https://polkamon.com/polkamon/T08C02H06B04G00",
  "description": "Mindful of a million things, the Unisheep are Polkamon creatures that can graze and gander the day away. Creating an environment to actively direct these creatures helps them focus on one particular topic.",
  "name": "Unisheep",
  "initialProbabilities": {
    "horn": 0.2,
    "color": 0.345,
    "background": 1,
    "glitter": 0.99,
    "type": 0.1847
  },
  "attributes": [
    {
      "trait_type": "Type",
      "value": "Unisheep"
    },
    {
      "trait_type": "Horn",
      "value": "Spiral Horn"
    },
    {
      "trait_type": "Color",
      "value": "Green"
    },
    {
      "trait_type": "Background",
      "value": "Mountain Range"
    },
    {
      "trait_type": "Opening Network",
      "value": "Binance Smart Chain"
    },
    {
      "trait_type": "Glitter",
      "value": "No"
    },
    {
      "trait_type": "Special",
      "value": "No"
    },
    {
      "display_type": "date",
      "trait_type": "Birthday",
      "value": 1628902374
    },
    {
      "display_type": "number",
      "trait_type": "Booster",
      "value": 10000000195586
    }
  ],
  "opening_network": "Binance Smart Chain",
  "background_color": "FFFFFF",
  "animation_url": "https://assets.polkamon.com/videos/Unimons_T08C02H06B04G00.mp4",
  ...
}

Read Contract #

Functions:

  • balanceOf (3)
  • getApproved (4)
  • Role: DEFAULT_ADMIN_ROLE / MINTER_ROLE (1,2)
  • getRoleMember (6)
  • ownerOf (11)

Write Contract #

Functions:

  • burn (2)
  • mint (4)
  • grantRole (3)
  • safeTranferFrom
  • setTokenURI
Wallet>

Wallet #

Connect from browser>

Connect from browser #

Contract deployment>

Contract deployment #

References>

References #