How to Deploy and Use Subgraphs on Mantle Network
07/10/234 min read
✅ Make sure you have Foundry installed and set up in your local environment before moving forward! Check out Foundry's GitHub for more help with installation on your system.
1 git clone https://github.com/mantlenetworkio/mantle-example-subgraph.git
graph-cliutility required to deploy subgraphs.
1 bin/forge create --legacy --rpc-url https://rpc.testnet.mantle.xyz \ 2 --private-key 0x... \ # wallet private key to pay gas fees 3 --from 0x...\ # address used to deploy 4 contracts/Gravity.sol:GravatarRegistry # contract path 5 6 Deployer: 0x00000500E87eE83A1BFa233512af25a4003836C8 7 Deployed to: 0x1de239E2D98dea46C10D6D14F5E9EB427fdE6059 8 Transaction hash: 0x4cf8fa85b6cb253cf8222c0863eea3607b31c5c168a9170262723077d674eb22
startBlockvalues specific to your contract to the
subgraph.yamlfile in the main directory.
1 source: 2 address: # your contract address 3 abi: # name assigned to the contract ABI file, path defined under abis 4 startBlock: # block number for your contract deployment transaction
1 yarn codegen 2 yarn deploy-testnet
Querying the Subgraph
1 bin/cast send --legacy --rpc-url https://rpc.testnet.mantle.xyz \ 2 --private-key 0x.. \ # wallet private key to pay gas fees 3 --from 0x.. \ 4 0x1de239E2D98dea46C10D6D14F5E9EB427fdE6059 \ # your contract address 5 "createGravatar(string,string)" "Alice" "https://google.com/a.jpg" # function call from your contract
📖 You can refer to the Graph endpoint reference to see the endpoint URLs that can be used to interact with the graph service deployed on Mantle testnet.