# Developer Guid

### Installation

Install the Decontext Protocol package via npm:

```bash
npm install decontext-protocol
```

Or clone the full repository:

```bash
git clone https://github.com/Decontext/decontext-protocol
cd decontext-protocol
npm install
```

***

### Project Structure

* `contracts/`: Solidity smart contracts implementing DMCP
* `sdk/`: TypeScript SDK to interact with context models
* `scripts/`: Deployment and utility scripts
* `examples/`: Sample code for integration
* `test/`: Unit tests using Hardhat
* `docs/`: Developer documentation and walkthroughs

***

### Prerequisites

* Node.js ≥ v16
* npm ≥ v8
* Hardhat (for testing/deployment)
* Metamask-compatible wallet
* Infura or Alchemy key for Sepolia testnet (or another RPC)

***

### Environment Setup

Create a `.env` file in the root directory with the following:

```env
SEPOLIA_RPC_URL=https://sepolia.infura.io/v3/YOUR_INFURA_KEY
PRIVATE_KEY=your_wallet_private_key_without_0x
ETHERSCAN_API_KEY=your_etherscan_key
```

***

### Contract Compilation

Use Hardhat to compile the contracts:

```bash
npx hardhat compile
```

***

### Deploying to Sepolia

You can deploy the DMCP contracts to Sepolia using the included script:

```bash
npx hardhat run scripts/deploy.cjs --network sepolia
```

This will deploy the protocol contracts and output the deployed addresses.

***

### Running Tests

Ensure the protocol behaves correctly using the built-in tests:

```bash
npx hardhat test
```

***

### Using the SDK

You can interact with the protocol using the provided TypeScript SDK in `sdk/`. Example:

```ts
tsCopyEditimport { ContextClient } from "decontext-protocol";

const client = new ContextClient({
  rpcUrl: process.env.SEPOLIA_RPC_URL,
  privateKey: process.env.PRIVATE_KEY,
});

// Fetch context
const userContext = await client.getContext("user.profile", "0xABC...");

// Set new context
await client.setContext("user.reputation", { score: 85 });
```

The SDK abstracts interaction with DMCP contracts and schema logic, making it easy to build context-aware agents and dApps.

***

### Example Use Case

In the `examples/` folder, you'll find templates for:

* Registering a context schema
* Updating a user's context
* Querying an entity's behavior context
* Integrating with smart contracts or AI agents

***

### Additional Resources

* **Docs:** Inside the `/docs` folder or GitHub wiki
* **Live Package:** [npmjs.com/package/decontext-protocol](https://www.npmjs.com/package/decontext-protocol)
* **Source Code:** [github.com/decontextai/decontext-protocol](https://github.com/decontextai/decontext-protocol)

***

### Next Steps

1. Register a new context schema
2. Deploy your own context-aware dApp or AI agent
3. Integrate with other Decontext-compatible modules

> Need help? Join the Decontext developer community (Discord/Forum coming soon).


---

# Agent Instructions: 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:

```
GET https://docs.dctx.ai/guide/developer-guid.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
