Retrieving posts directly from Arweave

All of Mirror’s posts are available to access on Arweave, an on-chain decentralized storage layer that makes it so that your posts exist forever (even if Mirror does not)!

Here’s a basic tutorial on how to get data published on Mirror directly from Arweave:

  1. Grab the Mirror content digest from the end of a Mirror post URL. The URL for this post is dev.mirror.xyz/GjssNdA6XK7VYynkvwDem3KYwPACSU9nDWpR5rei3hw and so the digest is GjssNdA6XK7VYynkvwDem3KYwPACSU9nDWpR5rei3hw
  2. We’re going to plug this digest value into a query against Arweave’s graphQL endpoint to render the data
  3. We’re going to make use of a couple of tags to get the Arweave transaction via GraphQL. Every post on Mirror has a few tags we can use to filter for the content:
    1. App-Name: MirrorXYZ tells Arweave to scope the results to all posts on Mirror
    2. Original-Content-Digest: GjssNdA6XK7VYynkvwDem3KYwPACSU9nDWpR5rei3hw tells Arweave to return every single transaction that matches the requested content digest
    3. By default, we upload every single published update on a post to Arweave, so the query returns a list. To get the most recently published update sent to Arweave, we just sort the results by block height and grab the newest transaction.
  4. Once, we have the Transaction ID we need, we can use the getData function in the Arweave JS SDK to render the JSON content
    1. We can also verify that we have the correct transaction ID navigating to arweave.net/<TRANSACTION_ID> which will render the JSON
    2. Our digest GjssNdA6XK7VYynkvwDem3KYwPACSU9nDWpR5rei3hw returns a transaction ID of dysIrCovgAHJ6siGA5_r27Q59j2tv5wD4kqc1bxRFVE, which renders the content you see here.

The GraphQL query is available as a gist here.

In order to bypass requiring content digests to populate Mirror posts, you can use the Contributor tag to query for all posts made by a specific wallet. A full list of available tags is available on the Transaction GraphQL object.

Subscribe to Mirror Development
Receive the latest updates directly to your inbox.
Verification
This entry has been permanently stored onchain and signed by its creator.