PainterPuppets / learn-ckb

learn nervos chain
MIT License
2 stars 0 forks source link

ckb training course homework #1

Open PainterPuppets opened 2 years ago

PainterPuppets commented 2 years ago

ckb

ckb简介 slide

CKB> tx add-input --tx-hash 0xf8f103344cbb3d2f23cbe61a516583b0dca169ec53134ae26851f6fd69f2d10b --index 0 --tx-file tx.json status: success

CKB> tx add-output --capacity 100 --tx-file tx.json --to-sighash-address ckt1qyqvg2cpzfp4nn4v63zqe3rpdpw0m4je5pgspkn8ak status: success

CKB> tx info --tx-file tx.json [input] ckt1qyqvsv5240xeh85wvnau2eky8pwrhh4jr8ts8vyj37 => 89992.99757236, (data-length: 0, type-script: none, lock-kind: sighash(secp)) [output] ckt1qyqvg2cpzfp4nn4v63zqe3rpdpw0m4je5pgspkn8ak => 100.0, (data-length: 0, type-script: none, lock-kind: sighash(secp)) input_total: 89992.99757236 (CKB) output_total: 100.0 (CKB) tx_fee: 89892.99757236 (CKB)

CKB> tx add-output --capacity 89892 --to-sighash-address ckt1qyqvsv5240xeh85wvnau2eky8pwrhh4jr8ts8vyj37 --tx-file tx.json status: success

CKB> tx info --tx-file tx.json [input] ckt1qyqvsv5240xeh85wvnau2eky8pwrhh4jr8ts8vyj37 => 89992.99757236, (data-length: 0, type-script: none, lock-kind: sighash(secp)) [output] ckt1qyqvg2cpzfp4nn4v63zqe3rpdpw0m4je5pgspkn8ak => 100.0, (data-length: 0, type-script: none, lock-kind: sighash(secp)) [output] ckt1qyqvsv5240xeh85wvnau2eky8pwrhh4jr8ts8vyj37 => 89892.0, (data-length: 0, type-script: none, lock-kind: sighash(secp)) input_total: 89992.99757236 (CKB) output_total: 89992.0 (CKB) tx_fee: 0.99757236 (CKB)

CKB> tx sign-inputs --from-account ckt1qyqvsv5240xeh85wvnau2eky8pwrhh4jr8ts8vyj37 --add-signatures --tx-file tx.json Password:

CKB> tx send --tx-file tx.json 0xd821cca5d4bb6e6049f5b18be643e9ab20afe6b00dce698610f11b67ecdfae85


- [ ] 在 testnet 部署 always success 合约,并使用 type id 作为 type script
- [ ] 创建一个 lock 和 type 都使用 type script hash 引用 always success 的 cell
- [ ] 升级一次 always success,可以不修改 data
- [ ] 使用升级后的 always success 组装交易解锁第三步中的 cell

### ckb两步提交

- [x] 自己在 Explorer 找一个块手算 Cellbase 奖励和手续费

block: [6478265](https://pudge.explorer.nervos.org/block/6478265)
奖励对象:6478265 - 11 = [miner](https://pudge.explorer.nervos.org/address/ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsq03ewkvsva4cchhntydu648l7lyvn9w2cctnpask) of [6478254 block](https://pudge.explorer.nervos.org/block/6478254) 

Epoch: 4,947
Block Index: 372/1800

一级增发:
Eopch 总额: 1,917,808.21917808

1,917,808.21917808 / 1800 = 1065.44901065

二级增发:

613698.63013698 / 1800 = 340.94368340943333

<img width="701" alt="image" src="https://user-images.githubusercontent.com/22258327/195663759-6862d9a3-88e8-4e9f-8f5f-8fe69abc8505.png">

<img width="773" alt="image" src="https://user-images.githubusercontent.com/22258327/195663714-c489bf85-4dd1-4aca-aa19-e36bd9e27ab9.png">

340.94368340943333 * (594424732800000000 / 4612388749964379586) = 43.939348761976184


Commit 手续费:

(0.00100000 + 0.00001000 + 0.00001000 + 0.00001000 + 0.00039422 + 0.00003140 + 0. 00002140) * 0.6 = 0.000886212

Proposal 手续费:

CKB> rpc get_block --hash 0xe14fca3122ae8a6874f1f07d66891196386dbaa2f7f863894518d5456d7df5f1 proposals:

手续费

总手续费 = 1,065.44901066 + 43.93934975 + 0.00088622 + 0.00032152 = 1,109.38956815

Q: Why there is no output of cellbase in blocks 1 to 11 on ckb?

A: 因为cellbase规定区块n的 Cellbase Output 是发放给 N - 11 的区块生产者,在1-11这些区块中没有n - 11的区块生产者,所以不会有cellbase output

ckb难度提交

Q: What is the difference between the meaning of uncle in Ethereum and uncle in CKB?

ckb中挖出叔块没有奖励,但是打包叔块的矿工可以获得奖励。

以太坊中挖出叔块有奖励

PainterPuppets commented 2 years ago

ckb-cli

the utilities from ckb-cli

Use CKB Rust SDK to build your transaction

PainterPuppets commented 2 years ago

lumos&ckit

Transfer CKB via Omnilock and MetaMask

https://github.com/PainterPuppets/learn-ckb/blob/main/src/homework/sudtTx.ts

https://github.com/PainterPuppets/learn-ckb/blob/main/src/homework/exchangeSudtTx.ts

PainterPuppets commented 2 years ago

ckb-vm

Omnilock Script

Taproot Script slide video

PainterPuppets commented 2 years ago

Axon

Axon 架构和设计模式

Overload Consensus

CKB编程入门

Axon 跨链系统介绍