# About Context Protocol

Context is an AI-Ready, Decentralized Semantic Name Service to organize and verify real-world data in Web3 Storage.

<figure><img src="https://2383774531-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FecjUZkkkzTibDqjoS6JO%2Fuploads%2FzetkLUx14AyoHa9aDIaX%2Fog-v2.png?alt=media&amp;token=fbcb62ac-67e7-4b91-86e6-e37a2ff1e71a" alt=""><figcaption></figcaption></figure>

The global internet infrastructure lacks a standardized way to verify and distribute trusted data for AI interactions, leading to billions in losses from fake data and delayed AI adoption.

Context Protocol transforms how we verify and organize **real-world data for AI interactions**. Our innovative L2 blockchain provides the trust layer for the AI-powered internet, enabling authority-verified data spaces with real-time updates and permanent traceability. Through our semantic data structure and comprehensive developer tools, we ensure data verification, compliance, and seamless AI integration for developers, while enabling trusted autonomous interactions at scale.

> We're not just verifying data; we're building the foundation for trusted AI interactions.

At Context we offer:

* Semantic data organization optimized for AI
* Authority-verified blockchain infrastructure ensuring trust and compliance
* Web3 storage with permanent traceability and version control
* Cross-chain compatibility for seamless data verification
* Complete developer toolkit for building trust-native applications


# Why Context Protocol?

## **AI trust crisis: a critical infrastructure gap**

* **Unverified AI decisions:** today's AI agents make billions of autonomous decisions using unverified data, resulting in $406M annual losses and 41% of companies delaying AI adoption due to trust concerns.
* **No infrastructure for trust:** current systems lack the foundation needed for trusted AI interactions, creating systemic risks as AI agents trade and interact using fake or outdated data.
* **Real-time verification missing:** without instant verification infrastructure, AI-powered markets risk catastrophic failures and cascading errors that become impossible to recover from.
* **No semantic context:** traditional systems fail to provide the semantic organization needed for AI to understand and verify data context, limiting the potential of autonomous interactions.
* **Not Searchable Data:** Traditional DNS focuses only on domains, not on individual documents, **making it harder to find and access data**, especially in Web3 where it’s hidden behind hashes. This restricts the  ability to perform precise data searches.

### &#x20;**From Verification to AI Agents**

Context Protocol provides developers with infrastructure to build trusted interactions at any scale - from simple authority verification to complex autonomous systems. Whether you're building for industries, organizations, or AI agents, our tools enable you to create trust-native applications. Here's your development progression with Context:

**Build Today: Data Verification Infrastructure**

* Create verifiable data endpoints with permanent traceability
* Set up real-time data update systems with blockchain verification
* Deploy semantic data structures optimized for AI consumption
* Integrate authority-verified data sources into your applications
* Build cross-chain data verification systems

**Build Verified Knowledge Domains**

* Create semantic knowledge bases with authority verification
* Deploy industry-specific ontologies and taxonomies
* Build structured data hierarchies with real-time updates
* Create verified reference libraries for specific sectors
* Deploy machine-readable, verified documentation systems

**Build AI-Ready Applications**

* Create RAG systems with verified knowledge bases
* Develop applications that train on authenticated data sources
* Build retrieval systems with real-time data verification
* Deploy AI applications with traceable data lineage
* Integrate verified data streams for AI model inputs

**Build for the Agent Economy**

* Create trusted agent-to-agent interaction systems
* Deploy autonomous agents with verified data access
* Build agent marketplaces with built-in data verification
* Develop multi-agent systems with trusted data exchange
* Create agent-based applications with real-time verification

### Benefits of Using Context Protocol

**1. Real-Time Trust Verification**

* Deploy instant verification for any data update
* Enable trusted autonomous interactions at scale
* Build applications with built-in authority validation

**2. Permanent Traceability**

* Track every data change with blockchain-backed history
* Access complete lineage of information updates
* Build systems with auditable data trails

**3. Developer-First Infrastructure**

* Comprehensive SDK for trust-native development
* Standardized APIs for verification integration
* Ready-to-use smart contract templates
* Cross-chain compatibility out of the box

**4. Semantic Knowledge Structure**

* Deploy structured data optimized for AI consumption
* Create verified knowledge domains for any industry
* Build RAG systems with trusted information sources

**5. Authority Framework**

* Create and manage verified authorities
* Deploy industry-specific verification standards
* Build trusted reputation systems

**6. Real-Time Updates**

* Enable instant data verification and distribution
* Deploy systems with immediate trust validation
* Build applications with live data integrity

**7. AI Agent Ready**

* Create trusted agent-to-agent interactions
* Deploy verified data streams for AI consumption
* Build autonomous systems with built-in trust

**8. Future-Proof Architecture**

* Scale from simple verification to complex AI systems
* Build for the emerging agentic economy
* Deploy solutions ready for autonomous interactions


# Verified AI-Ready Domains (VARD)

**Verified AI-Ready Domains** enable authorities of any kind (institutions, associations, clusters, DAOs) to In the emerging AI economy, organizations need verified knowledge spaces where AI can interact with trusted data. VARD enables this through two paths:

Domain Authorities (like governments, associations, or DAOs) can create verified knowledge spaces where they set the verification standards. For example, Barcelona city council could manage .bcn, verifying organizations within their ecosystem.

Organizations seeking verified presence can:

* Request their own domain under an existing authority (example: restaurant.bcn)
* Join global domains through verification processes
* Participate in industry-specific domains

Once verified, organizations maintain full sovereignty over their data, choosing what to make public or private. They can update their knowledge space just as they would update a website today, but with the added trust layer that enables AI interactions.

VARD serves two key user groups:

**1. Domain Authorities**

* Create and manage verified knowledge spaces
* Can be institutions, associations, clusters, DAOs, or recognized industry bodies
* Verify organizations within their domain
* Define verification standards and processes
* Control their domain's structure and governance

**2. Organizations Seeking Verified Domains**

* Request domains from relevant authorities
* Maintain sovereignty over their data (public/private)
* Use Context agents to:
  * Update real-time verified data for AI consumption
  * Verify their supply chain and partners
  * Upload and verify products/services
  * Share public knowledge bases
  * Manage private verified information

All data within VARD becomes part of a growing knowledge graph where:

* Information is semantically structured for AI
* Updates are verified in real-time
* Changes maintain permanent traceability
* Organizations control their data privacy
* Verification flows through relationships

This creates an evolving, verified knowledge ecosystem that enables trusted AI interactions while respecting both authority verification and organizational autonomy.


# Training AI with verified data

### Real-time Vector Database to expand AI capabilities

Our advanced vector database is **key to training trustworthy AI models**.&#x20;

Context Protocol enables AI systems to train and operate with verified data sources in real-time. By providing semantically structured, authority-verified information, we ensure AI agents can:

* Access trusted, current data for decision-making
* Build knowledge bases from verified sources
* Retrieve information with guaranteed authenticity
* Update their understanding in real-time
* Maintain traceability of all data sources

Our semantic structure transforms raw verified data into AI-ready knowledge, enabling:

* Reliable RAG systems with verified sources
* Trusted agent-to-agent interactions
* Real-time knowledge updates
* Traceable information lineage
* Authority-verified information retrieval

