cyberia 3.0.3 → 3.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{.env.production → .env.example} +20 -2
- package/.github/workflows/engine-cyberia.cd.yml +41 -10
- package/.github/workflows/engine-cyberia.ci.yml +53 -14
- package/.github/workflows/ghpkg.ci.yml +1 -1
- package/.github/workflows/gitlab.ci.yml +1 -1
- package/.github/workflows/hardhat.ci.yml +82 -0
- package/.github/workflows/npmpkg.ci.yml +37 -8
- package/.github/workflows/publish.ci.yml +5 -5
- package/.github/workflows/publish.cyberia.ci.yml +5 -5
- package/.github/workflows/pwa-microservices-template-page.cd.yml +3 -3
- package/.github/workflows/pwa-microservices-template-test.ci.yml +1 -1
- package/.github/workflows/release.cd.yml +3 -2
- package/.vscode/extensions.json +9 -8
- package/.vscode/settings.json +3 -2
- package/CHANGELOG.md +211 -1
- package/CLI-HELP.md +78 -53
- package/WHITE-PAPER.md +1540 -0
- package/bin/build.js +16 -10
- package/bin/cyberia.js +861 -4
- package/bin/deploy.js +103 -270
- package/bin/file.js +2 -1
- package/bin/index.js +861 -4
- package/bin/vs.js +3 -3
- package/conf.js +105 -97
- package/deployment.yaml +148 -4
- package/hardhat/.env.example +31 -0
- package/hardhat/README.md +531 -0
- package/hardhat/WHITE-PAPER.md +1540 -0
- package/hardhat/contracts/ObjectLayerToken.sol +391 -0
- package/hardhat/deployments/.gitkeep +0 -0
- package/hardhat/deployments/hardhat-ObjectLayerToken.json +11 -0
- package/hardhat/hardhat.config.js +136 -0
- package/hardhat/ignition/modules/ObjectLayerToken.js +21 -0
- package/hardhat/networks/besu-object-layer.network.json +138 -0
- package/hardhat/package-lock.json +7628 -0
- package/hardhat/package.json +45 -0
- package/hardhat/scripts/deployObjectLayerToken.js +98 -0
- package/hardhat/test/ObjectLayerToken.js +590 -0
- package/jsdoc.dd-cyberia.json +59 -0
- package/jsdoc.json +20 -13
- package/manifests/cronjobs/dd-cron/dd-cron-backup.yaml +1 -1
- package/manifests/cronjobs/dd-cron/dd-cron-dns.yaml +1 -1
- package/manifests/deployment/dd-cyberia-development/deployment.yaml +490 -0
- package/manifests/deployment/dd-cyberia-development/proxy.yaml +261 -0
- package/manifests/deployment/dd-cyberia-development/pv-pvc.yaml +132 -0
- package/manifests/deployment/dd-default-development/deployment.yaml +2 -2
- package/manifests/deployment/dd-test-development/deployment.yaml +52 -52
- package/manifests/deployment/dd-test-development/proxy.yaml +4 -4
- package/manifests/pv-pvc-dd.yaml +1 -1
- package/package.json +50 -44
- package/proxy.yaml +79 -7
- package/pv-pvc.yaml +132 -0
- package/scripts/k3s-node-setup.sh +1 -1
- package/scripts/ports-ls.sh +2 -0
- package/src/api/atlas-sprite-sheet/atlas-sprite-sheet.controller.js +3 -1
- package/src/api/atlas-sprite-sheet/atlas-sprite-sheet.model.js +1 -2
- package/src/api/document/document.service.js +1 -1
- package/src/api/file/file.controller.js +3 -1
- package/src/api/file/file.service.js +28 -5
- package/src/api/ipfs/ipfs.service.js +2 -2
- package/src/api/object-layer/object-layer.controller.js +6 -2
- package/src/api/object-layer/object-layer.model.js +12 -8
- package/src/api/object-layer/object-layer.router.js +668 -42
- package/src/api/object-layer/object-layer.service.js +6 -7
- package/src/api/object-layer-render-frames/object-layer-render-frames.model.js +1 -2
- package/src/api/user/user.router.js +10 -5
- package/src/api/user/user.service.js +7 -7
- package/src/cli/baremetal.js +6 -10
- package/src/cli/cloud-init.js +0 -3
- package/src/cli/db.js +54 -71
- package/src/cli/deploy.js +64 -12
- package/src/cli/env.js +5 -5
- package/src/cli/fs.js +0 -2
- package/src/cli/image.js +0 -3
- package/src/cli/index.js +35 -13
- package/src/cli/monitor.js +5 -6
- package/src/cli/repository.js +329 -46
- package/src/cli/run.js +180 -120
- package/src/cli/secrets.js +1 -3
- package/src/cli/ssh.js +1 -1
- package/src/client/Itemledger.index.js +1 -959
- package/src/client/components/core/AgGrid.js +20 -5
- package/src/client/components/core/Alert.js +2 -2
- package/src/client/components/core/Content.js +22 -3
- package/src/client/components/core/Docs.js +30 -6
- package/src/client/components/core/FileExplorer.js +71 -4
- package/src/client/components/core/Input.js +1 -1
- package/src/client/components/core/Modal.js +20 -6
- package/src/client/components/core/RichText.js +1 -2
- package/src/client/components/cyberia-portal/CommonCyberiaPortal.js +1 -0
- package/src/client/components/cyberia-portal/CssCyberiaPortal.js +44 -2
- package/src/client/components/cyberia-portal/LogInCyberiaPortal.js +0 -1
- package/src/client/components/cyberia-portal/MenuCyberiaPortal.js +64 -2
- package/src/client/components/cyberia-portal/RoutesCyberiaPortal.js +1 -0
- package/src/client/components/underpost/CssUnderpost.js +59 -0
- package/src/client/components/underpost/LogInUnderpost.js +3 -0
- package/src/client/components/underpost/LogOutUnderpost.js +2 -0
- package/src/client/components/underpost/MenuUnderpost.js +99 -13
- package/src/client/components/underpost/RoutesUnderpost.js +2 -0
- package/src/client/public/cryptokoyn/assets/logo/base-icon.png +0 -0
- package/src/client/public/cryptokoyn/browserconfig.xml +12 -0
- package/src/client/public/cryptokoyn/microdata.json +85 -0
- package/src/client/public/cryptokoyn/site.webmanifest +57 -0
- package/src/client/public/cryptokoyn/sitemap +3 -3
- package/src/client/public/default/sitemap +3 -3
- package/src/client/public/itemledger/browserconfig.xml +2 -2
- package/src/client/public/itemledger/manifest.webmanifest +4 -4
- package/src/client/public/itemledger/microdata.json +71 -0
- package/src/client/public/itemledger/sitemap +3 -3
- package/src/client/public/itemledger/yandex-browser-manifest.json +2 -2
- package/src/client/public/test/sitemap +3 -3
- package/src/client/ssr/body/404.js +15 -11
- package/src/client/ssr/body/500.js +15 -11
- package/src/client/ssr/body/SwaggerDarkMode.js +285 -0
- package/src/client/ssr/head/PwaItemledger.js +60 -0
- package/src/client/ssr/offline/NoNetworkConnection.js +11 -10
- package/src/client/ssr/pages/Test.js +11 -10
- package/src/client.build.js +0 -3
- package/src/client.dev.js +0 -3
- package/src/db/DataBaseProvider.js +17 -2
- package/src/db/mariadb/MariaDB.js +14 -9
- package/src/db/mongo/MongooseDB.js +17 -1
- package/src/index.js +1 -1
- package/src/proxy.js +0 -3
- package/src/runtime/express/Express.js +15 -9
- package/src/runtime/lampp/Lampp.js +6 -13
- package/src/server/auth.js +12 -14
- package/src/server/backup.js +2 -3
- package/src/server/besu-genesis-generator.js +1630 -0
- package/src/server/client-build-docs.js +126 -17
- package/src/server/client-build-live.js +9 -18
- package/src/server/client-build.js +203 -75
- package/src/server/client-dev-server.js +14 -13
- package/src/server/conf.js +376 -164
- package/src/server/cron.js +2 -1
- package/src/server/dns.js +28 -12
- package/src/server/downloader.js +0 -2
- package/src/server/logger.js +27 -9
- package/src/server/object-layer.js +79 -6
- package/src/server/peer.js +0 -2
- package/src/server/process.js +1 -50
- package/src/server/proxy.js +4 -8
- package/src/server/runtime.js +5 -8
- package/src/server/ssr.js +0 -3
- package/src/server/start.js +19 -12
- package/src/server/tls.js +0 -2
- package/src/server.js +0 -4
- package/.env.development +0 -43
- package/.env.test +0 -43
- package/hardhat/contracts/CryptoKoyn.sol +0 -59
- package/hardhat/contracts/ItemLedger.sol +0 -73
- package/hardhat/contracts/Lock.sol +0 -34
- package/hardhat/hardhat.config.cjs +0 -45
- package/hardhat/ignition/modules/Lock.js +0 -18
- package/hardhat/networks/cryptokoyn-itemledger.network.json +0 -29
- package/hardhat/scripts/deployCryptokoyn.cjs +0 -25
- package/hardhat/scripts/deployItemledger.cjs +0 -25
- package/hardhat/test/Lock.js +0 -126
- package/hardhat/white-paper.md +0 -581
- package/white-paper.md +0 -581
|
@@ -0,0 +1,531 @@
|
|
|
1
|
+
# Cyberia Hardhat Module
|
|
2
|
+
|
|
3
|
+
Hardhat project for the **Cyberia Online Object Layer Token** (ERC-1155) ecosystem deployed on **Hyperledger Besu** (IBFT2/QBFT) private networks.
|
|
4
|
+
|
|
5
|
+
This module contains the Solidity smart contract, deployment scripts, tests, and network configuration for the unified `ObjectLayerToken` contract that manages the entire Cyberia token economy:
|
|
6
|
+
|
|
7
|
+
| Token Type | Token ID | Supply | Description |
|
|
8
|
+
|---|---|---|---|
|
|
9
|
+
| **Fungible (CKY)** | `0` | 10,000,000 × 10¹⁸ | CryptoKoyn — in-game currency managed via cryptokoyn.net |
|
|
10
|
+
| **Semi-fungible** | `computeTokenId(itemId)` | > 1 | Stackable resources (wood, stone, potions) via itemledger.com |
|
|
11
|
+
| **Non-fungible** | `computeTokenId(itemId)` | = 1 | Unique items (legendary weapons, skins) via itemledger.com |
|
|
12
|
+
|
|
13
|
+
See [WHITE-PAPER.md](./WHITE-PAPER.md) for the full protocol specification.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Project Structure
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
hardhat/
|
|
21
|
+
├── contracts/
|
|
22
|
+
│ └── ObjectLayerToken.sol # Unified ERC-1155 multi-token contract
|
|
23
|
+
├── scripts/
|
|
24
|
+
│ └── deployObjectLayerToken.js # Deployment script (ESM)
|
|
25
|
+
├── test/
|
|
26
|
+
│ └── ObjectLayerToken.js # Comprehensive test suite
|
|
27
|
+
├── deployments/ # JSON deployment artifacts (per-network)
|
|
28
|
+
├── networks/
|
|
29
|
+
│ └── besu-object-layer.network.json # Besu genesis & network config
|
|
30
|
+
├── ignition/
|
|
31
|
+
│ └── modules/
|
|
32
|
+
│ └── ObjectLayerToken.js # Hardhat Ignition module (alternative deploy)
|
|
33
|
+
├── hardhat.config.js # Hardhat configuration (ESM)
|
|
34
|
+
└── package.json
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Prerequisites
|
|
40
|
+
|
|
41
|
+
- **Node.js** ≥ 18
|
|
42
|
+
- **npm** or **yarn**
|
|
43
|
+
- For on-chain deployment: a running Hyperledger Besu network (IBFT2/QBFT)
|
|
44
|
+
|
|
45
|
+
Install dependencies:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
cd hardhat
|
|
49
|
+
npm install
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## 1. Ethereum Key Management
|
|
55
|
+
|
|
56
|
+
The Cyberia ecosystem uses **secp256k1 key pairs** as universal identity. The Cyberia CLI provides a key generation command:
|
|
57
|
+
|
|
58
|
+
### Generate a new key pair (console only)
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
# Print a new Ethereum key pair to the console without saving
|
|
62
|
+
cyberia chain key-gen
|
|
63
|
+
|
|
64
|
+
# Output:
|
|
65
|
+
# Address : 0x71C7656EC7ab88b098defB751B7401B5f6d8976F
|
|
66
|
+
# Private Key: 0x4c0883a69102937d6231471b5dbb...
|
|
67
|
+
# Public Key : 0x04b9e72dfd423bcf95b3...
|
|
68
|
+
# Mnemonic : word1 word2 word3 ...
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Generate and save to default paths
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
cyberia chain key-gen --save
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
This writes two separate files:
|
|
78
|
+
|
|
79
|
+
**Private data** → `./engine-private/eth-networks/besu/<address>.key.json`
|
|
80
|
+
|
|
81
|
+
```json
|
|
82
|
+
{
|
|
83
|
+
"address": "0x71C7656EC7ab88b098defB751B7401B5f6d8976F",
|
|
84
|
+
"privateKey": "0x4c0883a69102937d6231471b5dbb...",
|
|
85
|
+
"mnemonic": "word1 word2 word3 ..."
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**Public data** → `./hardhat/deployments/<address>.pub.json`
|
|
90
|
+
|
|
91
|
+
```json
|
|
92
|
+
{
|
|
93
|
+
"address": "0x71C7656EC7ab88b098defB751B7401B5f6d8976F",
|
|
94
|
+
"publicKey": "0x04b9e72dfd423bcf95b3..."
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
> **⚠ Security:** Private key files are stored under `./engine-private/` which should never be committed to version control. The coinbase deployer key is read from `engine-private/eth-networks/besu/coinbase` — a file outside the repository.
|
|
99
|
+
|
|
100
|
+
### Generate with custom paths
|
|
101
|
+
|
|
102
|
+
Override either or both default output paths:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
# Custom private key path only
|
|
106
|
+
cyberia chain key-gen --private-path ./my-secrets/deployer.key.json
|
|
107
|
+
|
|
108
|
+
# Custom public key path only
|
|
109
|
+
cyberia chain key-gen --public-path ./public/deployer.pub.json
|
|
110
|
+
|
|
111
|
+
# Both custom paths
|
|
112
|
+
cyberia chain key-gen \
|
|
113
|
+
--private-path ./my-secrets/deployer.key.json \
|
|
114
|
+
--public-path ./public/deployer.pub.json
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Providing `--private-path` or `--public-path` implies `--save` automatically.
|
|
118
|
+
|
|
119
|
+
### Set the coinbase deployer key
|
|
120
|
+
|
|
121
|
+
Use `cyberia chain set-coinbase` to configure the private key that `hardhat.config.js` reads for Besu deployments.
|
|
122
|
+
|
|
123
|
+
#### From a raw hex private key
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
cyberia chain set-coinbase --private-key 0xYOUR_PRIVATE_KEY_HEX
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
#### From a `.key.json` file generated by `key-gen --save`
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
# Use the key file saved by key-gen
|
|
133
|
+
cyberia chain set-coinbase --from-file ./engine-private/eth-networks/besu/0x71c7656ec7ab88b098defb751b7401b5f6d8976f.key.json
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
#### Custom coinbase file path
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
cyberia chain set-coinbase --private-key 0xYOUR_KEY --coinbase-path ./my-custom/path/coinbase
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
The command validates the private key by deriving its Ethereum address, normalises the `0x` prefix, and writes the raw key to `./engine-private/eth-networks/besu/coinbase` (or the path given by `--coinbase-path`).
|
|
143
|
+
|
|
144
|
+
#### Manual alternative (without CLI)
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
mkdir -p ./engine-private/eth-networks/besu
|
|
148
|
+
echo "0xYOUR_PRIVATE_KEY_HEX" > ./engine-private/eth-networks/besu/coinbase
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## 2. Compile & Test
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
# Compile Solidity contracts
|
|
157
|
+
cyberia chain compile
|
|
158
|
+
# or directly:
|
|
159
|
+
npx hardhat compile
|
|
160
|
+
|
|
161
|
+
# Run the full test suite (local Hardhat network)
|
|
162
|
+
cyberia chain test
|
|
163
|
+
# or directly:
|
|
164
|
+
npx hardhat test test/ObjectLayerToken.js
|
|
165
|
+
|
|
166
|
+
# Generate coverage report
|
|
167
|
+
npx hardhat coverage
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## 3. Deploy Besu Network & Contract
|
|
173
|
+
|
|
174
|
+
### Dynamic Manifest Generation
|
|
175
|
+
|
|
176
|
+
Every `cyberia chain deploy` invocation **dynamically generates fresh validator keys** (secp256k1), computes public keys, enode URLs, IBFT2 `extraData`, genesis, and all Kubernetes manifests before applying them. This means each deployment creates a **unique chain identity** — no hardcoded keys, hashes, or enodes.
|
|
177
|
+
|
|
178
|
+
The generator (`src/server/besu-genesis-generator.js`) produces:
|
|
179
|
+
|
|
180
|
+
| Artifact | Description |
|
|
181
|
+
|---|---|
|
|
182
|
+
| `manifests/besu/namespace.yaml` | Dedicated `besu` namespace |
|
|
183
|
+
| `manifests/besu/besu-genesis-configmap.yaml` | Genesis JSON with fresh `extraData` and validator addresses |
|
|
184
|
+
| `manifests/besu/besu-config-toml-configmap.yaml` | Besu TOML config + dynamic `static-nodes.json` |
|
|
185
|
+
| `manifests/besu/besu-validators-configmap.yaml` | Validator public keys (derived from new private keys) |
|
|
186
|
+
| `manifests/besu/besu-node-permissions-configmap.yaml` | Node allowlist with dynamic enode URLs |
|
|
187
|
+
| `manifests/besu/besu-secrets.yaml` | Validator node key secrets (fresh secp256k1 keys) |
|
|
188
|
+
| `manifests/besu/besu-services.yaml` | ClusterIP + NodePort services |
|
|
189
|
+
| `manifests/besu/besu-validators.yaml` | StatefulSets for all validators |
|
|
190
|
+
| `manifests/besu/kustomization.yaml` | Kustomize orchestration |
|
|
191
|
+
| `hardhat/networks/besu-object-layer.network.json` | Network config for Hardhat integration |
|
|
192
|
+
| `engine-private/eth-networks/besu/validators/` | Validator private key backups |
|
|
193
|
+
|
|
194
|
+
### Deploy the Besu blockchain (Kubernetes)
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
# Deploy IBFT2 consensus network (generates fresh keys + manifests, then applies)
|
|
198
|
+
cyberia chain deploy
|
|
199
|
+
|
|
200
|
+
# Deploy with custom options
|
|
201
|
+
cyberia chain deploy \
|
|
202
|
+
--validators 4 \
|
|
203
|
+
--chain-id 777771 \
|
|
204
|
+
--block-period 5 \
|
|
205
|
+
--epoch-length 30000 \
|
|
206
|
+
--coinbase-address 0xYOUR_DEPLOYER_ADDRESS \
|
|
207
|
+
--besu-image hyperledger/besu:24.12.1 \
|
|
208
|
+
--node-port-rpc 30545 \
|
|
209
|
+
--node-port-ws 30546 \
|
|
210
|
+
--namespace besu
|
|
211
|
+
|
|
212
|
+
# Pull container images into containerd before deployment (kubeadm)
|
|
213
|
+
cyberia chain deploy --pull-image
|
|
214
|
+
|
|
215
|
+
# Skip manifest generation and use existing manifests/besu/ as-is
|
|
216
|
+
cyberia chain deploy --skip-generate
|
|
217
|
+
|
|
218
|
+
# Skip waiting for validator pods to reach Running state
|
|
219
|
+
cyberia chain deploy --skip-wait
|
|
220
|
+
|
|
221
|
+
# Remove the network
|
|
222
|
+
cyberia chain remove
|
|
223
|
+
|
|
224
|
+
# Remove the network and clean up validator private keys
|
|
225
|
+
cyberia chain remove --clean-keys
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### Generate manifests without deploying
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
# Generate fresh manifests only (no kubectl apply)
|
|
232
|
+
cyberia chain generate-manifests
|
|
233
|
+
|
|
234
|
+
# With custom parameters
|
|
235
|
+
cyberia chain generate-manifests \
|
|
236
|
+
--validators 4 \
|
|
237
|
+
--chain-id 777771 \
|
|
238
|
+
--block-period 5 \
|
|
239
|
+
--namespace besu \
|
|
240
|
+
--output-dir ./manifests/besu
|
|
241
|
+
|
|
242
|
+
# Then deploy later with the pre-generated manifests
|
|
243
|
+
cyberia chain deploy --skip-generate
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### Deploy the ObjectLayerToken contract
|
|
247
|
+
|
|
248
|
+
The contract deploys with:
|
|
249
|
+
- 10,000,000 CKY (token ID 0) minted to the deployer
|
|
250
|
+
- Base IPFS URI `ipfs://` for metadata resolution
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
# Deploy to local Besu IBFT2
|
|
254
|
+
cyberia chain deploy-contract --network besu-ibft2
|
|
255
|
+
|
|
256
|
+
# Deploy to Besu QBFT
|
|
257
|
+
cyberia chain deploy-contract --network besu-qbft
|
|
258
|
+
|
|
259
|
+
# Deploy to Kubernetes-exposed Besu
|
|
260
|
+
cyberia chain deploy-contract --network besu-k8s
|
|
261
|
+
|
|
262
|
+
# Deploy to local Hardhat network (for testing)
|
|
263
|
+
npx hardhat run scripts/deployObjectLayerToken.js --network hardhat
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
A deployment artifact is written to `deployments/<network>-ObjectLayerToken.json`:
|
|
267
|
+
|
|
268
|
+
```json
|
|
269
|
+
{
|
|
270
|
+
"network": "besu-ibft2",
|
|
271
|
+
"chainId": "777771",
|
|
272
|
+
"contract": "ObjectLayerToken",
|
|
273
|
+
"address": "0x5FbDB2315678afecb367f032d93F642f64180aa3",
|
|
274
|
+
"deployer": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
|
275
|
+
"baseURI": "ipfs://",
|
|
276
|
+
"cryptokoynTokenId": "0",
|
|
277
|
+
"initialCryptokoynSupply": "10000000000000000000000000",
|
|
278
|
+
"timestamp": "2026-03-08T01:11:37.978Z"
|
|
279
|
+
}
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
### Check chain status
|
|
283
|
+
|
|
284
|
+
```bash
|
|
285
|
+
cyberia chain status --network besu-k8s
|
|
286
|
+
# or for direct RPC access
|
|
287
|
+
cyberia chain status --network besu-ibft2
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
> **Note:** The coinbase address is auto-detected from `./engine-private/eth-networks/besu/coinbase` during manifest generation. If no coinbase key exists, run `cyberia chain key-gen --save` and `cyberia chain set-coinbase` before deploying.
|
|
291
|
+
|
|
292
|
+
---
|
|
293
|
+
|
|
294
|
+
## 4. Fungible Token: CryptoKoyn (CKY)
|
|
295
|
+
|
|
296
|
+
CKY is token ID `0` — the fungible in-game currency with 18-decimal precision, managed via **cryptokoyn.net**.
|
|
297
|
+
|
|
298
|
+
### Query CKY balance
|
|
299
|
+
|
|
300
|
+
```bash
|
|
301
|
+
cyberia chain balance --address 0xYourAddress --token-id 0 --network besu-ibft2
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### Mint additional CKY
|
|
305
|
+
|
|
306
|
+
```bash
|
|
307
|
+
# Mint 1000 CKY (with 18 decimals: 1000 * 10^18)
|
|
308
|
+
cyberia chain mint \
|
|
309
|
+
--token-id 0 \
|
|
310
|
+
--to 0xPlayerAddress \
|
|
311
|
+
--amount 1000000000000000000000 \
|
|
312
|
+
--network besu-ibft2
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
### Transfer CKY
|
|
316
|
+
|
|
317
|
+
```bash
|
|
318
|
+
cyberia chain transfer \
|
|
319
|
+
--from 0xDeployerAddress \
|
|
320
|
+
--to 0xPlayerAddress \
|
|
321
|
+
--token-id 0 \
|
|
322
|
+
--amount 500000000000000000000 \
|
|
323
|
+
--network besu-ibft2
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
### Burn CKY (reduce circulating supply)
|
|
327
|
+
|
|
328
|
+
```bash
|
|
329
|
+
cyberia chain burn \
|
|
330
|
+
--address 0xHolderAddress \
|
|
331
|
+
--token-id 0 \
|
|
332
|
+
--amount 100000000000000000000 \
|
|
333
|
+
--network besu-ibft2
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
---
|
|
337
|
+
|
|
338
|
+
## 5. Semi-Fungible Tokens: Stackable Resources
|
|
339
|
+
|
|
340
|
+
Semi-fungible tokens have supply > 1 and represent stackable in-game resources (wood, stone, gold ore, health potions). Managed via **itemledger.com**.
|
|
341
|
+
|
|
342
|
+
### Register a semi-fungible resource
|
|
343
|
+
|
|
344
|
+
```bash
|
|
345
|
+
# Register "gold-ore" with initial supply of 1,000,000 units
|
|
346
|
+
cyberia chain register \
|
|
347
|
+
--item-id gold-ore \
|
|
348
|
+
--metadata-cid bafkreigold0remetadata... \
|
|
349
|
+
--supply 1000000 \
|
|
350
|
+
--network besu-ibft2
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
### Batch-register multiple resources
|
|
354
|
+
|
|
355
|
+
```bash
|
|
356
|
+
cyberia chain batch-register \
|
|
357
|
+
--items '[
|
|
358
|
+
{"itemId": "wood", "cid": "bafkreiwood...", "supply": 500000},
|
|
359
|
+
{"itemId": "stone", "cid": "bafkreistone...", "supply": 500000},
|
|
360
|
+
{"itemId": "health-potion", "cid": "bafkreihp...", "supply": 100000}
|
|
361
|
+
]' \
|
|
362
|
+
--network besu-ibft2
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
### Mint more of an existing resource
|
|
366
|
+
|
|
367
|
+
```bash
|
|
368
|
+
# Get the token ID first (deterministic from keccak256)
|
|
369
|
+
# Then mint additional supply
|
|
370
|
+
cyberia chain mint \
|
|
371
|
+
--token-id <tokenId-of-gold-ore> \
|
|
372
|
+
--to 0xPlayerAddress \
|
|
373
|
+
--amount 500 \
|
|
374
|
+
--network besu-ibft2
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
### Burn resources (crafting cost)
|
|
378
|
+
|
|
379
|
+
```bash
|
|
380
|
+
# Player burns 25 wood for crafting
|
|
381
|
+
cyberia chain burn \
|
|
382
|
+
--address 0xPlayerAddress \
|
|
383
|
+
--token-id <tokenId-of-wood> \
|
|
384
|
+
--amount 25 \
|
|
385
|
+
--network besu-ibft2
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
---
|
|
389
|
+
|
|
390
|
+
## 6. Non-Fungible Tokens: Unique Items
|
|
391
|
+
|
|
392
|
+
Non-fungible tokens have supply = 1 and represent unique items (legendary weapons, character skins). Managed via **itemledger.com**.
|
|
393
|
+
|
|
394
|
+
### Register a non-fungible unique item
|
|
395
|
+
|
|
396
|
+
```bash
|
|
397
|
+
# Register a legendary hatchet (supply = 1, unique)
|
|
398
|
+
cyberia chain register \
|
|
399
|
+
--item-id legendary-hatchet \
|
|
400
|
+
--metadata-cid bafkreihatchetmeta... \
|
|
401
|
+
--supply 1 \
|
|
402
|
+
--network besu-ibft2
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
### Transfer a unique item (quest reward / trade)
|
|
406
|
+
|
|
407
|
+
```bash
|
|
408
|
+
cyberia chain transfer \
|
|
409
|
+
--from 0xServerRelayer \
|
|
410
|
+
--to 0xPlayerAddress \
|
|
411
|
+
--token-id <tokenId-of-legendary-hatchet> \
|
|
412
|
+
--amount 1 \
|
|
413
|
+
--network besu-ibft2
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
### Burn a unique item (destroy)
|
|
417
|
+
|
|
418
|
+
```bash
|
|
419
|
+
cyberia chain burn \
|
|
420
|
+
--address 0xPlayerAddress \
|
|
421
|
+
--token-id <tokenId-of-legendary-hatchet> \
|
|
422
|
+
--amount 1 \
|
|
423
|
+
--network besu-ibft2
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
---
|
|
427
|
+
|
|
428
|
+
## 7. Object Layer Ecosystem Integration
|
|
429
|
+
|
|
430
|
+
Each on-chain token corresponds to an off-chain **Object Layer** document with four semantic realities:
|
|
431
|
+
|
|
432
|
+
```
|
|
433
|
+
AtomicPrefab = {
|
|
434
|
+
data: {
|
|
435
|
+
stats: { effect, resistance, agility, range, intelligence, utility }, // Mechanical
|
|
436
|
+
item: { id, type, description, activable }, // Experiential (UX)
|
|
437
|
+
ledger: { type: "ERC1155", address: "0x...", tokenId: "uint256" }, // Economic
|
|
438
|
+
render: { cid: "bafk...atlas.png", metadataCid: "bafk...meta" } // Presentational
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
**Full lifecycle:** Register → Mint → Transfer → Burn
|
|
444
|
+
|
|
445
|
+
1. **Game server** creates the Object Layer (stats, item, render) and pins assets to IPFS
|
|
446
|
+
2. **Server relayer** calls `registerObjectLayer()` on Besu — assigns deterministic token ID
|
|
447
|
+
3. **MongoDB** is updated with `ledger: { type: "ERC1155", address, tokenId }`
|
|
448
|
+
4. **itemledger.com** indexes the new item via `ObjectLayerRegistered` event
|
|
449
|
+
5. **Players** trade via `safeTransferFrom`, craft via burn + mint, and earn via minting
|
|
450
|
+
|
|
451
|
+
### Token ID computation
|
|
452
|
+
|
|
453
|
+
Token IDs are deterministic from item identifiers:
|
|
454
|
+
|
|
455
|
+
```
|
|
456
|
+
tokenId = uint256(keccak256("cyberia.object-layer:" + itemId))
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
This ensures the same item ID always maps to the same token ID across all services.
|
|
460
|
+
|
|
461
|
+
---
|
|
462
|
+
|
|
463
|
+
## 8. Governance
|
|
464
|
+
|
|
465
|
+
### Emergency pause (freeze all transfers)
|
|
466
|
+
|
|
467
|
+
```bash
|
|
468
|
+
cyberia chain pause --network besu-ibft2
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
### Resume transfers
|
|
472
|
+
|
|
473
|
+
```bash
|
|
474
|
+
cyberia chain unpause --network besu-ibft2
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
---
|
|
478
|
+
|
|
479
|
+
## Network Configuration
|
|
480
|
+
|
|
481
|
+
| Network | RPC URL | Chain ID | Description |
|
|
482
|
+
|---|---|---|---|
|
|
483
|
+
| `hardhat` | in-process | 31337 | Local testing (default) |
|
|
484
|
+
| `besu-ibft2` | `http://127.0.0.1:8545` | 777771 | Local Besu IBFT2 (port-forward or docker-compose) |
|
|
485
|
+
| `besu-qbft` | `http://127.0.0.1:8545` | 777771 | Local Besu QBFT |
|
|
486
|
+
| `besu-k8s` | `http://127.0.0.1:30545` | 777771 | Kubernetes NodePort (recommended for kubeadm) |
|
|
487
|
+
|
|
488
|
+
Override RPC URLs via environment variables:
|
|
489
|
+
|
|
490
|
+
```bash
|
|
491
|
+
export BESU_IBFT2_RPC_URL=http://10.0.0.5:8545
|
|
492
|
+
export BESU_IBFT2_CHAIN_ID=777771
|
|
493
|
+
export BESU_K8S_RPC_URL=http://192.168.1.100:30545
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
## Dynamic Chain Generation Architecture
|
|
497
|
+
|
|
498
|
+
The `besu-genesis-generator.js` module (`src/server/besu-genesis-generator.js`) ensures every deployment gets a fresh chain identity:
|
|
499
|
+
|
|
500
|
+
1. **Key generation:** `crypto.createECDH('secp256k1')` generates N validator private keys
|
|
501
|
+
2. **Public key derivation:** Uncompressed public keys (128-char hex) derived from each private key
|
|
502
|
+
3. **Address computation:** `sha3-256(pubKeyBytes)[12..31]` yields the 20-byte Ethereum address
|
|
503
|
+
4. **IBFT2 extraData:** RLP-encoded `[vanity(32), [validator-addresses], vote, round, seals]`
|
|
504
|
+
5. **Genesis:** Includes dynamic `extraData`, coinbase alloc, dev accounts, and timestamp
|
|
505
|
+
6. **Enode URLs:** `enode://<pubkey>@validator<N>-0.besu-validator<N>.besu.svc.cluster.local:30303`
|
|
506
|
+
7. **Manifests:** All YAML files written with the computed values — no hardcoded hashes
|
|
507
|
+
|
|
508
|
+
```
|
|
509
|
+
cyberia chain deploy
|
|
510
|
+
└─> generateBesuManifests()
|
|
511
|
+
├─> generateValidatorKeys(4) → fresh secp256k1 key sets
|
|
512
|
+
├─> buildGenesis(validators, opts) → genesis.json with dynamic extraData
|
|
513
|
+
├─> write manifests/besu/*.yaml → all K8s resources
|
|
514
|
+
├─> write hardhat/networks/*.json → Hardhat network config
|
|
515
|
+
└─> write engine-private/*/validators/ → key backups
|
|
516
|
+
└─> kubectl apply -k manifests/besu
|
|
517
|
+
└─> wait for validator1-0..validator4-0 Running
|
|
518
|
+
```
|
|
519
|
+
|
|
520
|
+
---
|
|
521
|
+
|
|
522
|
+
## References
|
|
523
|
+
|
|
524
|
+
- [WHITE-PAPER.md](./WHITE-PAPER.md) — Full Object Layer Token protocol specification
|
|
525
|
+
- [src/server/besu-genesis-generator.js](../src/server/besu-genesis-generator.js) — Dynamic Besu manifest generator (deployBesu/removeBesu)
|
|
526
|
+
- [bin/cyberia.js](../bin/cyberia.js) — Cyberia CLI (chain deploy/remove/generate-manifests commands)
|
|
527
|
+
- [OpenZeppelin ERC-1155](https://docs.openzeppelin.com/contracts/5.x/erc1155)
|
|
528
|
+
- [Hardhat Documentation](https://hardhat.org/docs)
|
|
529
|
+
- [Hyperledger Besu](https://besu.hyperledger.org/)
|
|
530
|
+
- [EIP-1155: Multi Token Standard](https://eips.ethereum.org/EIPS/eip-1155)
|
|
531
|
+
- [EIP-712: Typed Structured Data Signing](https://eips.ethereum.org/EIPS/eip-712)
|