02 May 2022
使用@ethersproject旗下的系列套件時做一個具有註記的錢包
程式碼如下:
const ethWallet = require('@ethersproject/wallet')
const ethTx = require('@ethersproject/transactions')
import { computePublicKey } from '@ethersproject/signing-key'
const wallet = ethWallet.Wallet.createRandom() //隨機建立一個含有私鑰、註記詞的錢包
console.log(wallet.mnemonic.phrase) // 印出註記詞
console.log(wallet.publicKey) //印出公鑰
console.log(wallet.privateKey) //印出私鑰
console.log(wallet.address) //印出錢包地址
console.log(wallet.publicKey.substring(2)) //印出publicKeyHex
console.log(wallet.privateKey.substring(2)) //印出privateKeyHex
console.log(ethTx.computeAddress(wallet.publicKey)) //same to wallet.address
如果將privateKeyHex的值匯入metamask,會發現成功匯入,這個錢包的地址就是wallet.address!
29 Apr 2022
以Akutar Mint Pass這個合約為例
將網址中的 “.io” 改為 “.deth.net”,會跳轉到vscode ui的頁面,方便讀code、進行查詢
改成如下的網址:
Vscode ui 介面:
有興趣可以去DethCode的github看更多詳細的細節與開源碼。
資料來源
27 Apr 2022
撰寫test檔時,發現以下eslint報的錯
解決辦法:
.eslintrc
檔案中加上:
資料來源
16 Apr 2022
購買網域並使用Cloudflare配置DNS後,想在github page勾選Enforce https讓網頁可以進行安全連線,卻發現如下問題:
原因:
Cloudflare會預設啟用代理功能(顯示Proxied的橘色雲朵狀態),因此github沒辦法查看生成證書需要的DNS資訊。
解決方法:
將和github page有關的DNS設定改為灰色雲朵DNS only,回到github page頁面,重新設定一次custom domain。
資料來源
06 Apr 2022
test 智能合約時,透過ethers.getSigners()建立Signer並使用
跑 npx hardhat test 發現問題:Error: invalid address or ENS name (argument=”name”, value=”<SignerWithAddress 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266>”, code=INVALID_ARGUMENT, version=contracts/5.6.0)
把alice使用console.log印出來看看
把 {from: alice}
改成 {from: alice.address}
Problem solved!