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

[Proposal] Integrate Gateway as a Data Provider #1434

Open
ZKentin opened this issue Mar 3, 2023 · 9 comments
Open

[Proposal] Integrate Gateway as a Data Provider #1434

ZKentin opened this issue Mar 3, 2023 · 9 comments
Labels
Data Provider Contribute to Sismo Hub by creating a new Data Provider

Comments

@ZKentin
Copy link

ZKentin commented Mar 3, 2023

Integrate Gateway as a Data Provider will enable to create new Groups from holders of a specific Gateway Credential NFT.

Specifications

{
  "name": "Gateway",
  "iconUrl": "",
  "providerClassName": "GatewayProvider",
  "functions": [
    {
      "name": "Get holders of credential NFT",
      "functionName": "TODO",
      "countFunctionName": "TODO",
      "description": "Returns all holders of a specific Gateway credential",
      "args": [
        {
          "name": "credential",
          "argName": "TODO",
          "type": "string",
          "required": "true",
          "example": "TODO",
          "description": "A specific credential identifier"
        }
      ]
    },
    {
      "name": "Get holders of organization",
      "functionName": "TODO",
      "countFunctionName": "TODO",
      "description": "Returns all holders of any Gateway credential of a specific organization",
      "args": [
        {
          "name": "organization",
          "argName": "TODO",
          "type": "string",
          "required": "true",
          "example": "TODO",
          "description": "A specific organization identifier"
        }
      ]
    }
  ]
}

Tips on how to integrate the Data Provider

Gateway NFTs are non-transferrable ERC-721 NFTs minted on Polygon with this contract address.

They don’t have an API, so the easiest way to extract the list of addresses is by using BigQuery & Arweave.

Have a look at Sismo documentation to understand what is a Data Provider, and checkout the tutorial to know how to integrate a Data Provider.

Have fun!

@ZKentin ZKentin added the Data Provider Contribute to Sismo Hub by creating a new Data Provider label Mar 3, 2023
@sampolgar
Copy link
Contributor

sampolgar commented May 10, 2023

Notes

  1. The Gateway metadata (Credential Name, Credential Type, Organization Id) are metadata of the Gateway NFT as available here.
  2. There are currently 762,000 NFTs issued
  3. We will probably need to use something that indexes data like Dune or The Graph

@MartinGbz
Copy link
Contributor

Agree with this, again The Graph well be more welcomed than Dune 😅
But I think as it is specified in the issue: using BigQuery + Arweave seems ok to me isn't it?

@sampolgar
Copy link
Contributor

I had a quick look on BigQuery, we can query the token_transfers which returns an array of objects like this:

{
  "token_address": "0x506402dbeeec75b2425d80b6f51e806684fd9f40",
  "from_address": "0x0000000000000000000000000000000000000000",
  "to_address": "0x5187c076ed0f393ead95d8f74c6ee98b12c08282",
  "value": "764065",
  "transaction_hash": "0xb7650d28e137bc39812e9953b6c15554bcb2d88e67fc55ee966641dad090d301",
  "log_index": "89",
  "block_timestamp": "2023-05-20 04:24:58.000000 UTC",
  "block_number": "42921051",
  "block_hash": "0x631a3bc77d94e428257dfcaebe74a48a2a6733868c88b0cb44c5bb9bd4bf8114"
}

Here we have the owner and tokenId but not the Credential Name, Credential Type, or Organization Id. Not sure how to use Arweave as it looks like these NFT's don't have metadata stored on Arweave.

Do you know how I can use BigQuery + Arweave?

@MartinGbz
Copy link
Contributor