This creates a foundation where AI can operate with confidence, knowing every piece of information is verified and traceable to its source.

<figure><img src="https://2383774531-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FecjUZkkkzTibDqjoS6JO%2Fuploads%2Fj3Q7WSb58hVyj1o1JC83%2FCaptura%20de%20pantalla%202024-11-03%20a%20les%2013.07.48.png?alt=media&amp;token=52c6ac2c-9a0e-4f12-a924-4ca4023de69f" alt=""><figcaption></figcaption></figure>


# SaaS Solution

**SaaS Platform: Making Verified Data Simple**

We've transformed complex blockchain and verification infrastructure into an intuitive platform that enables organizations to create trusted AI-ready knowledge domains without dealing with the underlying complexity. Our SaaS solution makes it easy to:

For Cities:

* Deploy verified city knowledge domains instantly
* Enable AI agents to interact with real-time city data
* Create trusted city services with built-in verification
* Foster an ecosystem of innovative AI applications
* Build smart city solutions with verified data at their core

For Organizations:

* Manage verified data through natural conversations
* Update information by simply chatting with AI agents
* Control public and private knowledge spaces through chat
* Integrate verified data seamlessly into AI applications
* Monitor AI agent interactions in real-time

Built for EU AI Act Compliance:

* Automatic documentation of data sources and changes
* Complete traceability of AI training data
* Real-time verification of data authenticity
* Permanent audit trails for all AI interactions

All the power of blockchain verification and semantic organization, without the complexity. Organizations interact with their data as naturally as having a conversation, while our platform handles the technical infrastructure behind the scenes.


# Technology behind Context

<figure><img src="https://2383774531-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FecjUZkkkzTibDqjoS6JO%2Fuploads%2FuRRdYDMASTzex6BLoSVN%2FCaptura%20de%20pantalla%202024-11-03%20a%20les%2012.03.01.png?alt=media&amp;token=5cc23492-72bf-456d-bb07-cfc94dc96f20" alt=""><figcaption></figcaption></figure>

### Application Layer

This layer enables users and enterprises to manage domains, query data, and anyone to interact with the DNS3 ecosystem. Additionally, the Application Layer supports the integration of third-party applications via our **SDK** or **Public Gateway**, allowing developers to easily connect their services with DNS3. For companies, this layer also includes a **Dashboard (SaaS)** that offers comprehensive tools for managing and monitoring their domains and data within the Web3 environment.

### Abstraction Layer

Using **MongoDB Atlas**, DNS3 implements a semantic caching system that temporarily stores frequently accessed queries and semantically enriched responses, significantly reducing response times. We also create a Vector Search that supports AI training, particularly Retrieval-Augmented Generation (RAG), enhancing the accuracy and efficiency of AI models by providing them with real-time, structured data. Additionally, account abstraction is handled through **Biconomy**, allowing for the creation of smart wallets for users, making interactions with the blockchain effortless and user-friendly.

### Integration Layer

This layer manages the deployment of **multiple smart contracts (Top-Level Domain “TLD” Registry)** across different blockchains, ensuring that they are interoperable and can communicate effectively. By leveraging **LayerZero**, DNS3 ensures that contracts can interact seamlessly between chains, allowing for a truly decentralized and interconnected Web3 environment.

### Storage Layer

The Storage Layer integrates multiple Web3 storage solutions to handle both public and private data. For public data, DNS3 connects with decentralized storage networks like **Arweave**, **BNB Greenfield**, or **Swarm**, ensuring that data is distributed and securely stored across the network. For private data, DNS3 supports encrypted solutions like **Ten Protocol**, allowing sensitive information to be stored securely and accessed only by authorized parties.


# $TEX Token

Our token’s value is directly fueled by the community’s engagement and innovation, **mirroring Ethereum's model** where increasing utility and ecosystem growth drive its worth. The token is used for **transactional fees tied to document updates**, creating a sustainable economic model for protocol services.

The token serves multiple purposes within the protocol, such as powering the multi-chain registry, where it helps manage decentralized domains across networks.

Token holders can participate in governance, influence decisions around TLD management, and **help secure the network through validator staking on our future AppChain**. These features, along with mechanisms like SaaS subscription buybacks, drive demand and value, making the token an integral part of our decentralized ecosystem.


# Multi-chain token

{% hint style="info" %}

#### Under Construction

We're working on this section and it will be available soon. Thanks for your patience!
{% endhint %}


# Token Utility

The $TEX token serves as a versatile utility token within the Context ecosystem, primarily used as a means of payment for interactions with the registry. When a user interacts with the registry, such as registering or updating data, they will be required to pay a small fee in $TEX. This fee will be split between the protocol, the template to which the interaction refers, and potentially a frontend that originated the interaction. This split ensures that the protocol is adequately supported, and that the schemas and frontends that are used are rewarded for their contributions, creating an incentive for the continuous development and maintenance of high-quality schemas and frontends. This, in turn, supports the overall growth and sustainability of the Context ecosystem.

In addition to these transactional fees, the $TEX token will play a crucial role in the staking mechanism for domain verifications within the DNS3 system. Token holders will be able to stake $TEX to participate in verifying and securing domain names within the decentralized DNS3 framework. This staking process not only ensures the integrity and reliability of the DNS3 system but also rewards participants with incentives for their contributions to maintaining this vital infrastructure.

Furthermore, $TEX tokens will be essential for maintaining the future Context L2/L3 network. As Context evolves into a more complex and scalable system, an AppChain will be developed to handle the growing number of transactions and interactions within the ecosystem. Token holders will be able to stake $TEX to help secure and validate transactions on this AppChain, ensuring its smooth operation and robustness. Stakers will be rewarded for their role in upholding the network, further aligning incentives with the long-term success of Context.

Overall, the $TEX token is designed to be deeply integrated into the various layers of the Context ecosystem, from transactional interactions with the registry and DNS3 system to staking for network security and AppChain maintenance. This multifaceted utility ensures that $TEX holders are actively involved in the governance, development, and security of the platform, reinforcing the decentralized and community-driven nature of Context.

* **Registry**: Multi-chain Token
* **Investor Staking**: Mid-term staking
* **Governance Token**: Stake to vote
* **Name Resolution**: Verification staking
* **Document Update**: Transactional fee
* **TLD**: Governance staking
* **SaaS Buyback**: Buying pressure


# Governance

The $TEX token will be a crucial component in the future DAO (Decentralized Autonomous Organization) of the Context project, giving token holders the ability to influence and decide the future direction of the project. Through this DAO, $TEX holders will participate in governance decisions that will shape the evolution of Context, including the development of the global DNS3 (Decentralized Naming System 3.0).

Token holders will have the power to propose and vote on key issues such as protocol upgrades, funding allocations, strategic partnerships, and other critical decisions. By participating in the DAO, the community will collectively control the future of Context and ensure that it remains aligned with the interests of its users.

Moreover, the control of the global DNS3 will be managed by the DAO, with $TEX holders having a say in how this decentralized naming system is governed and maintained. This ensures that the DNS3 remains a public good, accessible and beneficial to all, and that its development is guided by the community’s collective wisdom and values.


# Allocation

In this section, we outline the allocation of the $TEX tokens to various aspects of the project, as detailed in the table provided:

* **Ecosystem Development**: These funds are designated for the growth and enhancement of the Context ecosystem. This includes funding for research and development, partnerships, and the overall expansion of the platform to ensure it continues to meet the needs of its users.
* **Community & Marketing**: To build a robust and engaged community around the Context project, a significant portion of the tokens will be allocated to community-building initiatives and marketing efforts. This includes outreach, education, promotional campaigns, airdrops and events to raise awareness and adoption of the Context platform.
* **Staking Fund & Incentives**: To encourage token holders to stake their $TEX and participate actively in the governance and security of the network, a portion of tokens will be reserved for staking rewards and other incentive programs.

These allocations are designed to cover all critical aspects of the project’s development and ensure the long-term success and sustainability of the Context ecosystem.


# Use Cases and Applications


# Telegram bot for updates

Broadcast Trusted Updates to Telegram Groups with Context's Easy Document Management.

## **What Does the Bot Do?**

Our Telegram bot allows you to:

* Subscribe to updates from Context documents with the core/updates data template.
* Receive notifications in your Telegram group whenever there is a new update.
* Easily manage your subscriptions.
* And if you are the owner of a verfied domain, send new updates

## **How to Use the Bot**

{% stepper %}
{% step %}

### **Get Access**

Join our [Telegram Group](https://t.me/contextdao) and ask the team to verify your domain and get access to the platform.
{% endstep %}

{% step %}

### **Install the Bot**

**‍**Telegram : [`@ContextUpdateBot`](https://t.me/contextUpdatesBot)
{% endstep %}

{% step %}

### **Subscribe to a Document**

Follow us : in the bot execute /subscribe contextprotocol/updates

Follo you : execute the command /subscribe \<yourdomain>/updates with the domain we will give to you once verified
{% endstep %}

{% step %}

### **Write an update**

In the bot execute /setup and use the API KEY that we will provide.

Now execute the command /update and just follow instructions
{% endstep %}
{% endstepper %}

## **Example Use Case**

* **Fundraising Updates**: Whether you're managing a startup or a nonprofit organization, keeping investors and stakeholders informed about funding rounds and milestones is crucial. With Context, you can create a centralized document using the core/updates template to share funding updates across multiple Telegram groups simultaneously. This ensures that all relevant parties receive timely and consistent information, enhancing transparency and investor relations.
* **Partnership Announcements**: When forging partnerships with other businesses or organizations, it's essential to communicate updates efficiently. Context allows you to maintain a single document for partnership announcements, such as collaborations, joint ventures, or strategic alliances. By using the Context Bot on Telegram, you can ensure that partners and stakeholders are promptly notified of any developments, fostering strong relationships and collaboration.
* **Event Management**: Managing events involves coordinating with various stakeholders, including speakers, sponsors, and attendees. Context simplifies event updates by enabling organizers to maintain a document with real-time updates on schedules, agenda changes, and last-minute announcements. Subscribing Telegram groups to this document ensures that everyone involved stays informed, minimizing confusion and enhancing event coordination.
* **Product Launches**: Launching a new product or service requires effective communication to generate excitement and engage your audience. Context allows you to create a dedicated document for product updates, including launch dates, features, and customer feedback. By subscribing relevant Telegram groups, you can ensure that your updates reach targeted audiences, driving awareness and adoption of your new offerings.
* **Policy and Regulatory Updates**: Businesses operating in regulated industries need to stay compliant with evolving policies and regulations. Context provides a reliable platform to manage updates related to legal changes, compliance requirements, and industry standards. By centralizing regulatory updates in a document and broadcasting them via Telegram, organizations can ensure that all stakeholders are informed promptly, mitigating risks and maintaining compliance.


# Basenames integration

{% hint style="info" %}

#### Under Construction

We're working on this section and it will be available soon. Thanks for your patience!
{% endhint %}

Coming soon available at: <https://app.ctx.xyz/claim/base>


# Dynamic NFTs


# dWeb: Descentralized Website

{% hint style="info" %}

#### Under Construction

We're working on this section and it will be available soon. Thanks for your patience!
{% endhint %}


# Decentralized Link3

{% hint style="info" %}

#### Under Construction

We're working on this section and it will be available soon. Thanks for your patience!
{% endhint %}


# WikiWine


# Bill3: Private Invoices


# What is Context?

**Context Protocol is a Web3 Semantic Layer** that redefines the way we interact with and manage data in the decentralized digital landscape. At its core, Context Protocol bridges the gap between decentralized storage solutions and semantic understanding, providing a framework where data is not just stored, but also intelligently understood and utilized.

<figure><img src="https://2383774531-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FecjUZkkkzTibDqjoS6JO%2Fuploads%2FYIizjDhVFI06plzB6Y2U%2FCaptura%20de%20pantalla%202024-04-19%20a%20les%208.35.42.png?alt=media&amp;token=c7a4a090-2690-4779-ae73-4581d8c8bbcb" alt=""><figcaption></figcaption></figure>

Data stored through these Documents can be associated with one or more schemas, such as "human", "programmer" or "event organizer", and then registered with distinctive identifiers in our Polygon registry. This registry functions as a <mark style="color:blue;">Semantic Name Service</mark>, where each identifier relates to a "smart document," the term we use for on-chain Documents designated for data storage.

The functionality of these smart documents can vary substantially depending on the associated schemas. In addition, smart documents incorporate versioning, which enhances the data with traceability features that allow its progression to be tracked over time.

<figure><img src="https://2383774531-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FecjUZkkkzTibDqjoS6JO%2Fuploads%2FlmI16oaTT9zYgnzyc29M%2FCaptura%20de%20pantalla%202024-04-19%20a%20les%208.35.56.png?alt=media&amp;token=44b7b6e3-e776-40ee-bdd8-08698ce6e153" alt=""><figcaption></figcaption></figure>


# Semantic Name Service

**Context Protocol Registry**

The Registry in the Context Protocol is a crucial component that serves as a Semantic Name Service. It is a decentralized system that assigns names to context documents, which are essentially on-chain data spaces used for storing JSON files.

**Functionality**

The primary function of the Registry is to provide a mapping between names and context documents. Each name in the Registry corresponds to a specific linked list of transactions, and this name is unique. This means that once a name is assigned to a context document, it cannot be used for another document. This unique mapping allows users to easily locate and access the data stored in a context document by using its assigned name.

**Decentralization**

The Registry is decentralized, meaning it is not controlled by any single entity. Instead, it is maintained by the users of the Context Protocol. This decentralization enhances the security and reliability of the Registry, as it is not vulnerable to single points of failure.

**Interoperability**

The Registry promotes interoperability and data portability. Since each name in the Registry corresponds to a Context document, and each Context document can be linked to one or more schemas, it is possible to link a single piece of data to multiple schemas. This makes it easier for developers to build and scale their applications, as they can leverage the same data across different schemas.

**Data Versioning**

In addition to its naming function, the Registry also supports data versioning. Each time a Context document is updated, a new version of the data is created and stored. This allows users to track the evolution of their data over time, enhancing data traceability.

**Conclusion**

In summary, the Registry in the Context Protocol is a decentralized Semantic Name Service that assigns unique names to Context documents. It promotes data interoperability and portability, supports data versioning, and is maintained by the users of the Context Protocol. It is a key component of the Context Protocol, enabling users to easily locate and access their data.


# Context Documents

**Context Protocol Documents**

Context Documents are a central element of the Context Protocol. Essentially, they are a series of transactions on Arweave used for storing versioned data, providing a flexible and secure method for data management within the protocol.

<figure><img src="https://2383774531-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FecjUZkkkzTibDqjoS6JO%2Fuploads%2F9YaEwRjH9CQMCtuGvl0O%2FCaptura%20de%20pantalla%202024-04-19%20a%20les%208.43.12.png?alt=media&amp;token=20b0d26c-3b12-422b-aaf1-02a0da1b8822" alt=""><figcaption></figcaption></figure>

**Functionality**

Context Documents serve as containers for data within the Context Protocol. They allow users to store their data on Arweave, and soon other storage blockchain platforms, such as Filecoin, Ethereum storage, and others. The data stored in a Context Document can be linked to one or more templates, providing a structured and organized way to manage data.

**Ownership**

Ownership of Context Documents is a key feature of the Context Protocol. The owner of the data, whether it's a single owner with a Metamask wallet or a full Data DAO with more complex governance, has complete control over their Documents. This ensures that users maintain full ownership and control over their data.

**Decentralization**

Context Documents are decentralized, meaning they are not controlled by any single entity. Instead, they are maintained by the users of the Context Protocol. This decentralization enhances the security and reliability of the Documents, as they are not vulnerable to single points of failure.

**Interoperability**

Context Documents promote interoperability and data portability. Since each Document can be linked to multiple templates, it is possible to use the same piece of data across different applications. This makes it easier for developers to build and scale their applications, as they can leverage the same data across different templates.

**Data Versioning**

In addition to their data storage function, Context Documents also support data versioning. Each time a Document is updated, a new version of the data is created and stored. This allows users to track the evolution of their data over time, enhancing data traceability.

**Registry Integration**

Context Documents are integrated with the Context Protocol's Registry. Each Document is assigned a unique name in the Registry, making it easy for users to locate and access their data.

**Conclusion**

In summary, Context Documents in the Context Protocol are decentralized data storage containers that are owned and controlled by the data owners. They promote data interoperability and portability, support data versioning, and are integrated with the Registry. They are a key component of the Context Protocol, enabling users to securely store and manage their data.


# Context Templates

**Context Protocol Semantic Templates**

Templates are a fundamental part of the Context Protocol. They provide a structured framework for organizing and interpreting data stored in Context Documents.

**Functionality**

Templates serve as a framework to coordinate the structure of data within the Context Protocol. They define the structure and type of data that can be stored in a Context Document, providing a standardized way to organize and interpret data. These templates follow the JSON Schema spec.

**Public Goods**

Templates are considered public goods within the Context Protocol. This means they are freely available for anyone to use. They are not owned or controlled by any single entity, but rather, they are maintained by the community of users within the Context Protocol.

**Creation**

One of the key features of Templates in the Context Protocol is that anyone can create them. This allows for a diverse range of Templates to be created, catering to a wide variety of data types and structures. This feature promotes innovation and flexibility within the protocol.

**Bottom-Up Approach**

Templates are built using a bottom-up approach. This means they are created and defined by the users of the Context Protocol, rather than being imposed from the top down. This approach allows for a more organic and user-centric development of Templates, ensuring they meet the needs of the community.

**Context Documents**

Templates themselves are Context Documents. This means they have versioning and the same ownership principles as other Documents in the Context Protocol. Each time a Template is updated, a new version is created and stored. This allows users to track the evolution of a Template over time, enhancing traceability.

**Conclusion**

In summary, Templates in the Context Protocol are a structured framework for organizing and interpreting data. They are public goods that anyone can create, built using a bottom-up approach, and are themselves Context Documents with versioning and ownership principles. They are a key component of the Context Protocol, enabling users to effectively structure and interpret their data.


# Why use Context?

Benefits of using Context

**Context Protocol** is a **Web3 Semantic Layer** that brings your data:

1. <mark style="color:blue;">Sovereignty</mark> *On context you control your Data, no third parties involved.*
2. <mark style="color:blue;">Traceability</mark> You can *verify what is a Real and where it comes from.*
3. <mark style="color:blue;">Interoperability</mark> *With Common language (Standards) for different applications.*
4. <mark style="color:blue;">Reputation & verification</mark> *We created proof of integrity, where you can proof that you are what you say you are, and get reputation.*
5. <mark style="color:blue;">Security</mark> <mark style="color:blue;"></mark>*<mark style="color:blue;">Data</mark> is stored on the blockchain.*
6. <mark style="color:blue;">Versioning</mark> <mark style="color:blue;"></mark>*<mark style="color:blue;">Data</mark>* *is alive, you can travel on the version and evolve your data.*
7. <mark style="color:blue;">Portability</mark> *AVOIDING DATA DUPLICATION!*


# Litepaper

## <mark style="color:blue;">1. Introduction</mark>

Context Protocol is a **Web3 Semantic Layer** that redefines the way we interact with and manage data in the decentralized digital landscape. At its core, Context Protocol bridges the gap between decentralized storage solutions and semantic understanding, providing a framework where data is not just stored, but also intelligently understood and utilized. By facilitating a decentralized and semantic approach to data storage and management on the blockchain, it enables users to operate data on-chain Documents while imparting semantic meaning to the stored information. Context is laying the foundation for enhanced data interoperability by providing the necessary framework for data to be fully comprehended and utilized.

Data management faces several challenges that Context is prepared to mitigate. First is the critical need for a decentralized open knowledge database accessible to all, with enhanced data security and privacy measures. In addition, there is a compelling need for a global open source repository for data templates or standards that rationalize data in a cohesive manner, improving the effectiveness and efficiency of data storage and interaction.

In addition, the current landscape lacks a cohesive data architecture, which complicates interactions between developers and users due to the disjointed approach to data interaction. This inconsistency is a barrier to the effective utilization of data assets. In addition, unclear and inconsistent relationships between data and its structure make it difficult to decipher the context and essence of the data.

In response to this, Context stands as a pivot in the data management industry, focused on delivering solutions ensuring that data is alive, accessible and understandable to anyone, anytime, anywhere. Context is both an innovative technology and a platform that leverages a decentralized infrastructure with a commitment to fostering a universally accessible, easily understandable and efficiently operational data environment.

**Mission**

Our mission is to redefine data management in the decentralized space. Our goal is to empower developers and users with a platform that not only stores data, but also adds a layer of semantic intelligence to it. In doing so, we strive to improve the quality, accessibility and usability of data in decentralized applications, fostering innovation and growth in the blockchain ecosystem.

**Vision**

Context Protocol envisions a decentralized digital world where data is not just a static entity, but an easily accessible, interpretable and actionable dynamic resource. Our vision is to become the leading platform for semantic data aggregation, setting new standards for data integrity, interoperability and usability across diverse networks and blockchain applications.

**Positioning**

Context Protocol is positioned as a pioneer in the field of on-chain semantic data aggregation, uniquely combining the security and reliability of blockchain technology with advanced semantic data understanding. We are positioned to meet the growing needs of developers and organizations seeking efficient, secure and intelligent data management solutions, thus becoming an indispensable tool in the toolbox of modern decentralized applications and platforms.

## <mark style="color:blue;">2.  Context Design</mark>

### <mark style="color:blue;">2.1 Tech  Stack</mark>

**Context** technology stack is based on several fundamental components to efficiently manage and interact with the platform. Each component has been carefully designed to ensure smooth interaction and a high standard of functionality. These core components include:

**Smart Contracts:** As the foundation of the Context platform, smart contracts oversee the registration, templates and operations of Context documents. Developed in Solidity, these open source contracts accept reviews and contributions from the community, encouraging collaborative development and continuous improvement.

**Command Line Interface (CLI):** The CLI provides an easy-to-use terminal interface that facilitates interaction with the platform. It contains commands to manage essential functions such as managing Context documents, adjusting templates and navigating the registry, making it easy to use even from a terminal.

**Software Development Kit (SDK):** The SDK is a library of code that allows developers to interact with the platform from their own code. It provides a simple and consistent interface for interacting with the platform.

**API:** This gateway allows external applications to seamlessly extract information about Context documents and templates from the registry. Designed for fast and efficient data retrieval, it maintains a unified interface for inbound and outbound data.

All these components work together to make Context Context is a technology platform built on a decentralized infrastructure for creating templates, and managing data,  making it easy for developers to build applications and services on top of it.

<figure><img src="https://2383774531-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FecjUZkkkzTibDqjoS6JO%2Fuploads%2FlmI16oaTT9zYgnzyc29M%2FCaptura%20de%20pantalla%202024-04-19%20a%20les%208.35.56.png?alt=media&amp;token=44b7b6e3-e776-40ee-bdd8-08698ce6e153" alt=""><figcaption><p>Context Tech Stack</p></figcaption></figure>

### <mark style="color:blue;">2.2 Architecture</mark>

#### <mark style="color:blue;">2.2.1. Templates</mark>

One of the main benefits of Context is that we provide developers with a clear and consistent way to associate data with its structure. By using a GraphQL-style approach, templates are easy to understand and work with, making it simple for developers to interact with and manage data in Context.

```
type Organization {
  name: String!
  url: String
}
```

### <mark style="color:blue;">2.2.2. Context Documents</mark>

Context documents are smart contracts that hold information and data in a structured format that follows a specific template. These templates provide a standardized way for data to be organized and understood. The benefits of using Context documents include:

1. Data is organized in a consistent and predictable way, making it easier to work with and access.
2. Context documents are decentralized and can be owned by anyone, which ensures that data is not controlled by any single entity.
3. Context documents can be easily edited and updated by their owners, which allows for the data they hold to stay up-to-date and relevant.
4. Context documents can be easily referenced by their Universal Registry name, making it easy for others to discover and interact with the data they contain.
5. Context documents can be connected to other Context documents, which allows for the creation of complex data structures and relationships.
6. Context documents can be deployed to the blockchain, which provides an immutable record of all data transactions, ensuring data integrity and security.
7. Context documents can be integrated with different apps, dApps and protocols, which allows for data to be used in many different contexts and use cases.

Each time the data in a Context documents is updated, a new version of the Context documents is created, allowing for traceability of the data's evolution over time.

This versioning system is unique to Context documents and different from traditional versioning systems like those used in Github for code. It does not use major, minor, and patch versioning and does not have branches, instead, it focuses on data traceability

The ability to extend Context documents allows for greater flexibility and versatility in the way data is organized and represented. By allowing Context documents to incorporate fields from additional templates, users are able to create more complex and detailed representations of the data they are working with. This feature, known as composability, allows for the creation of custom data structures that can be tailored to specific use cases.

Overall, the ability to extend Context documents provides developers with a powerful tool for organizing and representing data in a way that is both flexible and easy to understand.

### &#x20;<mark style="color:blue;">2.2.3. Registry</mark>

The Registry is a decentralized and open-source smart contract that acts as the backbone of the Context ecosystem. It serves as a global, decentralized name service for data that is stored within the Context network. The Registry allows users to associate a unique name to a Context documents, which can then be easily referenced and queried by other users within the ecosystem.

**Universal Name Service**

A Universal Name Service is a decentralized naming system that allows users to assign unique and human-readable names to any resource, whether it be a person, project, product, or any other type of item. Unlike traditional naming systems, such as DNS, which are limited to a specific set of resources, like IP addresses, a Universal Name Service can be used to assign names to any type of resource, providing a more versatile and flexible naming system. The benefits of a Universal Name Service include the ability to easily and consistently reference resources, improved data interoperability, and increased human-readability of data. The ability to extend Context documents also enables the composability of data, making it easier to build and maintain complex data structures.

Benefits of the Universal Name Service include:

* Decentralization: The Registry is not controlled by any single entity, ensuring that data is accessible to everyone and that there is no central point of failure.
* Ease of use: The Registry provides a simple and intuitive interface for users to name and reference Context documents, making it easy for developers to work with and query the data stored within the network.
* Interoperability: The Registry allows for different applications and systems to easily reference and query data stored within the Context network, promoting interoperability between different systems.
* Security: The use of a decentralized name service provides an additional layer of security, as there is no single point of attack or failure.
* Traceability: The Registry allows for the traceability of data, as all versions of a Context documents can be easily accessed and queried.
* Incentivized participation: The Registry incentivizes participation in the network through the use of the Context token and a portion of the fees paid for naming and referencing Context documents is directed to the working group responsible for curating the namespace.

#### Subnames

The Registry allows anyone with a name, such as an organization or project, to add subnames. This allows for a flexible way of organizing information, making it easy to navigate and find the data needed. Additionally, the Registry ensures that all the names and templates are unique and can't be duplicated, which ensures the integrity of the data stored in Context.

## <mark style="color:blue;">3. How Context works</mark>

### <mark style="color:blue;">3.1. Coordination</mark>

The process of creating and evolving a standard in Context begins with the editor, who is responsible for defining the initial structure and format of the template. Contributors can then add proposals for new fields or modifications to the template, which the editor can review and accept or reject.

Once the template has been established, editors can invite new contributors to join the working group and contribute to the template's development. Additionally, curators are also added to the working group to ensure the quality of the names being used. They are responsible for curating the names that are using the template and can add new names under the core/organization template, for example.

As the template evolves, contributors are incentivized to create and maintain better standards through a small fee paid in our token. A portion of this payment goes to the treasury of the working group, providing an additional incentive for collaboration and improvement.

### <mark style="color:blue;">3.2. Templates</mark>

The Templates serve as the foundation and are designed to provide a common language for data to be understood and used in any application.

The templates, which are used to represent individuals, organizations, and projects, respectively. These templates are designed to be simple and flexible, allowing them to be easily extended and customized to suit their specific needs.

Templates:

* human
* organization
* project
* address
* place
* social
* team
* document

At the first stage of the project, only one template can be assigned a name, and these names will be curated by the curators of Context or partner to ensure the quality of the data being represented. This allows for a consistent and well-structured foundation for all data in the platform, and ensures that all data has context and can be easily understood and used in any application. The Contributors act as a gatekeeper to ensure the quality of the data being represented in the platform.<br>

## <mark style="color:blue;">4. Why use Context</mark>

Context is a powerful tool for managing data in a decentralized and interoperable way. It provides a range of benefits for projects and applications, including:

### <mark style="color:blue;">4.1. Portability</mark>

Context enables data portability by providing a common language for data that can be easily understood and used across different applications and systems. This means that data can be moved between different platforms and applications without the need for costly and time-consuming data conversion processes. With Context, data can be easily shared, reused, and integrated, allowing for more efficient and effective data management.

### <mark style="color:blue;">4.2. Interoperability</mark>

Context makes data interoperable by providing a standardized data structure that can be used across different applications and systems. This means that data can be easily exchanged and integrated between different platforms and applications, making it possible to create more complex and powerful applications that draw on data from multiple sources. By promoting interoperability, Context enables greater collaboration between different projects and applications, leading to more innovation and better outcomes.

### <mark style="color:blue;">4.3. Security</mark>

Context provides a secure environment for managing data by leveraging decentralized technologies and cryptographic protocols. This means that data is protected from unauthorized access, manipulation, and theft, ensuring the privacy and security of sensitive information. With Context, projects can build trust and confidence among their users and stakeholders, leading to greater adoption and success.

### <mark style="color:blue;">4.4. Public Good</mark>

Context is a public good that promotes openness, transparency, and innovation. By providing a decentralized and interoperable platform for managing data, Context enables greater collaboration and knowledge sharing across different communities and stakeholders. This leads to more equitable and sustainable outcomes, promoting the public good and benefiting society as a whole. With Context, projects can contribute to a better future for everyone.

## <mark style="color:blue;">5. Tokenomics - $TEX</mark>

Our token is called $TEX have a limited supply of 100M.

### <mark style="color:blue;">5.1. Governance</mark>

The $TEX token will be a crucial component in the future DAO (Decentralized Autonomous Organization) of the Context project, giving token holders the ability to influence and decide the future direction of the project. Through this DAO, $TEX holders will participate in governance decisions that will shape the evolution of Context, including the development of the global DNS3 (Decentralized Naming System 3.0).

Token holders will have the power to propose and vote on key issues such as protocol upgrades, funding allocations, strategic partnerships, and other critical decisions. By participating in the DAO, the community will collectively control the future of Context and ensure that it remains aligned with the interests of its users.

Moreover, the control of the global DNS3 will be managed by the DAO, with $TEX holders having a say in how this decentralized naming system is governed and maintained. This ensures that the DNS3 remains a public good, accessible and beneficial to all, and that its development is guided by the community’s collective wisdom and values.

### <mark style="color:blue;">5.2. Token Utility</mark>

The $TEX token serves as a versatile utility token within the Context ecosystem, primarily used as a means of payment for interactions with the registry. When a user interacts with the registry, such as registering or updating data, they will be required to pay a small fee in $TEX. This fee will be split between the protocol, the template to which the interaction refers, and potentially a frontend that originated the interaction. This split ensures that the protocol is adequately supported, and that the schemas and frontends that are used are rewarded for their contributions, creating an incentive for the continuous development and maintenance of high-quality schemas and frontends. This, in turn, supports the overall growth and sustainability of the Context ecosystem.

In addition to these transactional fees, the $TEX token will play a crucial role in the staking mechanism for domain verifications within the DNS3 system. Token holders will be able to stake $TEX to participate in verifying and securing domain names within the decentralized DNS3 framework. This staking process not only ensures the integrity and reliability of the DNS3 system but also rewards participants with incentives for their contributions to maintaining this vital infrastructure.

Furthermore, $TEX tokens will be essential for maintaining the future Context L2/L3 network. As Context evolves into a more complex and scalable system, an AppChain will be developed to handle the growing number of transactions and interactions within the ecosystem. Token holders will be able to stake $TEX to help secure and validate transactions on this AppChain, ensuring its smooth operation and robustness. Stakers will be rewarded for their role in upholding the network, further aligning incentives with the long-term success of Context.

Overall, the $TEX token is designed to be deeply integrated into the various layers of the Context ecosystem, from transactional interactions with the registry and DNS3 system to staking for network security and AppChain maintenance. This multifaceted utility ensures that $TEX holders are actively involved in the governance, development, and security of the platform, reinforcing the decentralized and community-driven nature of Context.

### <mark style="color:blue;">5.3. Allocation</mark>

In this section, we outline the allocation of the $TEX tokens to various aspects of the project, as detailed in the table provided:

* **Ecosystem Development**: These funds are designated for the growth and enhancement of the Context ecosystem. This includes funding for research and development, partnerships, and the overall expansion of the platform to ensure it continues to meet the needs of its users.
* **Community & Marketing**: To build a robust and engaged community around the Context project, a significant portion of the tokens will be allocated to community-building initiatives and marketing efforts. This includes outreach, education, promotional campaigns, airdrops and events to raise awareness and adoption of the Context platform.
* **Staking Fund & Incentives**: To encourage token holders to stake their $TEX and participate actively in the governance and security of the network, a portion of tokens will be reserved for staking rewards and other incentive programs.

These allocations are designed to cover all critical aspects of the project’s development and ensure the long-term success and sustainability of the Context ecosystem.

## <mark style="color:blue;">6. Get in Touch</mark>

Send us an email. We are looking for:

* Business Angels and VCs interested in Open Source and Public Goods.
* Strategic Partners with specific use cases.
* Crazy People willing to Join us.

Email : <info@ctx.xyz>

\
\
\
\ <br>

##


# Core Components

Introduction, with diagram and explain Coordination with link to different core components


# TLDs

Multiples and also core DNS to verify. DAOs and governance.


# Domains

Domains represent verified and curated entities, such as companies, projects, or individuals.


# Documents

Context Documents are a central element of the Context Protocol. Essentially, they are a series of transactions on Arweave used for storing versioned data, providing a flexible and secure method for data management within the protocol.

<figure><img src="https://2383774531-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FecjUZkkkzTibDqjoS6JO%2Fuploads%2F9YaEwRjH9CQMCtuGvl0O%2FCaptura%20de%20pantalla%202024-04-19%20a%20les%208.43.12.png?alt=media&amp;token=20b0d26c-3b12-422b-aaf1-02a0da1b8822" alt=""><figcaption></figcaption></figure>

**Functionality**

Context Documents serve as containers for data within the Context Protocol. They allow users to store their data on Arweave, and soon other storage blockchain platforms, such as Filecoin, Ethereum storage, and others. The data stored in a Context Document can be linked to one or more templates, providing a structured and organized way to manage data.

**Ownership**

Ownership of Context Documents is a key feature of the Context Protocol. The owner of the data, whether it's a single owner with a Metamask wallet or a full Data DAO with more complex governance, has complete control over their Documents. This ensures that users maintain full ownership and control over their data.

**Decentralization**

Context Documents are decentralized, meaning they are not controlled by any single entity. Instead, they are maintained by the users of the Context Protocol. This decentralization enhances the security and reliability of the Documents, as they are not vulnerable to single points of failure.

Versioning

TBD


# Templates


# Smart Contracts

Intro and diagram contracts works


# Registry (TLDs)

The Registry is a decentralized and open-source smart contract that acts as the backbone of the Context ecosystem. It serves as a global, decentralized name service for data that is stored within the Context network. The Registry allows users to associate a unique name to a Context documents, which can then be easily referenced and queried by other users within the ecosystem.

**Functionality**

The primary function of the Registry is to provide a mapping between names and context documents. Each name in the Registry corresponds to a specific linked list of transactions, and this name is unique. This means that once a name is assigned to a context document, it cannot be used for another document. This unique mapping allows users to easily locate and access the data stored in a context document by using its assigned name.

**Decentralization**

The Registry is decentralized, meaning it is not controlled by any single entity. Instead, it is maintained by the users of the Context Protocol. This decentralization enhances the security and reliability of the Registry, as it is not vulnerable to single points of failure.

**Interoperability**

The Registry promotes interoperability and data portability. Since each name in the Registry corresponds to a Context document, and each Context document can be linked to one or more schemas, it is possible to link a single piece of data to multiple schemas. This makes it easier for developers to build and scale their applications, as they can leverage the same data across different schemas.

**Data Versioning**

In addition to its naming function, the Registry also supports data versioning. Each time a Context document is updated, a new version of the data is created and stored. This allows users to track the evolution of their data over time, enhancing data traceability.

\
List of deployed contracts in the future


# Settings


# Public Gateway

The gateway indexes and serves data, making it accessible to users.

Every data on Context is publicly available, free, and forever for other developers to use through `https://rpc.ctx.xyz/`

### **Endpoint Structure**

* **domain**: Represents the primary identifier for your stored data. It’s typically structured as `yourdomain.base.eth` or any other registered TLD in the Context ecosystem.
* **path/to/document**: The directory path to the specific document or data you want to access. This path could represent various files or data objects stored under your domain.

Example:

```http
https://rpc.ctx.xyz/myorg.startup/files/report.json
```

**Using cURL**: To fetch a document from the gateway, you can use the following command:

```bash
curl -X GET "https://rpc.ctx.xyz/myorg.startup/files/logo.png"
```

### **Use Cases and Applications**

Here are some suggested applications where you can use it:

1. **Profile Management**: Use your domain to host and fetch user profile data (e.g., profile pictures, bios).
2. **Data Verification**: Store verifiable, tamper-proof documents such as certifications or legal records.
3. **Decentralized File Storage**: Access public files or media stored under a specific domain.
4. **Custom Links or Content Hubs**: Host custom frames or "link trees" that link to various resources under your domain, ideal for social media or portfolio pages.

### **Security and Authentication**

Currently, public data is accessible without authentication but with rate limit. However, if you need to read private data or exceed rate limit, make sure you use access tokens or API keys. Follow these best practices:

* **Secure API Keys**: Do not hardcode keys directly in client-side code.
* **HTTPS**: Always use HTTPS to prevent interception of data.

### **Query Parameters**

TBD


# Curations/verification


# FAQ

<details>

<summary><mark style="color:blue;">What kind of data can be stored in Context Documents?</mark></summary>

Context Documents are designed to hold any data in JSON format, including metadata and structured data. They are not designed for storing images, audio, or video files.

</details>

<details>

<summary><mark style="color:blue;">What is a Template?</mark></summary>

A template is a set of rules that defines how data is structured and how it should be stored in a database. It provides a blueprint for organizing and describing data elements, attributes, and the relationships between them. A schema can be used to define the data types, constraints, default values, and other rules that should be followed when creating and managing a database.

</details>

<details>

<summary><mark style="color:blue;">What is the Universal Name Registry?</mark></summary>

The Universal Name Registry or UNS, is the reference point for the schemas and SmartPods on the Context platform, allowing for easy access and organization of the data. It helps to ensure that data is standardized and easily accessible for all builders.

</details>

<details>

<summary><mark style="color:blue;">How is Context different from other data platforms?</mark></summary>

Context is unique in its focus on data interoperability and portability. By providing standardized schemas and a decentralized approach to data management, it makes it easier for builders to seamlessly integrate data from different sources and build innovative projects.

</details>

<details>

<summary><mark style="color:blue;">How can I get involved in Context?</mark></summary>

There are several ways to get involved in Context, including joining a Working Group, creating a SmartPod, or building a Front-end with Context technology. You can contact us through our website or [group of Telegram](https://t.me/contextdao) to learn more about Context.

</details>


# Why build on Context

Context empowers developers to create and innovate like never before. With Context, builders can eliminate dependencies, integrate efficient onchain data, and unlock new possibilities for dynamic, real-time applications—all within a unified platform.

\
Benefits of using Context for Devs. Blob alternative.


# Typescript SDK

The Context SDK is a robust and flexible toolkit designed for developers to interact programmatically with [Context Protocol](https://ctx.xyz/).

{% embed url="<https://www.npmjs.com/package/@contextprotocol/sdk>" %}


# Initialization

### Install the SDK

Install the Context SDK to your TypeScript project using npm:

```bash
npm install @contextprotocol/sdk
```

### Setting Up Your Connection

To use Context, you always need a domain. This domain acts as your namespace within Context, where all your documents will be stored. Then, you'll need to obtain an API key for your domain.

You can claim your domain and generate the API key by creating an account at [app.ctx.xyz](https://app.ctx.xyz/).

Initialize the SDK:

```typescript
import { Context } from '@contextprotocol/sdk';

const ctx = new Context({ apiKey: "your_api_key_here" }); // Replace with your API key
```


# Working with Domains

Domains represent verified and curated entities, such as companies, projects, or individuals.

### Fetch Domain Information

Fetch details of a specific domain or the default domain associated with your API key:

```typescript
// Fetch your domain
const yourDomain = await ctx.domain();

// Fetch a specific domain.tld
const domain = await ctx.domain("context.startup");
```

### Domain Properties

Access and display properties of a domain:

```typescript
console.log(domain.data.name);
console.log(domain.data.fullDomain);
console.log(domain.data.tld);
console.log(domain.data.documents);
console.log(domain.data.status);
console.log(domain.data.createdAt);
console.log(domain.data.updatedAt);
```


# Managing Documents

{% hint style="warning" %}

### Public Data

Remember, all data stored on Context is public. Avoid storing any secrets or private information without additional measures to protect confidentiality.
{% endhint %}

### Fetch Documents

Fetch a specific document or template or asset, from any domain:

```typescript
// Fetch a specific document
const document = await ctx.document("context.startup/link3");  // "domain/path/to/file"
```

### Document Properties

Access and display properties of a document:

```typescript
console.log(document.data.path);
console.log(document.data.versionNumber);
console.log(document.data.data);
console.log(document.data.metadata);
console.log(document.data.templates);
console.log(document.data.type); // Document | Template | Asset
console.log(document.data.txId);
console.log(document.data.createdAt);
console.log(document.data.updatedAt);
console.log(JSON.stringify(document.data));
```

### List Document Versions

Fetch a list of all versions of a document:

```typescript
const documentVersions = await document.data.versions();
```

### Fetch a Specific Document Version

You can fetch a specific version of a document in two different ways:

```typescript
// By using the version method of the document:
const document = await ctx.document("document_path");
const documentVersion = await document.data.getVersion("X.Y.Z");

// By specifying the version directly the document path:
const documentInVersionXYZ = await ctx.document("document_path?v=X.Y.Z");
```

### Create a Document

Steps to create a new document within a domain:

```typescript
const data = YOUR_JSON_DATA;  // JSON data for the document
const templates = ["template_path"];  // Optional array of template paths
const metadata = { name: "Document Name", description: "Document Description", readme: "ctx:domain/files/my_markdown" };  // Optional metadata
const documentPath = "mypath/files/document";

const newDocument = await ctx.createDocument(documentPath, data, templates, metadata);
```

### Update a Document

Update an existing document:

```typescript
const updatedData = YOUR_UPDATED_JSON_DATA;  // Updated JSON data
const document_path = "mypath/files/document";

const document = await ctx.document(documentPath);
if (!document.success) {
    // Handle error
}
const result = await document.data.update(updatedData);
```

### Adding Metadata to a Document

You can add metadata to a document using the `addMetadata` method. The metadata object should contain the following (optional) fields: `name`, `description`, and `readme` as shown below:

```typescript
const metadata = { name: "Document Name", description: "Document Description", readme: "ctx:domain/files/my_markdown" };
await document.data.addMetadata(metadata);
```


# Creating Templates

### Define a JSON Schema for a Template

Create a JSON schema directly or from a TypeScript interface:

```typescript
// Direct JSON Schema definition
const schema = {
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "name": {"type": "string", "description": "The name of the organization."},
    "description": {"type": "string", "description": "A brief description of the organization."},
    "website": {"type": "string", "description": "The URL of the organization's website.", "format": "uri"}
  },
  "required": ["name"],
};

// Generate JSON schema from a TypeScript interface
const dataName = 'User';
const myDataType = `interface ${dataName} {
  name: string;
  age: number;
}`;
const schema = generateJsonSchema(dataName, myDataType);
```

### Create a New Template

Use the defined schema to create a new template:

```typescript
const metadata = { name: "Template Name", description: "Template Description", readme: "Markdown document" };  // Optional metadata
const template = await ctx.createTemplate("template_path", schema, [], metadata /* optional */);
```

### Installing Templates

Once we have the template, we can install it in a document by using the `install` method:

```typescript
const document = await ctx.document("document_path");
if (!document.success) {
    // Handle error
}
const templateArrayToInstall = ["template_path"];
const newDoc = await document.data.install(templateArrayToInstall);
```

### Uninstalling Templates

To uninstall a template from a document, we can use the `uninstall` method:

```typescript
const document = await ctx.document("document_path");
if (!document.success) {
    // Handle error
}
const templateArrayToUninstall = ["template_path"];
const newDoc = await document.data.uninstall(templateArrayToUninstall);
```


# Assets

### Upload new Assets

As a user, you can upload assets to your domain. When uploading an asset, you can specify the document path where the asset will be stored.

```typescript
const ctxDocumentPath = "document/path";
const localFilePath = "file/path.jpg";
const asset = await ctx.createAsset(ctxDocumentPath, localFilePath, metadata /* optional */);
```

### Update an Asset

You can update an existing asset by providing the document path and the local file path of the updated asset. It returns a document with a new version.

```typescript
const localFilePath = "file/path.jpg";
const asset = await ctxDocument.data.updateAsset(localFilePath, metadata /* optional */);
```


# Error Handling

When calling a function, you can check if an error occurred by checking the `error` property in the returned object:

```typescript
const document = await ctx.document("document_path");
if(document.success === false){
  console.error(document.error.error); // Error message
  console.error(document.error.message); // Detailed error message
  console.error(document.error.statusCode); // HTTP status code
}
```


# Example Workflow

Example workflow to start creating and updating your Documents with Context Protocol.

### 1. Create a Document

First, create a document within your Domain using some initial data.

```typescript
import { Context } from '@contextprotocol/sdk';

const ctx = new Context({ apiKey: 'your_api_key_here' });

async function createDocument() {
    const data = {
        title: "Initial Document",
        content: "This is the initial content of the document."
    };

    const pathToFile = "myfiles/path/file_name";
    const document = await ctx.createDocument(pathToFile, data);
    if (!document.success) {
        // Handle error
    }
    console.log(`Document created on: ${document.data.path}`);

    return document;
}
```

### 2. Define and create a Template

Next, define a JSON schema and use it to create a new Template on your domain.

```typescript
async function createTemplate() {
    const schema = {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "type": "object",
        "properties": {
            "title": {
                "type": "string",
                "description": "The title of the document."
            },
            "content": {
                "type": "string",
                "description": "The content of the document."
            }
        },
        "required": ["title", "content"]
    };
    
    const templatePath = "templates/newtemplate";
    const template = await ctx.createTemplate(templatePath, schema);
    if (!template.success) {
        // Handle error
    }
    console.log(`Template created on: ${template.data.path}`);

    return template;
}
```

### 3. Update the Document

Then, update the previously created document to be adapted to the template.

```typescript
async function updateDocument(documentPath) {
    const updatedData = {
        title: "Updated Document",
        content: "This is the updated content of the document."
    };

    const doc = await ctx.document(documentPath)
    const updatedDoc = await doc.data.update(updatedData);
    if (!updatedDoc.success) {
        // Handle error
    }
    console.log(`Document updated with new data: ${updatedDoc.data.data}`);

    return updatedDoc;
}
```

### 3. Install the Template

Finally, install the created template.

```typescript
async function installTemplate(documentPath) {

    const doc = await ctx.document(documentPath)
    const updatedDoc = await doc.data.install(["your_domain/templates/newtemplate"]);
    if (!updatedDoc.success) {
        // Handle error
    }
    console.log(`Document updated with this templates: ${updatedDoc.data.templates}`);

    return updatedDoc;
}
```

Finally, update the previously created document with new data and apply the newly created template.

<br>


# Create your first Domain

We are scheduled to launch on Mainnet in the coming weeks. If you are interested in becoming one of our early users, we encourage you to create your initial domain on our Beta using the [WebApp](https://app.ctx.xyz).

For inquiries about creating a premium and **verified** domain, please contact us at <support@ctx.xyz>


# Community Program

Participate in the Context Community and earn points to **get a share of the $TEX Airdrop** and more exclusive rewards!

🚀 Join now at [Context Community](https://community.ctx.xyz/)

{% stepper %}
{% step %}

### **Participate in the program**

Get points by completing quests, like daily tasks on Telegram or Twitter, and engaging with Context Protocol.
{% endstep %}

{% step %}

### **Climb the rank**

The higher your $TEX leaderboard rank, the bigger the real drop you'll receive. You will be able to claim your tokens after TGE.
{% endstep %}

{% step %}

### **Refer your friends**

Invite your friends to join the Context Community and earn extra points based on their success.
{% endstep %}
{% endstepper %}


# Social Media

<table data-view="cards"><thead><tr><th></th><th></th><th></th></tr></thead><tbody><tr><td></td><td>Linkedin</td><td></td></tr><tr><td></td><td>Twitter</td><td></td></tr><tr><td></td><td>Warpcast</td><td></td></tr><tr><td>Telegram</td><td></td><td></td></tr></tbody></table>


# Support


