Как быстро задеплоить Subgraph: пошаговый чеклист функций в Power Shell

HEORHII YABLONSKYI
2 min readDec 9, 2020

В данной статье представлены шаги для создания сабграфа на Windows через Power Shell, запущенного от имени системного администратора.

Обратите внимание, что у вас должно быть установлено:

· Node.js (https://nodejs.org/en/)

· Git for Windows (https://gitforwindows.org/)

· Yarn for Windows with the installer (https://classic.yarnpkg.com/en/docs/install/#windows-stable)

Итак, вот тот чек-лист, с помощью которого можно выполняя функции быстро задеплоить сабграф на Tha Graph Explorer:

1. C:\WINDOWS\system32> Set-ExecutionPolicy RemoteSigned — Y

2. C:\WINDOWS\system32> Set-ExecutionPolicy Unrestricted -scope Process — Y

3. C:\WINDOWS\system32> npm install -g npm

4. C:\WINDOWS\system32> npm install -g npm-windows-upgrade

5. C:\WINDOWS\system32> npm install -g @graphprotocol/graph-cli

6. C:\WINDOWS\system32> cd /

7. C:\> cd D:\

8. D:\> graph init — from-contract 0xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

√ Subgraph name · 0001/0001
√ Directory to create the subgraph in · x-folder
√ Ethereum network · mainnet
√ Contract address · 0xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
√ Fetching ABI from Etherscan
√ Contract Name · xxxxxx
Result: Subgraph 0001/0001 created in x-folder

9. D:\> graph auth https://api.thegraph.com/deploy/ <access-token>
Result: Access token set for https://api.thegraph.com/deploy/ <access-token>

10. D:\> cd x-folder

11. D:\ x-folder > yarn codegen

12. D:\ x-folder > yarn build
Result: Build completed: D:\ x-folder\…\…\subgraph.yaml

D:\ x-folder > yarn deploy
Result: Deployed to https://thegraph.com/explorer/subgraph/0001/0001

--

--