Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENS example: migrate from hosted subgraph #1975

Merged
merged 1 commit into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/content/data-feeds/ens.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ In Solidity, the address of the ENS registry must be known. According to [ENS do

ENS registry address: [0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e](https://etherscan.io/address/0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e).

Also, instead of using readable string names like `eth-usd.data.eth`, resolvers accept bytes32 hash IDs for names. Hash IDs can be retrieved from [this subgraph](https://thegraph.com/explorer/subgraph/ensdomains/ens) or via this npm package [eth-ens-namehash](https://www.npmjs.com/package/@ensdomains/eth-ens-namehash).
Also, instead of using readable string names like `eth-usd.data.eth`, resolvers accept bytes32 hash IDs for names. Hash IDs can be retrieved from [this subgraph](https://thegraph.com/explorer/subgraphs/5XqPmWe6gjyrJtFn9cLy237i4cWw2j9HcUJEXsP5qGtH) or via this npm package [eth-ens-namehash](https://www.npmjs.com/package/@ensdomains/eth-ens-namehash).

"ETH / USD" hash: `0xf599f4cd075a34b92169cf57271da65a7a936c35e3f31e854447fbb3e7eb736d`

Expand Down
21 changes: 12 additions & 9 deletions src/features/ens/components/EnsLookupForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,18 @@ export const EnsLookupForm = () => {
}`,
})

const response = await fetch("https://api.thegraph.com/subgraphs/name/ensdomains/ens", {
method: "post",
body: data,
headers: {
"Content-Type": "application/json",
"Content-Length": data.length.toString(),
"User-Agent": "Node",
},
})
const response = await fetch(
"https://gateway-arbitrum.network.thegraph.com/api/934b65a95f6dd6f3d9a468d9cdda9ec6/subgraphs/id/5XqPmWe6gjyrJtFn9cLy237i4cWw2j9HcUJEXsP5qGtH",
{
method: "post",
body: data,
headers: {
"Content-Type": "application/json",
"Content-Length": data.length.toString(),
"User-Agent": "Node",
},
}
)
const json = await response.json()
const hashName = json.data.domains[0] ? json.data.domains[0].id : "Not Found"

Expand Down