-
For the scripts in
package.json
to work, you need to load your environment variables. The most convient way to doing this:- Copy
.env.example
to.env
, and check / change the desired values - run the scripts like this:
npx dotenv-cli yarn script-name
(the dotenv-cli will load the variables from the file named.env
defaultly)
- Copy
-
Start a local graph node: run
yarn compose-local-graph-node
(modify.env
file to configure ports and chain names/urls) -
Common scripts for subgraph development in
package.json > scripts
:-
compose-local-graph-node
: just a shortcut fordocker-compose up
for the docker-compose.local.yml file -
you most probably using these in this order:
generate-types
: generate the typescript types for the specified contract subgraph (controlled by theCONTRACT_NAME
env variable)generate-chain-specific-configs
: generate all the subgraph.${CHAIN_NAME}.yaml files for the specified contract subgraph (controlled by theCONTRACT_NAME
env variable) for all the specified chains (controlled by theCHAINS
env variable, or - if it's not presented - bychains
property insubgraph_infrastructure.yaml
)build
: build the subgraph for the specified contract subgraph and specified chain (controlled by theCONTRACT_NAME
andCHAIN_NAME
env variables)register
: register a subgraph in the graph node (controlled by theSUBGRAPH_NAME
andGRAPH_NODE
env variables),unregister
is the same, but for removing the registrationdeploy
: deploy the specified contract subgraph to the graph node (controlled by theSUBGRAPH_NAME
(need to be registered before),CONTRACT_NAME
,CHAIN_NAME
,IPFS_NODE
,GRAPH_NODE
,VERSION_LABEL
env variables)generate-build-deploy
: just a shortcut to run all the above scripts all at once
-
Keep the naming convention for new subgraphs for the scripts to be able to work: subgraphs/$ContractName/src/subgraph.yaml
.
- create a new folder with the exact name of the contract
subgraphs/$ContractName
- create an src folder inside it
subgraphs/$ContractName/src
- Create the
subgraph.yaml
and the schema and mapping files inside thesrc
folder (see the other subgraphs for examples) - Add the
generate-abis
script to the package.json (see the othergenerate-abis
scripts for examples)- create the
$contract-name:generate-abis
script - extend the
postinstall
script with it (so it will generate all the abis automatically when you install the dependencies)
- create the
- install dependencies
yarn install
- export AWS credentials
- run the deployment script
./scripts/deploy-public-chain.sh --chain-name ${chain_name} --contract-name ${contract_name}
Currently supported chains:
Polygon Mumbai
(id: polygon-testnet)Polygon zkevm
(id: polygon-zkevm)Arbitrum
(id: arbitrum)