Mapping && structure
storage keywords
storage keywords is used to spcify that variables should parmnately stored in blockchain. It represents persistent storage area of the contract where data is stored across multiple function calls and Even persistent storage after contract execution is completed.
Collectible storage collectible = idToCollectible[_id];
storage kerwords represent the collectible variables will refrence the idTocollectible[_id], means any change of the coolectible will directly affect the value stored in the mapping.
Structure
Structure keywords is used to describe the structure of the data. it’s similar to typescripe’s interface. and we can use this to declare the variables have the same structure. It will provide convience for dev to know the variables’s structure also EVM to do static checks.
struct User {
uint balance;
bool isActive;
}
Signer, Provider and Wallet.
Signer
A Signer in ethers is an abstraction of an Ethereum Account, which can be used to sign messages and transactions and send signed transactions to the Ethereum Network to execute state changing operations.
The most common Signers you will encounter are:
const signer = ethers.provider.getSigner(0);
await signer.sendTransaction({
to: await wallet.getAddress(),
value: ethers.utils.parseEther('2'),
});
- Wallet, which is a class which knows its private key and can execute any operations with it
- JsonRpcSigner, which is connected to a JsonRpcProvider (or sub-class) and is acquired using getSigner
Provider
A Provider is an abstraction of a connection to the Ethereum network, providing a concise, consistent interface to standard Ethereum node functionality.
const provider = new ethers.providers.JsonRpcProvider(process.env.TEST_API_URL as string);
Wallet
The Wallet class inherits Signer and can sign transactions and messages using a private key as a standard Externally Owned Account (EOA).
const wallet = new ethers.Wallet(process.env.TEST_PRIVATE_KEY as string, provider);
Event
Event are the way solidty and EVM provide dev with logging functionality used to write data to a data structure on the blockchain that lives out of smart contract’s storage variables.
Event are an abstraction on top of the EVM’s low-level log functionality, opcode is LOG0-LOG4. The spcific code used will depend on the number of topics that event using indexed keyword.
- Topics in Ethereum record
The first part of logs record consists of an array of topics. The first topic usually consists of the Signature(kaccak256 hash) of the name of the events that occurred, including the types (uint256, string, etc.) of its parameters. - Data in Ethereum record
The second part of logs record consists additional data. Best to combine data and topics together. while topic is searchable, but data is not.


Now, we just need to understand how data (like our final argument) can be included. LOG3 requires 5 arguments:
LOG3(memoryStart, memoryLength, topic1, topic2, topic3)
Event data is read from memory in the following fashion:
memory[memoryStart…(memoryStart + memoryLength)]
Luckily, higher-level smart contract programming languages like Solidity, Vyper, or Bamboo will handle writing event data to memory for us, which means you can usually pass data directly as a parameter when emitting logs.

read more details here: Event
Escrows
Escrows is a subjuct service in financial, but in blockchain, It will be smart contract forms, because smart contract is immutable when it deploys. Both sellers and buyers can be trusted the smart contract and it’s transparented.

