Skip to content

Commit ab0f73d

Browse files
authored
chore(deploy): mainnet fresh-deploy path + repoint to new mainnet contracts (#71)
- Deploy.s.sol: gate MarketSeed/bootstrapMarket behind non-mainnet. On Gravity mainnet (chain 127001) switch GTreasury to withdraw mode (faucet OFF -> withdraw ON) so no unbacked G can be minted on the full-backed mainnet economy. - Repoint default Router to the freshly deployed mainnet proxy 0x13860c81003e1d11E8C8576F995a68b02c750A59 across frontend config, MCP server defaults (src + rebuilt zero-install bin bundle), README, and the play-skill connect docs. - frontend: format wei-denominated gBalance for display (1 G = 1e18), fixing the G column now that mainnet runs the wei economy.
1 parent 89c1bf2 commit ab0f73d

9 files changed

Lines changed: 761 additions & 623 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ npm run build # tsc → dist/ (or `npm run build:bin` to refresh the bu
227227
"env": {
228228
"PRIVATE_KEY": "0xYOUR_PRIVATE_KEY",
229229
"RPC_URL": "https://mainnet-rpc.gravity.xyz",
230-
"ROUTER_ADDRESS": "0x4c2F6C0BAd768A75a67949b35feb094BAC4De03a",
230+
"ROUTER_ADDRESS": "0x13860c81003e1d11E8C8576F995a68b02c750A59",
231231
"CHAIN_ID": "127001"
232232
}
233233
}

contracts/script/Deploy.s.sol

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import "../src/ArenaEngine.sol";
1515
import "../src/Router.sol";
1616

1717
contract DeployScript is Script {
18+
uint256 constant GRAVITY_MAINNET_CHAIN_ID = 127001;
19+
1820
function run() external {
1921
uint256 deployerKey = vm.envUint("PRIVATE_KEY");
2022
address operator = vm.envAddress("OPERATOR_ADDRESS");
@@ -119,9 +121,20 @@ contract DeployScript is Script {
119121
Router(address(routerProxy)).setGTreasury(address(treasuryProxy));
120122
Router(address(routerProxy)).setCardLedger(address(cardLedgerProxy));
121123

122-
uint8[4] memory seedStats = [uint8(5), 5, 5, 5];
123-
(uint256 seedAgentId, ) = engine.createAgent("MarketSeed", "arena market maker", seedStats, operator);
124-
ArenaEngine(address(arenaProxy)).bootstrapMarket(seedAgentId);
124+
// Mainnet runs a full-backing G economy: no free faucet, G is withdrawable.
125+
// bootstrapMarket faucet-mints unbacked G, so it is skipped on mainnet; the
126+
// treasury is switched to withdraw mode instead. Testnet/anvil keep the faucet
127+
// and seeded market.
128+
uint256 seedAgentId = 0;
129+
if (block.chainid == GRAVITY_MAINNET_CHAIN_ID) {
130+
// faucet OFF first — setWithdrawEnabled requires !faucetEnabled.
131+
GTreasury(address(treasuryProxy)).setFaucetEnabled(false);
132+
GTreasury(address(treasuryProxy)).setWithdrawEnabled(true);
133+
} else {
134+
uint8[4] memory seedStats = [uint8(5), 5, 5, 5];
135+
(seedAgentId, ) = engine.createAgent("MarketSeed", "arena market maker", seedStats, operator);
136+
ArenaEngine(address(arenaProxy)).bootstrapMarket(seedAgentId);
137+
}
125138

126139
// ──── Initialize World Bible ────
127140
engine.initWorldBible();

frontend/config/gravity-mainnet.example.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
"rpc_url": "https://mainnet-rpc.gravity.xyz",
33
"wss_url": "",
44
"chain_id": 127001,
5-
"router_address": "0x4c2F6C0BAd768A75a67949b35feb094BAC4De03a",
5+
"router_address": "0x13860c81003e1d11E8C8576F995a68b02c750A59",
66
"explorer_url": "https://mainnet-explorer.gravity.xyz"
77
}

frontend/config/gravity.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
"rpc_url": "https://mainnet-rpc.gravity.xyz",
33
"wss_url": "",
44
"chain_id": 127001,
5-
"router_address": "0x4c2F6C0BAd768A75a67949b35feb094BAC4De03a",
5+
"router_address": "0x13860c81003e1d11E8C8576F995a68b02c750A59",
66
"explorer_url": "https://mainnet-explorer.gravity.xyz"
77
}

frontend/src/hooks/useArenaEngine.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useEffect, useRef } from 'react';
2-
import { JsonRpcProvider, Contract, EventLog } from 'ethers';
2+
import { JsonRpcProvider, Contract, EventLog, formatUnits } from 'ethers';
33
import { useGameStore } from '../store/useGameStore';
44
import { useArenaStore, ArenaGhost, ArenaMatch, ArenaSimulation } from '../store/useArenaStore';
55
import { getActiveNetwork } from '../lib/networks';
@@ -340,7 +340,8 @@ export function useArenaEngine() {
340340
agentIds.forEach((aId, i) => {
341341
const id = Number(aId);
342342
tierOf[id] = Number(tiers[i]) as 0 | 1 | 2;
343-
if (hasGTreasury) gOf[id] = Number(gBalances[i]);
343+
// gBalance is wei-denominated on-chain (1 G = 1e18); show whole-G.
344+
if (hasGTreasury) gOf[id] = Number(formatUnits(gBalances[i], 18));
344345
});
345346
} catch { /* pre-#33 arena — leave tier/G unset */ }
346347

