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

# ChainGPT Integration

> ChainGPT integration enables Web3 smart contract generation and auditing inside Scriptonia for Blockchain/DApp projects.

## Overview

ChainGPT is a Web3-focused AI platform used in Scriptonia for:

* Smart contract generation
* Smart contract security auditing

It is triggered automatically when the **Blockchain/DApp** platform is selected.

***

## What ChainGPT is used for

* Generate Solidity smart contracts from natural language
* Perform automated security audits
* Produce audit reports as part of project deliverables

***

## Integration Points

* `lib/chaingpt.ts` — Base API client
* `lib/chaingpt-smart-contract.ts` — Contract generation
* `lib/chaingpt-auditor.ts` — Contract auditing
* `lib/platform-templates.ts` — Triggers generation during execution

***

## Smart Contract Generation

### Purpose

Generate production-ready Solidity contracts from project requirements.

### Supported

* Networks: Ethereum, Polygon, BSC, Solana
* Standards: ERC-20, ERC-721, ERC-1155, custom contracts

### Function

```
generateSmartContract(request)
```

**Input**

* description
* network (optional)
* standards (optional)
* additionalRequirements (optional)

**Output**

* Solidity contract code
* Explanation
* Network and standards used

***

## Smart Contract Auditing

### Purpose

Analyze generated contracts for security and best-practice issues.

### Function

```
auditSmartContract(contractCode, mode)
```

### Modes

* **quick**
  * Critical and high-severity issues
  * Used immediately after generation
* **full**
  * Complete audit report
  * Included in final deliverables

***

## Workflow Integration

1. User selects **Blockchain/DApp** platform
2. Execution starts
3. Backend agent detects `contract.sol`
4. ChainGPT generates the contract
5. Quick audit runs
6. During final execution:
   * Full audit runs
   * `audit.md` is generated

***

## Configuration

### Required environment variables

```
CHAINGPT_API_KEY=
CHAINGPT_BASE_URL=https://api.chaingpt.org
```

***

## Output

Blockchain/DApp projects include:

* `contract.sol` — Generated smart contract
* `audit.md` — Security audit report

***

## Notes

* Scriptonia does **not** deploy or audit live contracts
* Generated contracts must be reviewed before use
* Audits are automated, not a substitute for professional audits

***

## Status

* Integration: Complete
* Used automatically for Blockchain/DApp projects
