> ## Documentation Index
> Fetch the complete documentation index at: https://docs.blockmsg.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Developer Guide

> Clone, build, and deploy your own blockmsg instance

## Prerequisites

Before you begin, make sure you have:

* **Node.js** v18 or higher
* **Yarn** package manager
* **Git** for cloning the repository

***

## Quick Start

<Steps>
  <Step title="Clone the Repository">
    ```bash theme={null}
    git clone https://github.com/Gutslabs/blockmsg.git
    cd blockmsg
    ```
  </Step>

  <Step title="Install Dependencies">
    ```bash theme={null}
    yarn install
    ```
  </Step>

  <Step title="Set Environment Variables">
    ```bash theme={null}
    cp packages/nextjs/.env.example packages/nextjs/.env.local
    ```

    Edit `.env.local` with your configuration
  </Step>

  <Step title="Start Development Server">
    ```bash theme={null}
    yarn start
    ```

    App runs at `http://localhost:3000`
  </Step>
</Steps>

***

## Project Structure

```
blockmsg/
├── packages/
│   ├── hardhat/           # Smart contracts
│   │   ├── contracts/     # Solidity contracts
│   │   ├── deploy/        # Deployment scripts
│   │   └── test/          # Contract tests
│   └── nextjs/            # Frontend application
│       ├── app/           # Next.js pages
│       ├── components/    # React components
│       └── hooks/         # Custom hooks
└── docs/                  # This documentation
```

***

## Smart Contracts

### SecretCircles.sol

The main contract handling encrypted messaging:

```solidity theme={null}
// Key functions
function sendDM(
    address _to,
    externalEuint32[] calldata _encryptedContent,
    bytes[] calldata _proofs,
    uint256 _expiresInSeconds
) external;

function dmMessages(
    address _user1,
    address _user2,
    uint256 _index
) external view returns (DirectMessage memory);
```

### Deploying Contracts

```bash theme={null}
# Deploy to Ethereum Sepolia testnet
cd packages/hardhat
yarn deploy --network sepolia

# Verify contract
yarn verify --network sepolia
```

***

## Environment Variables

| Variable                       | Description                         |
| ------------------------------ | ----------------------------------- |
| `NEXT_PUBLIC_CHAIN_ID`         | Target chain ID (Sepolia: 11155111) |
| `NEXT_PUBLIC_CONTRACT_ADDRESS` | Deployed SecretCircles contract     |
| `DEPLOYER_PRIVATE_KEY`         | Private key for contract deployment |

***

## Testing

### Contract Tests

```bash theme={null}
cd packages/hardhat
yarn test
```

### Frontend Development

```bash theme={null}
cd packages/nextjs
yarn dev
```

***

## Deployment

### Frontend (Vercel)

1. Push to GitHub
2. Connect repo to Vercel
3. Set environment variables
4. Deploy

### Contracts (Zama fhEVM)

```bash theme={null}
yarn deploy --network zama
```

***

## Contributing

<CardGroup cols={2}>
  <Card title="Fork & Clone" icon="code-fork">
    Fork the repo, make changes, submit a PR
  </Card>

  <Card title="Issues" icon="bug">
    Report bugs or request features on GitHub
  </Card>
</CardGroup>

<Tip>
  All contributions are welcome! Check the GitHub issues for good first issues.
</Tip>
