How to do?
- Create node server
- Fetch events or state data throw RPC or Subscribe events.
- Save data to db
this is not optimal:
- Doesn't work for already deployed contracts.
- Extra gas costs for storing those values.
- Requires another call to fetch the data for an Ethereum node.
Learn: https://thegraph.com/ecosystem/learn/
-
Build faster 100% less servers
Create groundbreaking applications without needing to run your own data server, build indexing infrastructure, or parse through raw data.
-
Spend less 60-98% less per month
Cut down on costs and time spent running expensive infrastructure by tapping into The Graph’s competitive data market.
-
Increase resilience 99.99%+ uptime
Ensure your application’s uptime and keep its data flowing 24/7 with a globally distributed network of contributors.
-
Site: https://graphql.org/
-
Example:
-
call GraphQL: https://graphql.org/graphql-js/graphql-clients/
fetch("/graphql", {
method: "POST",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
},
body: JSON.stringify({ query: "{ hello }" }),
})
.then(r => r.json())
.then(data => console.log("data returned:", data))https://thegraph.com/docs/en/developing/creating-a-subgraph/
Public RPC Node: https://ethereum-sepolia.publicnode.com
- Deploy Contract
- Get ABI
- Create Subgraph project
- Graph init
- Graph codegen & graph build. & grpah deploy
- Example: https://api.studio.thegraph.com/proxy/64062/mybank/v0.0.3/graphql
- Contract Address: 0x3FD542687000843F7B1d79945E8D1b7B44c09FD1
- Add new contract (
grpah add) - Query: call by http (GraphQL)
