This repo contains the code and configuration for Request Payment subgraphs:
Mainnets:
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 MantleWhen a PR is merged on main
:
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
TS6054: File '~lib/allocator/arena.ts' not found.
You probably have an issue in the package resolution of assemblyscript
.
See next issue for resolution.
Couldn't find match for ...
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.
Need to set env var ALCHEMY_API_KEY or INFURA_API_KEY.