Skip to content

Instantly share code, notes, and snippets.

@saarim-mirror
Created April 4, 2022 19:20
Show Gist options
  • Save saarim-mirror/2605fda5baf8b428385c872f6eb5d6d5 to your computer and use it in GitHub Desktop.
Save saarim-mirror/2605fda5baf8b428385c872f6eb5d6d5 to your computer and use it in GitHub Desktop.
Query for Mirror Content on Arweave
// GraphQL query to get the Arweave transaction ID of a Mirror post
// With the transaction ID we can use `getData()` from the Arweave JS SDK, eg.
// arweave.transactions.getData('bNbA3TEQVL60xlgCcqdz4ZPHFZ711cZ3hmkpGttDt_U').then(data => { console.log(data); });
// We can use the explorer at https://arweave.net/graphql, which queries https://arweave.net/graphql to test it out
// With the transaction ID we can go to the URL `arweave.net/<YOUR_TRANSACTION_ID>` which will render the JSON
// More details on how this works on https://dev.mirror.xyz/GjssNdA6XK7VYynkvwDem3KYwPACSU9nDWpR5rei3hw
query GetMirrorTransactions($digest: String!) {
transactions(tags:[
{
name:"App-Name",
values:["MirrorXYZ"],
},
{
name:"Original-Content-Digest",
values:[$digest]
}
], sort:HEIGHT_DESC, first: 1){
edges {
node {
id
}
}
}
}
@coffeeandcrypto
Copy link

I had a whole thing written up about how this didn't work for me because of the $digest variable and then I discovered/remembered that there had to be a thing somewhere in the graphql explorer to put in variables. Once I figured that out everything worked great. Would ask/recommend that the original blog post be updated with how to use that query variable section to run this query so that everything works.

@k1ic
Copy link

k1ic commented Nov 9, 2022

query GetMirrorTransactions($digest: String = "3G_T7cCJpbGFeV94uj8N7n-Tv_De3eoFX7gN5qcv9ew") { transactions(tags:[ { name:"App-Name", values:["MirrorXYZ"], }, { name:"Original-Content-Digest", values:[$digest] } ], sort:HEIGHT_DESC, first: 1){ edges { node { id } } } }

@HappySean2845
Copy link

HappySean2845 commented Sep 2, 2024

RGW8X3ZWkLxCS4kc3eM7m1uHsAd5DXCD5AICzIIC7OQ
this digest cannot be retrieved from grapphql

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment