OpenBuild Starknet Bootcamp任务4:基于dojo-starter项目,使用Slot命令部署游戏

  • rzexin
  • 更新于 2024-01-05 18:57
  • 阅读 2316

基于dojo-starter项目,使用Slot命令部署游戏

OpenBuild Starknet Bootcamp任务4:基于dojo-starter项目,使用Slot命令部署游戏

1 任务要求

基于dojo-starter项目, 使用 Slot 命令部署游戏,可以参考这个 教程。 你需要为 katana slot 和 torii slot 提供 RPC 节点 URL, 部署的 katana 和 torii slot 名必须和github 用户一致。例如:

  1. Katana rpc: https://api.cartridge.gg/x/github-username/katana
  2. Torii 端点
    1. GraphQL: https://api.cartridge.gg/x/github-username/torii/graphql
    2. GRPC: https://api.cartridge.gg/x/github-username/torii/grpc

2 项目创建

$ mkdir js-dojo-starter && cd js-dojo-starter

$ sozo init
 ⛩️ ====== STARTING ====== ⛩️ 
Setting up project directory tree...
Cloning project template from https://github.com/dojoengine/dojo-starter...
🎉 Successfully created a new ⛩️ Dojo project!
====== SETUP COMPLETE! ======
To start using your new project, try running: `sozo build`

3 身份验证

执行该命令,将会跳转到浏览器网页进行身份认证。需要进行帐号注册,并使用手机扫码进行身份验证。

$ slot auth login
Your browser has been opened to visit: 

    https://x.cartridge.gg/slot/auth?callback_uri=http%3A%2F%2F127.0.0.1%3A40113%2Fcallback

image.png

注册帐号:

image.png

认证成功后,网页上将会看到:

image.png

回到终端也会看到You are now logged in!字样:

image.png

