- 相關(guān)資料鏈接
- 官方部署文檔 https://developer.aleo.org/testnet/getting_started/deploy_execute_demo/
- 查看鏈上所有的程序 https://explorer.hamp.app/programs
- 測(cè)試網(wǎng)領(lǐng)水 https://twitter.com/AleoFaucet
- Aleo SDK在線工具 https://aleo.tools/
- snarkOS源碼 https://github.com/AleoHQ/snarkOS
- leo源碼 https://github.com/AleoHQ/leo
- Aleo CSDN http://t.csdn.cn/BUUAx
安裝相關(guān)軟件
- 安裝cargo、snarkos、leo
# 1. 下載安裝Rust工具鏈管理器(內(nèi)涵Rust編譯工具)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env
# 查看是否安裝成功,未輸出找不到此命令則表示安裝成功
cargo --version
# 2. 下載安裝aleo隱私應(yīng)用部署工具
git clone https://github.com/AleoHQ/snarkOS.git --depth 1
cd snarkOS
cargo install --path . --locked
# 查看是否安裝成功,未輸出找不到此命令則表示安裝成功
# 3. 下載安裝aleo隱私應(yīng)用編譯工具
git clone https://github.com/AleoHQ/leo --depth 1
cd leo
cargo install --path . --locked
# 查看是否安裝成功,未輸出找不到此命令則表示安裝成功
leo
賬戶數(shù)據(jù)準(zhǔn)備
-
生成Aleo項(xiàng)目賬戶
- 通過(guò) https://aleo.tools/ 網(wǎng)站 Account 欄目的 Generate按鈕生成Aleo項(xiàng)目賬戶,然后將 Private Key、View Key、Address 記錄下來(lái),在這里我們把這三個(gè)值分別命名為 private_key , view_key , wallet_dddress . 如下圖所示。
-
領(lǐng)水,在自己的推特賬戶上發(fā)表如下信息(填寫自己的Aleo賬戶地址),從而獲得測(cè)試網(wǎng)Gas,用于之后的測(cè)試網(wǎng)鏈上部署隱私應(yīng)用的Gas。 如下圖所示。
@AleoFaucet Please send 10 credits to address Aleo賬戶地址
-
驗(yàn)證是否領(lǐng)水成功
- 等待5分鐘后查看自己是否領(lǐng)水成功,領(lǐng)水成功的話,如下圖紅框內(nèi)所示會(huì)得到 @AleoFaucet 的一個(gè)引用,然后點(diǎn)擊紅框內(nèi)的內(nèi)容。如下圖所示。
-
點(diǎn)擊上圖紅框內(nèi)內(nèi)容后,就會(huì)跳轉(zhuǎn)到下圖,然后點(diǎn)擊下圖紅框內(nèi)的內(nèi)容。如下圖所示。
-
點(diǎn)擊上圖紅框內(nèi)鏈接后,會(huì)返回一個(gè)Json字符串,如下圖所示。將第三個(gè)value的內(nèi)容復(fù)制下來(lái),在這里我們稱呼這個(gè)內(nèi)容為 record_ciphertext ,是我們加密后的鏈上數(shù)據(jù)的記錄?;蛘甙聪旅娴姆绞綄son字符串進(jìn)行格式化后再進(jìn)行復(fù)制。如下圖所示。
-
復(fù)制上圖的 Json字符串通到 https://json.cn 網(wǎng)站進(jìn)行格式化,或者安裝谷歌插件 https://chrome.google.com/webstore/detail/json-beautifier-editor/lpopeocbeepakdnipejhlpcmifheolpl 后再打開紅框內(nèi)的鏈接即可得到如下圖所示格式化后的數(shù)據(jù)。 將下圖黃色背景的內(nèi)容復(fù)制下來(lái),在這里我們稱呼這個(gè)內(nèi)容為 record_ciphertext ,是我們加密后的鏈上數(shù)據(jù)的記錄。如下圖所示。
-
游覽器上打開 https://aleo.tools/ ,選擇 Record 欄目,然后將 record_ciphertext 數(shù)據(jù)復(fù)制粘貼到 Record (Ciphertext) 方框內(nèi),然后在View Key方框里輸入自己的 view_key 的值, 網(wǎng)站就會(huì)自動(dòng)解密得到 Record (Plaintext) 方框內(nèi)的內(nèi)容。在這里我們將Record (Plaintext) 方框內(nèi)的內(nèi)容稱為 record_plaintext ,是我們解密后的鏈上數(shù)據(jù)的記錄。如下圖所示。文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-824431.html
-
記錄好 private_key , wallet_dddress , record_plaintext 三個(gè)值,在接來(lái)下部署隱私應(yīng)用的時(shí)候需要用到。文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-824431.html
部署隱私應(yīng)用
wallet_dddress="" # 填入自己的Aleo賬戶地址
private_key="" # 填入自己的Aleo賬戶的私鑰
app_name="helloworld_${wallet_dddress:0-6:6}" # 設(shè)置隱私應(yīng)用名稱,需要在Aleo網(wǎng)絡(luò)里全網(wǎng)唯一,不能重名。因此我們截取Aleo賬戶地址的部分字符串加入隱私應(yīng)用名稱內(nèi),以防止重名。
leo new "${app_name}" # 創(chuàng)建一個(gè)隱私應(yīng)用
cd "${app_name}" && leo run && cd - # 進(jìn)入隱私應(yīng)用目錄,進(jìn)行編譯,返回上層目錄
# 定義 Record 的明文
record_plaintext="{
owner: aleo1xvlh6eyfxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.private,
gates: 10000000u64.private,
_nonce: 41689884563743409008191298xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxgroup.public
}"
# 執(zhí)行部署操作
snarkos developer deploy "${app_name}.aleo" --private-key "${private_key}" --query "https://vm.aleo.org/api" --path "./${app_name}/build/" --broadcast "https://vm.aleo.org/api/testnet3/transaction/broadcast" --fee 600000 --record "${record_plaintext}"
# 如下所示的日志,表示部署成功。
# 將交易ID記錄下來(lái)(重要,查詢交易記錄以及進(jìn)行進(jìn)行下一次交易時(shí)都可能需要用到),例如 at1j97a8qmy6k2udaw9h9w34nu7wwahpkljnvvfpjvklht5uzwgsv8ss30g43 。
?? Creating deployment transaction for 'helloworld_gk5x0t.aleo'...
? Successfully deployed 'helloworld_gk5x0t.aleo' to https://vm.aleo.org/api/testnet3/transaction/broadcast.
at1j97a8qmy6k2udaw9h9w34nu7wwahpkljnvvfpjvklht5uzwgsv8ss30g43
- 通過(guò)網(wǎng)站 https://explorer.hamp.app/programs 查看被部署進(jìn)網(wǎng)絡(luò)里的隱私應(yīng)用。
- 輸入 交易ID 進(jìn)行查詢,例如我這里部署成功后的交易ID為 at1j97a8qmy6k2udaw9h9w34nu7wwahpkljnvvfpjvklht5uzwgsv8ss30g43 。查詢結(jié)果如下圖所示。
到了這里,關(guān)于Aleo隱私智能合約編程__第四章__部署進(jìn)鏈上Aleo Testnet3網(wǎng)絡(luò)的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!