> For the complete documentation index, see [llms.txt](https://hub.bsvblockchain.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hub.bsvblockchain.org/wiki/standards-protocols-and-tools/building-on-bitcoin/metanet-protocol.md).

# Metanet Protocol

The **Metanet Protocol** is a layer-2 overlay protocol that defines a method for creating data structure over Bitcoin SV. The protocol utilises nodes and edges to specify directed acyclic graph (DAG) data structures on the Bitcoin SV ledger. The Metanet protocol can be used to construct diverse systems such as file systems, internet domains, ownership structures and code repositories. There are tools available to write and read Metanet graphs, and a growing range of projects that use the Metanet protocol to structure their application data.

![typical Metanet graph.](/files/7QnT4pgZTxy9ucjoZi2m)

1. Node and Edge Structure The Metanet Protocol (MNP) is a protocol for creating graph structures comprising nodes and edges on the ledger. In the Metanet protocol the following definitions of node and edge are used:

* **Metanet Node** - A transaction using the Metanet protocol format.
* **Metanet Edge** - An input signature linking two Metanet nodes. A Metanet node is a transaction that conforms to the Metanet transaction format specified in the [Metanet technical summary](https://nchain.com/wp-content/uploads/2022/09/The-Metanet-Technical-Summary-v1.0.pdf) document produced by nChain. The basic components of a Metanet transaction include a protocol flag, Metanet-specific data attributes, and any content data that is to be stored by a Metanet node transaction. The protocol flag is a 4-byte \[] prefix that signifies that a transaction is using the format of the Metanet protocol. The hexadecimal value of the prefix was chosen to be the hexademical encoding 0x4d455441 of the string 'meta' by public poll on June 5th 2019. The Metanet-specific data attributes of a Metanet node transaction include the following:
* **P\_{node}** - the public key defining the node.
* **TxID\_{node}** - the unique transaction ID of the node.
* **P\_{parent}** - the public key defining a parent of the node.
* **SigP\_{parent}** - a signature created using the private key associated with the public key defining a parent of the node.
* **TxID\_{parent}** - the unique transaction ID of the parent of the node. The Metanet-specific data attributes listed above are used collectively to define a Metanet node and its position within a larger graph structure of multiple Metanet nodes, known as a **Metanet graph**. It is possible that a node does not have any parents and such a node is termed a *root node*. A root node will have null values for any P\_{parent}, SigP\_{parent}, and TxID\_{parent} attributes, and can therefore use a valid signature from any public key in its input(s). A Metanet transaction is defined as a transaction that contains an OP\_FALSE OP\_RETURN payload containing:
* The Metanet flag

![Metanet node transaction.](/files/vxrQkdKibWC0RV2naD5x)

* A node public key **P\_{node}**
* A parent transaction ID **TxID\_{parent}** (null if a root node). In order to qualify as a Metanet-valid node, the transaction must also be signed by the public key corresponding to its parent **P\_{parent}**. Any content data and its encoding can be included following these core Metanet attributes in the OP\_FALSE OP\_RETURN payload. The Metanet protocol does not specify the use of any one scheme for content data and additional attributes, and any valued usage of the Metanet protocol attributes above constitute a Metanet node transaction. A basic example of a Metanet node transaction that conforms to this format is shown in the diagram on the right. The Metanet graph is formed by creating edges between parent Metanet nodes and child Metanet nodes. An edge is created between a parent and child by the creation and insertion of the signature **SigP\_{parent}** in the child node, using the parent public key.

![creation of a Metanet edge.](/files/fUztGLlWFPvtZc29emul)

The fact that this signature is in a transaction input means that the signature itself may be validated by Miners. This means that attempts to spoof a Metanet node can be mitigated either by validating the signature explicitly or by confirming that the node is spending an appropriate previous output.

1. Rules of the Metanet Protocol The Metanet protocol specifies a simple and extensible rule set for creating Metanet graphs and data structures. The base rule set is the following:

* Nodes are transactions.
* Edges are created by signatures.
* Each node is uniquely identified by the pair of attributes: **P\_{node}**, **TxID\_{node}**.
* Each node must specify the node ID of itself and its parent: **ID\_{node}**, **ID\_{parent}**. The unique node identifier for a node is defined mathematically as **H(P\_{node}||TxID\_{node})**, where **H()** is a cryptographic hash function. Metanet graph structures may be created using this base rule set alone. It is also possible to impose additional rules to Metanet graph structures to achieve different properties for data structures. A simple extension of the rule set is to impose the following constraints:
* The in-degree of a node should be 0 (no parent) or 1 (one parent).
* The out-degree of a node should be a free parameter.

![simple Metanet rule set.](/files/KooAbmkMorJaKzOvXX3H)

These additional rules allow domain-like structures to emerge as Metanet DAGs, which can be used to structure websites and file systems which inherit the permission structure of a Metanet graph.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://hub.bsvblockchain.org/wiki/standards-protocols-and-tools/building-on-bitcoin/metanet-protocol.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