mcp-server/bin/gravity-town-mcp.mjs

Lines changed: 736 additions & 612 deletions
Large diffs are not rendered by default.

mcp-server/src/http.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { ChainClient, ChainConfig } from "./chain.js";
88
function getConfig(): ChainConfig {
99
const rpcUrl = process.env.RPC_URL || "https://mainnet-rpc.gravity.xyz";
1010
const privateKey = process.env.PRIVATE_KEY;
11-
const routerAddress = process.env.ROUTER_ADDRESS || "0x4c2F6C0BAd768A75a67949b35feb094BAC4De03a";
11+
const routerAddress = process.env.ROUTER_ADDRESS || "0x13860c81003e1d11E8C8576F995a68b02c750A59";
1212

1313
if (!privateKey) throw new Error("PRIVATE_KEY env var required");
1414

mcp-server/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { registerTools, ToolOptions } from "./tools.js";
77
function getConfig(): ChainConfig {
88
const rpcUrl = process.env.RPC_URL || "https://mainnet-rpc.gravity.xyz";
99
const privateKey = process.env.PRIVATE_KEY;
10-
const routerAddress = process.env.ROUTER_ADDRESS || "0x4c2F6C0BAd768A75a67949b35feb094BAC4De03a";
10+
const routerAddress = process.env.ROUTER_ADDRESS || "0x13860c81003e1d11E8C8576F995a68b02c750A59";
1111

1212
if (!privateKey) throw new Error("PRIVATE_KEY env var required");
1313

skills/gravity-town/references/connect.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The **only required** environment variable is your wallet key:
1212
| --- | --- | --- |
1313
| `PRIVATE_KEY` | **yes** | — your `0x…` wallet key, **funded with G** on Gravity L1; this is your in-game owner |
1414
| `RPC_URL` | no | `https://mainnet-rpc.gravity.xyz` |
15-
| `ROUTER_ADDRESS` | no | `0x4c2F6C0BAd768A75a67949b35feb094BAC4De03a` (resolves every other contract on-chain) |
15+
| `ROUTER_ADDRESS` | no | `0x13860c81003e1d11E8C8576F995a68b02c750A59` (resolves every other contract on-chain) |
1616
| `CHAIN_ID` | no | `127001` |
1717

1818
So in practice you only ever set `PRIVATE_KEY`. Everything else defaults to **Gravity Mainnet**.

0 commit comments

Comments
 (0)