When buyer pay for the deposit to Escrow, the Escrow will save the deposit, and it will check the condition is satisfied or not. if not the deposit will retrun to buyer. when the condition is satisfied, the deposit will release to the seller, and the goods or services will be send to buyer.
Read more info
Data location (reference type)
There are three different locations for data in solidity. Calldata, Memory and Storage.Calldata is external data, Memory is ephemeral data, Storage is persistent data.
Calldata
When we broadcast a transaction from EOA, We contain bytecode for EVM running. The bytecode is Calldata and it include identifier for the function we’re targeting and the parameters we’re sent.
When we use Array to be paremeters in external function, It must be identified by the calldata. it’s only-read reference for parameters and similar to Memory unless only-read.Memory
Memory is temporary data location provided for use to keep our local veriables. These variables will only exist in memory for the length of the transaction.
When we’re working with arrays that should only exist for the length of the transaction, we labeled them withMemorykeywords. We can read/write the data location that cheaply than compare with storage.Storage
Storage actully is location that store in blockchain. This is where the state variables are stored.
All of the Ethereum full node will store them in the local machine, since that Storage operations are expensive.
Value vs Reference
Assigning an array will copy it in some cases and store a reference in other cases.
Let’s consider this example:
import "hardhat/console.sol";
contract Contract {
uint[3] numbers = [1,2,3];
function modify() external {
uint[3] memory memoryArray = numbers;
// will modifying memoryArray modify numbers?
memoryArray[0] = 4;
// nope!
console.log(numbers[0]); // 1
}
}
☝️ This will not modify the numbers. The values from numbers are copied into memoryArray at this assignment and they are otherwise unrelated.
📖 In fact, the compiler will warn that this can be labeled as a view. Didn’t want to give any spoilers. 😉
import "hardhat/console.sol";
contract Contract {
uint[3] numbers = [1,2,3];
function modify() external {
uint[3] storage storageArray = numbers;
// will modifying storageArray modify numbers?
storageArray[0] = 4;
// yup!
console.log(numbers[0]); // 4
}
}
☝️ This will modify the numbers. In this case, storageArray contains a reference to numbers due to its storage location.
💡 Equal references point to the same spot in memory. Making a modification updates the memory directly, all the references still point to the same place.
aka
ethereum: 以太坊
Blockchain: 区块链
Crypto: 加密
crytocurrencts: 加密货币
decentralized: 去中心化
bitcoin: 比特币,第一个基于区块链技术实现的加密货币
fiancial incentives: 金融奖励
mining the rewards: 挖矿
deterministic: 确定性
pseudorandom: 伪随机
collsion resistant: 抗碰撞
consensus: 共识,一个网络对数据的状态达成共识。
censorship:审查
bribe: 贿赂
drill home: 钻研
relatively travel:相对较小的
infeasible: 不可能
symmetric: 对称
digital signature: 数字签名
RSA: 非对称加密的经典实现
ECDSA: bitcoin采用的非对称加密算法
ether: 以太币
address: 交易发起方类似于ip, bitcoin 使用checksum and base58, ethereum is last 20 bytes of the hash of the public key.
Enforcement: 执行
consensus rules: 共识规则
consensus mechanisms:协商一致
inter-changeable: 可互换的
cumulative: 积累型
nakamoto consensus: 最长的chain将是其他节点接受的一个真正的链,他是由一条链积累的工作所决定的。
txs: transactions.
pos: proof of stack, pos中,参与者需要持有一定数量的crytocurrency,参与记账过程,相比pow,pos不需要大量的算力
pow: proof of work,miners通过计算来添加txs和block,需要消耗算力。可以增加security of blockchain
merkle root:默克尔根,用来验证和确认交易是否被篡改。
underlying: 底层
hashcash: Hashcash工作量证明功能由Adam Back于 1997 年发明,并建议用于反 DoS 用途
Byzantine General’s Problem: 在p2p场景下,如何证明每个机器都是在工作的。
manipulate: 操作
Genesis Block: 第一个加入到区块链中的块,初始块
cost-effective: 成本效益
UTXO:Unspent Transaction Output, 未使用的交易
Retrospective: 回顾
vulnerable: 脆弱的
light nodes: 轻节点 (存储块头的轻节点)
full nodes:完整节点(常规节点)
achieve nodes: 归档节点, 完整节点(已验证的存档节点)
bandwidth: 带宽
configure: 配置
variables: 变量
discrepancies: 差异
tradeoffs: 权衡利弊
contrast: 对比
unfakeable: 不可伪造
replicate: 复制
Satoshi: “Satoshi” refers to the smallest unit of the cryptocurrency Bitcoin
individual: 个人
multitude: 众多的
aggregate: 总数
expedite: 加快
hefty prize : 巨额奖金
controlled supply: 受控供应
intentional: 故意的
quirk: 怪癖
denial: 否认
distinguish: 辨别
preceding: 前面
emerge: 出现
hierarchically: 层次分明
intimidating: 令人生畏的
underneath: 底下
infacting:连接
concatenate: 串联
optimization: 优化
inconsistencies: 不一致
deveration: 推导
arbitrary: 随意的
immutable: 不可变
implications: 含义
ledger: 账本
traversal: 遍历
PMTs: Partricia Merkle tries
sealed: 密封.
Permenant: 永恒的
Ephemeral: 短暂的
Constantly: 不断的
prefixes: 前缀
recursion: 递归
portion: 部分
adjacent: 邻近的
neat mechanisms: 整洁的机制
consists: 包含
crowdfunding: 众筹
parse: 解析
intimidated: 吓坏
deterministic: 确定性
infrastructure: 基础设施
constrain: 限制
reside: 贮存
presence: 存在
cencership: 审查制度
auditable:可审查
Ubiquitous: 无处不在
barries: 障碍
curb: 抑制,阻止
comprehend: 理解
easy as pie: 易如反掌
explicitly:明确的
clause: 条款
neutrality;中立
arbitrary: 随意的
EVM: Etherrum Virtual Machine
Stale/Orphan block: 陈旧/孤立块,是指在一个区块同时被矿工挖掘出,区块可能会出现临时分叉,未能被选为有效区块的区块被称为stale/Orphan block,在Etherum中此类区块又称为Ommer block,是Etherrum作为鼓励和奖励矿工为安全做出贡献的机制。
emulate: 模仿
underlying: 潜在的
monetary: 货币
fixed: 固定的
Arithmetic: 算术
benchmarking: 基准测试
discrepancies: 差异
philosophy: 理念
Ethereum improvement proposal: EIP, Ethereum 改进提案
first and foremost: 首先
specification: 规范
adhere: 符合
impromptu: 即兴
compatible: 兼容的
contentious: 有争议的
overHead:高昂的
collateral: 抵押物
intuitively: 直观的
re-orged: 重组
manual:手动的
intervention: 干涉
canonical: 经典的
shifted: 转移
denomination: 面值
demand: 需求
circumventing: 规避
deflationary: 通缩
deprecated: 弃用
redunant: 多余的
tampered: 被篡改
EOAs: Extended owned account.
Vulnerability: 漏洞
JSON-RPC: remote procedure call(rpc) protocal that uses JSON to encode message.
exclusively: 只,仅仅 equied to only
instruction: 指令
term: 术语
boilerplate: 样板
pioneer: 先锋
lucrative: 有利可图
mnemonic: 助记词
configured: 配置
specified: 指定的
analogues: 相似的
discarded: 丢弃
underscore preceding: 前下划线
snippet: 片段
dire consquences: 可怕的后果
unsigned integer: 无符号整数
allocated: 分配的
resilient: 弹性的
LIFO: 堆栈结构,it’s have pushing and poping
destructure: 解构
parenthesis: 括号
exception: 异常
declared: 声明
ephermal: 短暂的
ABI: application binary interface, that’s bridge connected compilers and applications.
writing up a to b: 连接a到b
pass into: 传递……进
repercurssion: 反应
padded out: 填充到
replay to: 转发到
associative array: 关联数组
brute force search: 暴力搜索
hit the nail on the head : 一针见血
Nested: 嵌套
maintaining: 维护
Escrows: 托管
treadoff: 权衡
peroid of inactivity: 不活跃期
compromised: 损坏/妥协