注:如果是vscode远程开发,需要配置转发端口,因会回调本地回环IP(http://127.0.0.1:40113/callback?code=aaa.bbb.ccc&state=),需要转发到远程服务器上,否则认证授权的无法回调成功

image.png

4 部署katana

4.1 执行部署命令

# slot deployments create <DEPLOYMENT_NAME> katana

$ export DEPLOYMENT_NAME=bityoume

$ slot deployments create $DEPLOYMENT_NAME katana
Deployment success 🚀

Endpoints:
  RPC: https://api.cartridge.gg/x/bityoume/katana

Stream logs with `slot deployments logs bityoume katana -f`

添加RPC地址到环境变量:

$ export RPC_URL=https://api.cartridge.gg/x/bityoume/katana

4.2 查看日志

默认创建了4个帐号,在下一步的配置修改中可以选择其中一个使用

$ slot deployments logs bityoume katana -f
| Account address |  0x15395ba42b40caa6af2d7782931f7e2d3a869271794e8b87c90f63eac5e8c14 
| Private key     |  0x......
| Public key      |  0x15a4af9aec05591aab053b7228d5e10810016879c3e49e56e9181773172c760

| Account address |  0x56e16ef173284363bd4f18a103b81036219abee41013ff0ad568d18083c8f37 
| Private key     |  0x......
| Public key      |  0x7556734de52bd4553647f9ecd063819449f89ade3bc96cfe46b20f922af1db7

| Account address |  0x2bcf2b7376d8dec1d2605e08e7fbcd10e99181fbaae0652ba14bcc1427d7678 
| Private key     |  0x......
| Public key      |  0x5ed6ec9c89999d6bedc412d0b44d5e0c714fd42181076345c5ebcf99ba81b5

| Account address |  0x50be9cd85891dde3daf9870f8975a029afbd78df29fd350a075bbb51797db2 
| Private key     |  0x......
| Public key      |  0x59588bb05f2405d730183d4a7599631d11ea7d306b24cf0f3a19b8efe4838c2

ACCOUNTS SEED
=============
9017192354132292993

🚀 JSON-RPC server started: http://0.0.0.0:5050

5 更新配置

修改配置文件:Scarb.toml

  • 修改rpc_url
# 修改前
[tool.dojo.env]
rpc_url = "http://localhost:5050/"

# 修改后
[tool.dojo.env]
rpc_url = "https://api.cartridge.gg/x/bityoume/katana"
  • 修改account_addressprivate_key
# 修改前
account_address = "0x517ececd29116499f4a1b64b094da79ba08dfd54a3edaa316134c41f8160973"
private_key = "0x1800000000300000180000000000030000000000003006001800006600"

# 修改后
account_address = "0x15395ba42b40caa6af2d7782931f7e2d3a869271794e8b87c90f63eac5e8c14"
private_key = "0x......"

6 项目编译

该命令执行成功没有任何日志(NO NEWS IS GOOD NEWS🤣)

$ sozo build

7 项目部署

部署到我们创建的Slot

# sozo migrate --name YOUR_PROJECT_NAME

$ sozo migrate --name js-dojo-starter

Migration account: 0x15395ba42b40caa6af2d7782931f7e2d3a869271794e8b87c90f63eac5e8c14

World name: js-dojo-starter

[1] 🌎 Building World state....
  > No remote World found
[2] 🧰 Evaluating Worlds diff....
  > Total diffs found: 5
[3] 📦 Preparing for migration....
  > Total items to be migrated (5): New 5 Update 0

# Executor
  > Contract address: 0x30d87b1462e33becf675f22517d2ff6d6b3b00ace2217a629a7eab770e467bc
# Base Contract
  > Class Hash: 0x6c458453d35753703ad25632deec20a29faf8531942ec109e6eb0650316a2bc
# World
  > Contract address: 0x47c831906db61b51a831d0c00f7f6ab3b2163e88af79d80e7f7eca70ed2ed39
# Models (2)
dojo_examples::models::moves
  > Class hash: 0x64495ca6dc1dc328972697b30468cea364bcb7452bbb6e4aaad3e4b3f190147
dojo_examples::models::position
  > Class hash: 0x4cd20d231b04405a77b184c115dc60637e186504fad7f0929bd76cbd09c10b
  > Registered at: 0x4a57a63d6bc3411969f306ce32848d318fa9b89a139c3a3f1529c43c86768ae
# Contracts (1)
dojo_examples::actions::actions
  > Contract address: 0x148ac942819a3d42f707fef5c3457e81f5faece5d5c8e4305b75b9918a7b41

🎉 Successfully migrated World at address 0x47c831906db61b51a831d0c00f7f6ab3b2163e88af79d80e7f7eca70ed2ed39

✨ Updating manifest.json...

✨ Done.

得到World地址,添加到环境变量中:

$ export WORLD_ADDRESS=0x47c831906db61b51a831d0c00f7f6ab3b2163e88af79d80e7f7eca70ed2ed39

8 启动索引器

8.1 执行启动命令

$ slot deployments create $DEPLOYMENT_NAME torii --world $WORLD_ADDRESS --rpc $RPC_URL --start-block 1
Deployment success 🚀

Configuration:
  World: 0x47c831906db61b51a831d0c00f7f6ab3b2163e88af79d80e7f7eca70ed2ed39
  RPC: https://api.cartridge.gg/x/bityoume/katana
  Start Block: 1

Endpoints:
  GRAPHQL: https://api.cartridge.gg/x/bityoume/torii/graphql
  GRPC: https://api.cartridge.gg/x/bityoume/torii/grpc

Stream logs with `slot deployments logs bityoume torii -f`

启动成功后将得到GraphQLgRPC地址。

8.2 查看日志

$ slot deployments logs $DEPLOYMENT_NAME torii -f
点赞 0
收藏 0
分享
本文参与登链社区写作激励计划 ,好文好收益,欢迎正在阅读的你也加入。

0 条评论

请先 登录 后评论
rzexin
rzexin
0x6Fa5...8165
江湖只有他的大名,没有他的介绍。