By using BigQuery (especially the getAllTransactionsForSpecificMethod of the BigQuery Provider) you can get fetch all NFT mints, and get so these 2 arguments:
Capture d’écran 2023-05-21 à 21 58 08
So with the tokenURI_ (https://tws5ihsn6k6tlq5zd3re62mbwuzh6tp4pfie6rfxeajb34jipnlq.arweave.net/naXUHk3yvTXDuR7iT2mBtTJ_Tfx5UE9EtyASHfEoe1c) you can have all these info stored (including the attributes) on Arweave.
So it seems possible to do it, but I don't know if it's so scalable (but it worth to test it).

@sampolgar
Copy link
Contributor

Awesome, thanks @MartinGbz, I'll have a play with the BigQuery, it looks like we just need to add a node env GOOGLE_APPLICATION_CREDENTIALS to run it locally?

RE Arweave - it seems some NFT metadata is stored on Arweave and some isn't
(results from the Alchemy getNFTMetadata query)
e.g. the Piggylet Podcast is on Arweave

{ "contract": { "address": "0x506402dbeeec75b2425d80b6f51e806684fd9f40" }, "id": { "tokenId": "762000", "tokenMetadata": { "tokenType": "ERC721" } }, "title": "Piggylet Podcast: Episode 12", "description": "Hey, lads'n'lasses. Welcome to Piggylet Podcast! Every week we share stats about NFT-Backed Lending, NFT sales, news about both cryptocurrencies and NFTs, and of course development notes of our NFT-Backed Lending Platform, Piggylet. You can claim your Piggylet Podcast Credential NFT for each episode!", "tokenUri": { "gateway": "https://arweave.net/i52Llq7NGbUlwN66CM_h4Ovct1-blli6sm8qw0Gws34", "raw": "https://arweave.net/i52Llq7NGbUlwN66CM_h4Ovct1-blli6sm8qw0Gws34" }, "media": [ { "gateway": "https://nft-cdn.alchemy.com/matic-mainnet/b2affa6e572103c6dd0d6010e8208d1a", "thumbnail": "https://res.cloudinary.com/alchemyapi/image/upload/thumbnailv2/matic-mainnet/b2affa6e572103c6dd0d6010e8208d1a", "raw": "https://node.mygateway.xyz/storage/file?id=d60740ad-8bc1-49cf-954a-87ebc700cf85", "format": "jpeg", "bytes": 462428 } ], "metadata": { "image": "https://node.mygateway.xyz/storage/file?id=d60740ad-8bc1-49cf-954a-87ebc700cf85", "issuanceDate": "2023-05-11T05:11:39.423Z", "name": "Piggylet Podcast: Episode 12", "description": "Hey, lads'n'lasses. Welcome to Piggylet Podcast! Every week we share stats about NFT-Backed Lending, NFT sales, news about both cryptocurrencies and NFTs, and of course development notes of our NFT-Backed Lending Platform, Piggylet. You can claim your Piggylet Podcast Credential NFT for each episode!", "attributes": [ { "value": 7, "trait_type": "Number of Tasks" }, { "value": "Piggylet Podcast: Episode 12", "trait_type": "Credential Name" }, { "value": "de458a10-025a-4f5a-8e8f-3d848b5de0e5", "trait_type": "Organization ID" } ], "proof": { "proofPurpose": "assertionMethod", "type": "HS256", "proofValue": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkZXNjcmlwdGlvbiI6IkhleSwgbGFkcyduJ2xhc3Nlcy4gV2VsY29tZSB0byBQaWdneWxldCBQb2RjYXN0ISBFdmVyeSB3ZWVrIHdlIHNoYXJlIHN0YXRzIGFib3V0IE5GVC1CYWNrZWQgTGVuZGluZywgTkZUIHNhbGVzLCBuZ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4gcGhyYXNlISBXZSdsbCBwcm92aWRlIGEgd2FybmluZyBkdXJpbmcgdGhlIHBvZGNhc3QganVzdCBiZWZvcmUgd2UgcmV2ZWFsIHRoZSBzZWNyZXQgcGhyYXNlIG9uIHRoZSBzY3JlZW4sIHNvIHN0YXkgYWxlcnQhIFRoZXJlIGFyZSBubyBjYXBpdGFsIGxldHRlcnMuIiwidGFza190eXBlIjoibWVldGluZ19jb2RlIiwiY29tcGxldGVkIjp0cnVlfV0sImF0dHJpYnV0ZXMiOlt7InRyYWl0X3R5cGUiOiJOdW1iZXIgb2YgVGFza3MiLCJ2YWx1ZSI6N30seyJ0cmFpdF90eXBlIjoiQ3JlZGVudGlhbCBOYW1lIiwidmFsdWUiOiJQaWdneWxldCBQb2RjYXN0OiBFcGlzb2RlIDEyIn0seyJ0cmFpdF90eXBlIjoiT3JnYW5pemF0aW9uIElEIiwidmFsdWUiOiJkZTQ1OGExMC0wMjVhLTRmNWEtOGU4Zi0zZDg0OGI1ZGUwZTUifV0sImlhdCI6MTY4Mzc4MTg5OX0.a6bIV1RkirakeaOcIcHuLkimJbJQ_um3g6_2kgiV4P0", "created": "2023-05-11T05:11:39.423Z" }, "proofOfWork": [ { "description": "YouTube is one of the best places to listen to the Piggylet Podcast! Don't miss any episodes by subscribing to Piggylet's YouTube channel and hitting the bell button!", "completed": true, "title": "Subscribe Piggylet's Channels and Watch/ Listen Piggylet Podcast: Episode 12", "task_type": "self_verify" }, { "description": "To reach Piggylet Discord, you need a link, so here it is!", "completed": true, "title": "Piggylet Discord Invitation Link", "task_type": "self_verify" }, { "description": "Follow us and together let's democratize NFT-Backed Lending solutions!", "completed": true, "title": "Follow @piggyletdefi", "task_type": "twitter_follow" }, { "description": "Share Piggylet Podcast with your friends!", "completed": true, "title": "Retweet Piggylet Podcast: Episode 12", "task_type": "twitter_retweet" }, { "description": "Show your love to Piggylet Podcast!", "completed": true, "title": "Like Piggylet Podcast: Episode 12", "task_type": "twitter_like" }, { "description": "There are more channels to connect with Piggylet!", "completed": true, "title": "Piggylet Website and more!", "task_type": "self_verify" }, { "description": "Watch or listen to Episode 12 of the Piggylet Podcast to discover the hidden phrase! We'll provide a warning during the podcast just before we reveal the secret phrase on the screen, so stay alert! There are no capital letters.", "completed": true, "title": "Enter the Hidden Phrase", "task_type": "meeting_code" } ] }, "timeLastUpdated": "2023-05-11T22:50:52.087Z", "contractMetadata": { "name": "Credential NFT", "symbol": "GNFT", "tokenType": "ERC721", "contractDeployer": "0x47640c1cca02c8209e989e02625e303e0a52406a", "deployedBlockNumber": 31814028, "openSea": { "lastIngestedAt": "2023-05-16T13:54:08.000Z" } }, "spamInfo": { "isSpam": "true", "classifications": [ "NoSalesActivity", "HighAirdropPercent" ] } }

or this is on Pinata

{ "contract": { "address": "0x506402dbeeec75b2425d80b6f51e806684fd9f40" }, "id": { "tokenId": "76400", "tokenMetadata": { "tokenType": "ERC721" } }, "title": "Goldfinch FAQ", "description": "This credential shows that you have read our Goldfinch FAQ in Discord and understand the basics about Goldfinch.", "tokenUri": { "gateway": "https://alchemy.mypinata.cloud/ipfs/Qme2k4PccAxsJZ2mBy1hDNfwMsNR7gzqRTvjGfQMBzDix9", "raw": "ipfs://Qme2k4PccAxsJZ2mBy1hDNfwMsNR7gzqRTvjGfQMBzDix9" }, "media": [ { "gateway": "https://nft-cdn.alchemy.com/matic-mainnet/f15537550d34da8bf82ee35ec4b2f84b", "thumbnail": "https://res.cloudinary.com/alchemyapi/image/upload/thumbnailv2/matic-mainnet/f15537550d34da8bf82ee35ec4b2f84b", "raw": "https://node.mygateway.xyz/storage/file?id=63d67262-79e3-4ccf-9061-e1d233057e3a", "format": "jpeg", "bytes": 1041301 } ], "metadata": { "image": "https://node.mygateway.xyz/storage/file?id=63d67262-79e3-4ccf-9061-e1d233057e3a", "issuanceDate": "2022-10-22T02:11:23.019Z", "name": "Goldfinch FAQ", "description": "This credential shows that you have read our Goldfinch FAQ in Discord and understand the basics about Goldfinch.", "attributes": [ { "value": 2, "tr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dsaFggoCyw9zQkt29cu8XvmvkApbwqLGY", "created": "2022-10-22T02:11:23.019Z" }, "proofOfWork": [ { "description": "Read the FAQ Channel", "completed": true, "title": "Read our FAQ in the Goldfinch Discord Channel", "task_type": "self_verify" }, { "description": "Goldfinch would like to test your knowledge on our FAQ.\n\nYou must answer 10 out of 10 questions right!", "completed": true, "title": "Have you read our FAQ?", "task_type": "quiz" } ] }, "timeLastUpdated": "2023-04-16T04:03:44.882Z", "contractMetadata": { "name": "Credential NFT", "symbol": "GNFT", "tokenType": "ERC721", "contractDeployer": "0x47640c1cca02c8209e989e02625e303e0a52406a", "deployedBlockNumber": 31814028, "openSea": { "lastIngestedAt": "2023-05-16T13:54:08.000Z" } }, "spamInfo": { "isSpam": "true", "classifications": [ "NoSalesActivity", "HighAirdropPercent" ] } }

@MartinGbz
Copy link
Contributor

Hey @sampolgar, in order to use BigQuery, you need to have a Google Cloud account and run this command gcloud auth login (no need to use the GOOGLE_APPLICATION_CREDENTIALS)

Regarding your remark: but here you are comparing 2 different NFTs, so that's normal, maybe the second one don't have attributes at all (it seems possible isn't it?)

@sampolgar
Copy link
Contributor

Ok, I think we're stuck, can we meet to discuss how we will do this?

Here is what I see:

On Chain Data
We can use TheGraph or BigQuery to query the onchain data

  • TokenId
  • NFT URI (Arweave or IPFS link)

Off Chain Data
Seems we have 2 options to fetch metadata

  1. query Arweave & IPFS
  2. query Alchemy

There are over 750 000 NFTs minted, so querying Arweave/IPFS would be a 1 to 1 query (query 750000 times) or querying Alchemy is 65 NFTs at a time

We should definitely cache the results somewhere and query on a schedule, etc.

@sampolgar
Copy link
Contributor

sampolgar commented May 24, 2023

An update - the Alchemy SDK supports async queries & rate-limit handling. This would significantly reduce the time to bulk query the endpoint.
I'll test it soon
Rate limit
SDK

edit
ANKR supports 90 000 RPC call per minute (this is still about 10 minutes for Gateway) ANKR rate limit

@MartinGbz
Copy link
Contributor

📢 Recap and Current State of the Issue - Integrate Gateway as a Data Provider

  • There are over 750 000 NFTs minted
  • NFTs are onchain
  • NFT metadata ara off chain on Arweave
  • The link between NFT and their metadata is a Arweave link write on chain

🔍 Solution found

  • Solution1: Query with BigQuery each token and then query one by one the NFT metadata on Arweave => It seems not to be so scallable, but nobody try this method so maybe it can works well.
    The perfect solution would be to cache NFT metadata in order to not retrieve it each time.
  • Solution2: Use Ankr, or Alchemy that they have surely a cache system on their side, so we can get easily the NFT holders and their metadata. In the Sismo Hub
    • We don't have an Alchemy premium account so we are rate limited
    • We have an Ankr premium account so we can do 90000 call per minute

👉 Next Steps

Implement one of these 2 solutions
Looking forward to getting this integration finalized.

If there are any further suggestions or ideas, please share them here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Data Provider Contribute to Sismo Hub by creating a new Data Provider
Projects
None yet
Development

No branches or pull requests

3 participants