Substrate 區塊鏈應用開發之存證模組的功能開發

寻月隐君發表於2024-04-05

Substrate 區塊鏈應用開發之存證模組的功能開發

存證是一種線上服務,可用於在某一時間點驗證計算機檔案的存在性,最早是透過比特幣網路帶有時間戳的交易實現的。
存證的應用場景有:

  • 數字版權
  • 司法存證
  • 供應鏈溯源
  • 電子發票
  • ...

存證的作用是:

  • 證明檔案在某一時間點確實存在
  • 證明檔案在某一時間點確實沒有被篡改
  • 證明檔案在某一時間點確實由某個人建立

實操

  1. Open a terminal shell on your computer.

  2. Clone the node template repository by running the following command:

git clone https://github.com/substrate-developer-hub/substrate-node-template
  1. Change to the root of the node template directory by running the following command:
    cd substrate-node-template
  1. Create a new branch to contain your work:
    git switch -c my-learning-branch-2024-04-05
  1. Compile the node template by running the following command:
    cargo build --release
  1. In the same terminal where you compiled your node, you can now start the node in development mode by running the following command:
    ./target/release/node-template --dev --tmp

  1. polkadot.js.org/apps 檢視

  2. 交易前查詢狀態 None

  3. 交易

  4. 提交交易

  5. 交易後查詢狀態

問題

  1. 編譯報錯後使用的命令
    cargo clean
    cargo update
    cargo update -p wasm-bindgen
    cargo update -p librocksdb-sys
    cargo update -p schnorrkel@0.11.4
    cargo update -p anstream@0.6.13  -Z sparse-registry    
  1. 編譯報錯:error[E0220]: associated type BlockNumber not found for T

解決: 替換T::BlockNumberBlockNumberFor<T>

  • https://substrate.stackexchange.com/questions/9848/associated-type-blocknumber-not-found-for-t

參考

  • https://docs.substrate.io/tutorials/build-a-blockchain/build-local-blockchain/
  • https://substrate.stackexchange.com/questions/9848/associated-type-blocknumber-not-found-for-t
  • https://polkadot.js.org/apps

更多詳情

  • https://github.com/qiaopengjun5162/substrate-pallets-poe

相關文章