Alpha Interface

Alpha Interface 团队为 Agri-D Food Hack 创建的 Hackathon 项目

安装 WebApp

在您的系统上安装 Flutter(这将同时为您安装 Dart)。

https://flutterdart.cn/docs/get-started/install

通过终端导航到 IDE 中的 App 文件夹

cd .\src\frontend\alpha_interface_app\ 

获取包

flutter pub get

在 Chrome 中运行应用

flutter run -d chrome

安装

下载 Wasp 和 wasp-cli

https://wiki.iota.org/wasp/guide/chains_and_nodes/running-a-node

brew install rocksdb
make install

运行一个 Wasp 节点

运行一个 Wasp 节点,通过 TXStream 连接到 Goshimmer。

您可以在此处找到测试网端点 https://wiki.iota.org/wasp/guide/chains_and_nodes/testnet

目前我们使用 goshimmer.sc.iota.org:5000

wasp -c ./wasp-nodes/config.json

# or

make run-wasp

配置 wasp-cli

wasp-cli init

# Set go shimmer api and request fund
wasp-cli set goshimmer.api https://api.goshimmer.sc.iota.org
wasp-cli request-funds
wasp-cli balance

# set wasp address for a local node
wasp-cli set wasp.0.api 127.0.0.1:9090
wasp-cli set wasp.0.nanomsg 127.0.0.1:5550
wasp-cli set wasp.0.peering 127.0.0.1:4000

设置一个链

# Trust node
wasp-cli peering info
wasp-cli peering trust {PubKey} 127.0.0.1:4000
wasp-cli peering list-trusted

# Deploy The Chain
# `committee` will correspond to wasp.0, wasp.1 in `wasp-cli.json`
# `quorum` is minimum amount node
wasp-cli chain deploy --committee=0 --quorum=1 --chain=alpha-interface-chain --description="Alpha Interface Chain"

# Deposit money to the chain
wasp-cli chain deposit IOTA:10000

# Set test chain you can find chain id from `http://127.0.0.1:7000/chains`
wasp-cli set chains.testchain {chain-id}
wasp-cli set chain testchain

构建智能合约

make build-wasm

部署智能合约

make deploy-wasm

发送智能合约请求

wasp-cli chain post-request alphainterface setOwner string owner string {actorID}
wasp-cli chain call-view alphainterface getOwner

wasp-cli chain list-accounts

wasp-cli chain post-request alphainterface setCrop string name string potato string country string germany --off-ledger
wasp-cli chain post-request alphainterface setCrop string name string rice string country string germany --off-ledger

wasp-cli chain call-view alphainterface getCrops
wasp-cli chain call-view alphainterface getCropsString
wasp-cli chain call-view alphainterface getCrop string cropIdx int32 0

wasp-cli chain post-request alphainterface createOrder string cropIdx int32 0 string type string short --transfer=IOTA:1000
wasp-cli chain call-view alphainterface getOrders
wasp-cli chain call-view alphainterface getOrdersString
wasp-cli chain call-view alphainterface getPositions
wasp-cli chain call-view alphainterface getPositionsString

wasp-cli chain post-request alphainterface createOrder string cropIdx int32 0 string type string long --transfer=IOTA:2000

wasp-cli chain post-request alphainterface closePosition string positionIdx int32 0
wasp-cli chain post-request alphainterface createOrder string cropIdx int32 0 string type string short --transfer=IOTA:1000

停用链

wasp-cli chain deactivate

资源

https://wiki.iota.org/wasp/overview

GitHub

查看 Github