Retrieving posts directly from Arweave
0xbDc4
April 4th, 2022

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.

Arweave TX
5wGxejc98wQ_OfEEjLmpkKa2k4YcPEcFecwCGOymh0U
Ethereum Address
0xbDc4199575A5FA3F19e9888C5d51Bde798F404Cc
Content Digest
GjssNdA6XK7VYynkvwDem3KYwPACSU9nDWpR5rei3hw