This repo contains the code and configuration for Request Payment subgraphs:
Mainnets:
- Arbitrum One
- Avalanche
- Base
- BSC
- Celo
- Core - Hosted by CoreDAO
- Ethereum Mainnet
- Fuse
- Fantom
- Gnosis Chain (xDai)
- Mantle - Hosted by FusionX
- Moonbeam
- Near
- Optimism
- Polygon (Matic)
- zkSync Era
Testnets:
It indexes Request's proxy smart-contracts for easy querying of payment data.
Smart-contract addresses can be found here:
# setup variables
cp .env.sample .env # don't forget to edit the WEB3_URL and, if required, the NETWORK variable
# install dependencies
yarn
# generate ABIs & subgraph manifests, and generate types
yarn prepare
# Run a local Graph Node
docker-compose up -d
# Run
This requires the
@requestnetwork/smart-contracts
package to be deployed.
export NETWORK=my-network
# update to latest version
yarn add --exact @requestnetwork/smart-contracts@next
# add new network
cat <<< $(jq '. + [env.NETWORK] | unique' cli/networks.json) > cli/networks.json
# update CI (update deployment targets with cli/networks.json)
NETWORKS=$(cat ./cli/networks.json) yq e -i '.jobs.deploy.strategy.matrix.chain |= env(NETWORKS)' .github/workflows/deploy.yaml
# create Github Environment (for CI) based on mainnet
yarn subgraph configure-ci $NETWORK
The subgraphs manifests are automatically generated using the prepare script, which uses @requestnetwork/smart-contracts
NPM package to get the smart-contracts addresses.
One manifest can refer to many different versions of proxies dealing with the same payment network. The first version found is not explicitely mentionned in generated files and data sources naming. Example; EthProxy
implicitely refers to the version 0.1.0
. Further versions are referenced in this format: EthProxy_0_2_0
for the contract EthProxy
of abi version 0.2.0
.
Note: The
TransferWithReferenceAndFee
event is configured twice. That is because the Conversion proxy makes an internal call to the ERC20 Fee proxy. BothTransferWithReferenceAndFee
andTransferWithConversionAndReference
need to be parsed for the Conversion smart-contract.
export NETWORK=sepolia
yarn build
export NETWORK=sepolia
yarn create-local
yarn deploy-local
All deployments are semi-automated through GitHub action. The first time a subgraph is deployed, it needs to be created on the Graph Node or on Subgraph Studio.
Graph Node locations:
core
uses the Graph Node hosted by CoreDAOmantle
uses the Graph Node hosted by FusionXmantle-testnet
uses the Graph Node hosted by Mantle- all other chains use Subgraph Studio.
When a PR is merged on main
:
- test chains are deployed immediately, without approval
- mainnet chains require a manual approval in GitHub actions.
Important: Once a subgraph is deployed on Subgraph Studio, a manual action is required to publish it to the decentralized network. See the documentation for more information.
You can compare the code to the deployed version using one of these commands
# all
yarn subgraph compare
# one network
yarn subgraph compare NETWORK_NAME
# several networks
yarn subgraph compare NETWORK_NAME_1 NETWORK_NAME_2
{
payments {
txHash
gasPrice
contractAddress
block
amount
amountInCrypto
feeAmount
feeAmountInCrypto
feeAddress
tokenAddress
maxRateTimespan
reference
id
to
from
currency
}
}
Run one of these commands to check for indexing delays.
# all
yarn subgraph monitor
# one network
yarn subgraph monitor --network NETWORK_NAME
# several networks
yarn subgraph monitor --network NETWORK_NAME_1 NETWORK_NAME_2
Some networks will require you to set env vars:
export ALCHEMY_API_KEY=...
export INFURA_API_KEY=...
URL: https://api.thegraph.com/index-node/graphql Schema: https://github.com/graphprotocol/graph-node/blob/master/server/index-node/src/schema.graphql
http POST 'https://api.thegraph.com/index-node/graphql' query="{ indexingStatusForPendingVersion(subgraphName: \"requestnetwork/request-payments-sepolia\") { subgraph fatalError { message } nonFatalErrors {message } } }" | jq .data
You probably have an issue in the package resolution of assemblyscript
.
See next issue for resolution.
This is related to the fact TheGraph uses a very old version of assemblyscript (see This PR for migration to the latest version).
In the meantime, yarn cache clean
should resolve it.
Failed to fetch status for mainnet: could not detect network (event="noNetwork", code=NETWORK_ERROR, version=providers/5.7.2)
Need to set env var ALCHEMY_API_KEY or INFURA_API_KEY.