Think Solidity with Sense of Security
Never show secret on chainRemember always show the hashed secret on chain! This code is secure because commit is stored in hash instead of plaintext. 123456789101112bytes32 public commit;function commitHash(bytes32 h) external { commit = h;}function reveal(string calldata secret) external { require( keccak256(abi.encodePacked(secret)) == commit, "wrong secret" );} Let’s take a look at the insecure code ⚠️. Attackers can monitor the mempo...
Key Concepts in JavaScript
this1.”this” is the object that calls the method. 1234567let cat = { name: "Tom", sayName() { console.log("My name is " + this.name); }}cat.sayName(); The output:My name is Tom 2.Global functions are essentially methods of the window. 1234function func(){ console.log(this);}func(); The output:[object Window] 3.dom element 1234567891011121314151617<!DOCTYPE html><html lang="en"><head> <meta...
My Understanding of Web3
IntroIn this passage, I’m gonna write down all my understanding based on the online book shop web3 project I’ve done. Here is the github repo: https://github.com/leonleerl/bookchain. I deployed it on Vercel, using Sepolia testnet:https://bookchain-ashen.vercel.app/. What is Web3.0?What is Blockchain? It is a decentralised ledger that stores transaction data publicly. What is Ethereum? It is a blockchain that supports smart contracts. What is Smart Contract? It is the code deployed on Ethere...
What is Web3?
What is Blockchain?It is a decentralised ledger that stores transaction data publicly. What is Ethereum?It is a blockchain that supports smart contracts. What is Smart Contract?It is the code deployed on Ethereum that runs autonomously and cannot be changed. What is Wallet?It is a way to store and control private keys (e.g. MetaMask) What is Transaction?It is a signed action recorded permanently on the blockchain. What is Testnet (e.g. Sepolia)?It is a testing version of Ethereum where crypto...
Natural Language Processing
Lecture 1 IntroductionOverview of NLPWhat we will learn in this course ⬇️ NLP and Machine Learning (lecture 1 - lecture 4) NLP Techniques (lecture 5 - lecture 8) Advanced topic (lecture 9 - lecture 12) Let’s have a look at the chart first ⬇️ Based on the chart above, the differences between Classical NLP and Deep Learning-based NLP are: Classical Deep Learning Procedure Complex Procedure Simpler Lots of Pre-processing Easy Pre-processing Each natural language needs an individual...
Merkle Tree
To create the Merkle Tree in Blockchain field 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091const { keccak256 } = require("js-sha3");<!-- more -->class MerkleTree { constructor(data) { this.leaves = data.map((item) => keccak256(item)); this.tree = this.buildTree(this.leaves); this.root = this.tree[this.tree.length - 1][...
