Instructions for Building Manifest
Understanding the Path Manifest Schema
Path Manifests are JSON objects and come with several key-value pairs. Each of these keys serves a specific purpose.
Mandatory Fields
manifest
: Type is string. This identifies that what you're creating is a path manifest for Arweave. It must be set toarweave/paths
.version
: Type is string. This tells us which version of the manifest specification you're using. As of now, it's0.1.0
. For future updates, just keep an eye on semver.paths
: Type is object. This is where the magic happens. It maps your subpaths to Arweave transaction IDs. Each subpath key has an associatedid
which is the transaction ID for that particular file or asset.
Optional Fields
index
: Type is object. This specifies what should happen when someone tries to access the manifest directly. If you set it, it must contain a behavior to adopt, which currently ispath
.index.path
: Type is string. If set, this is the default path that will load when the manifest is accessed. It must reference a key in thepaths
object, not a transaction ID.
Pro-Tips
Your path manifest transaction must only contain this JSON object.
The Content-Type tag must be set to
application/x.arweave-manifest+json
.
Example
Here’s a sample manifest JSON code snippet to illustrate how it all comes together:
In this example, if someone accesses the manifest directly, it will load index.html
by default. All the subpaths and their corresponding transaction IDs are clearly outlined in the paths
object.
And there you have it! You’ve now become proficient in crafting and understanding Path Manifests. In the next part of this tutorial, we will look at how to actually implement these Path Manifests into your Web3 projects. So, don’t go too far!
Understanding URL Resolution in Arweave Gateways
Applicability Scope
Note that the rules for URL resolution are specific to the /[:txid]
endpoint in Arweave gateways. These rules don't apply to /tx/[:txid]
endpoints.
URL Anatomy and Resolution
When a user requests a URL from an Arweave gateway, the gateway must first identify the manifest transaction ID (manifestId
) and the specified subpath. A typical Arweave URL might look like this:
Protocol:
https
Host:
arweave.net
Manifest ID:
dtOrr7JHEI6MTy9fqUJ48inydg4EiunfSzWRmCJ0KgS
Subpath:
css/style.css
Gateway Resolution Steps
Content-Type Verification: The gateway must first check the
Content-Type
of the page being requested. If theContent-Type
isapplication/x.arweave-manifest+json
, then further processing is needed; otherwise, the data is served as-is.Manifest Parsing and Validation: Next, the gateway parses the manifest transaction’s data and should verify its contents according to the schema described in the document.
Subpath Matching: The gateway searches the manifest for a key that corresponds to the requested subpath. If a match is found, the gateway responds with the transaction ID content specified in
manifest.paths[subpath].id
.HTTP Codes and Redirects: A
HTTP 200
status code should be returned if content is found. Redirects are not allowed; the user's URL must remain unchanged in the browser.Error Handling: If the manifest points to an invalid transaction ID or one that can’t be accessed, a
HTTP 404
status should be returned.Index Mapping: If a manifest is accessed directly (no subpath specified), and it has an
index.path
value, that value should be mapped to the manifest paths and resolved accordingly. Redirects toindex.path
are not allowed.Listing Available Paths: If no
index.path
is defined, the gateway should display a list of all validpaths
in a user-friendly HTML format.ETag
for Caching: ETag headers are important for caching. The ETag should be set to the transaction ID of the actual content, not the manifest, unless the manifest is being accessed without a subpath and no index is defined.
Examples
Here are some example scenarios based on hypothetical manifest files:
No subpath specified: The gateway will resolve to the data in
cG7Hdi_iTQPoEYgQJFqJ8NMpN4KoZ-vH_j7pG4iP7NI
asindex.html
is defined asindex.path
.Valid subpath specified: A request for
/mmJhKOPp2o73LXze05mj5qPVlgu4MsDzqCwpWKqoc7U/assets/img/logo.png
would return the content atQYWh-QsozsYu2wor0ZygI5Zoa_fRYFc8_X1RkYmw_fU
.Invalid subpath: A request for a non-existing path like
/mmJhKOPp2o73LXze05mj5qPVlgu4MsDzqCwpWKqoc7U/path/does/not/exist.txt
will return aHTTP 404
.No default index defined: If no
index.path
is present, the gateway will display an HTML page listing all valid paths available in the manifest.
By understanding these resolution rules, you’ll be better equipped to interact with the Arweave decentralized web, whether you’re a developer or an end user.
Last updated