基于dojo-starter项目,使用Slot命令部署游戏
基于dojo-starter项目, 使用 Slot 命令部署游戏,可以参考这个 教程。 你需要为 katana slot 和 torii slot 提供 RPC 节点 URL, 部署的 katana 和 torii slot 名必须和github 用户一致。例如:
https://api.cartridge.gg/x/github-username/katana
https://api.cartridge.gg/x/github-username/torii/graphql
https://api.cartridge.gg/x/github-username/torii/grpc
$ 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`
执行该命令,将会跳转到浏览器网页进行身份认证。需要进行帐号注册,并使用手机扫码进行身份验证。
$ 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
注册帐号:
认证成功后,网页上将会看到:
回到终端也会看到You are now logged in!
字样:
注:如果是vscode远程开发,需要配置转发端口,因会回调本地回环IP(http://127.0.0.1:40113/callback?code=aaa.bbb.ccc&state=),需要转发到远程服务器上,否则认证授权的无法回调成功。
# 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个帐号,在下一步的配置修改中可以选择其中一个使用
$ 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
修改配置文件: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_address
和private_key
# 修改前
account_address = "0x517ececd29116499f4a1b64b094da79ba08dfd54a3edaa316134c41f8160973"
private_key = "0x1800000000300000180000000000030000000000003006001800006600"
# 修改后
account_address = "0x15395ba42b40caa6af2d7782931f7e2d3a869271794e8b87c90f63eac5e8c14"
private_key = "0x......"
该命令执行成功没有任何日志(NO NEWS IS GOOD NEWS🤣)
$ sozo build
部署到我们创建的
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
$ 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`
启动成功后将得到GraphQL
和gRPC
地址。
$ slot deployments logs $DEPLOYMENT_NAME torii -f
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!