first release date:2022-07-05
latest revision date:2022-07-05
The Graph is a decentralized protocol for indexing and querying data from blockchains.
Dark Forest v0.6.5 is on gnosis chain (xdai) now.
Actually, we have subgraph for dark forest office test round v0.6.5.
So how to deploy a subgraph for lobby round?
Please notice: I don't think this is a elegant way to deploy, however it can work :-)
my computer OS is windows 10, and the CLI is PowerShell
1.download subgraph code
git clone https://github.com/darkforest-eth/eth.git
NOTICE: please make sure this code is only used for deploying subgraph, we will make lots of changes.
2.open file folder and download package dependencies.
cd eth
npm install
You may meet some error like
gyp ERR! find VS
gyp ERR! find VS msvs_version not set from command line or npm config
gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer, try re-running with '--loglevel silly' for more details
gyp ERR! find VS looking for Visual Studio 2015
gyp ERR! find VS - not found
gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
gyp ERR! find VS
gyp ERR! find VS **************************************************************
gyp ERR! find VS You need to install the latest version of Visual Studio
gyp ERR! find VS including the \"Desktop development with C++\" workload.
gyp ERR! find VS For more information consult the documentation at:
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
gyp ERR! find VS **************************************************************
....
Don't worry, you can just ignore them.
3.find the contract address and start block.
For example, the lobby address is : zkga.me/play/0xadc6d5ffda27525a725b01eb2199a546686c72b9
the contract address is : 0xadc6d5ffda27525a725b01eb2199a546686c72b9
the start block can find in gnosis chain's explorer
in the line of Creator 0x5da117–1a7145 at 0xce3501–c006f1
just click the right 0xce3501-c006f1 and go to
you will get the start block in the right of Block
, which is 22977361
So the start block is: 22977361
4.open eth/node_modules/@darkforest_eth/contracts/
change the contract address and start block in index.d.ts, index.js, index.js.map, index.ts.
The contract address and start block in those file before are for v0.6.5,
you just need to change them to your lobby.
5.find eth/hardhat.config.ts
and change the 37 line
//const { DEPLOYER_MNEMONIC, ADMIN_PUBLIC_ADDRESS } = process.env;
const DEPLOYER_MNEMONIC = 'change typical hire slam amateur loan grid fix drama electric seed label';
const ADMIN_PUBLIC_ADDRESS ='';
This is just to make yarn hardhat --xdai
can be used.
6.open file folder eth and input those command into CLI.
yarn subgraph:template:prod
This command will generate something into subgraph/subgraph.yaml
and you will see
Error: Command failed: npx graph codegen subgraph/subgraph.yaml
at ChildProcess.exithandler (node:child_process:399:12)
at ChildProcess.emit (node:events:526:28)
at ChildProcess.emit (node:domain:475:12)
at maybeClose (node:internal/child_process:1092:16)
at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5) {
killed: false,
code: 1,
signal: null,
cmd: 'npx graph codegen subgraph/subgraph.yaml',
stdout: "\x1B[31mENOENT: no such file or directory, open 'C:\\Users\\robot\\Desktop\\subgraph\\eth\\subgraph\\subgraph\\subgraph.yaml'\x1B[39m\n",
stderr: ''
}
don't worry, and you input the command into CLI
npx graph codegen subgraph/subgraph.yaml
and you will see
...
√ Load GraphQL schema from subgraph\schema.graphql
Write types to generated\schema.ts
√ Generate types for GraphQL schema
Types generated successfully
You will see generated/ in eth/, just move generated/ into eth/subgraph/
7.follow the graph's docs to store the access token And Add Subgraph
for example , your github name is goodboy, and the subgraph name is Play Dark Forest
then input below command int CLI
yarn subgraph:deploy:prod GoodBoy/play-dark-forest
if deploy successfully, you will see
Deployed to https://thegraph.com/explorer/subgraph/goodboy/play-dark-forest
Subgraph endpoints:
Queries (HTTP): https://api.thegraph.com/subgraphs/name/goodboy/play-dark-forest
Subscriptions (WS): wss://api.thegraph.com/subgraphs/name/goodboy/play-dark-forest
then you may need wait some time to wait for subgraph to snyc.
You can check the state in
https://thegraph.com/explorer/subgraph/goodboy/play-dark-forest
That's all, thanks for reading .
If you have any question, please feel free to connect with me :-)
my twitter @ddy_mainland.