Smart Contract Auditor

Smart Contract Auditor

AI-powered vulnerability detection for Solidity smart contracts. Submit contract source code and receive a scored audit report identifying security issues, gas optimizations, and best-practice violations.

Key Facts

Endpoint

POST /chat/stream

Model

smart_contract_auditor

Cost

1 credit per request (2 with chat history enabled)

SDK

@chaingpt/smartcontractauditor

Output

Scored audit report with categorized findings

Parameters

Parameter
Type
Required
Description

model

string

Yes

Must be "smart_contract_auditor"

question

string

Yes

The Solidity source code to audit, or a follow-up question about a previous audit

chatHistory

string

No

"on" or "off" (string, not boolean). Enables follow-up questions about findings. Doubles cost to 2 credits. Default: "off"

sdkUniqueId

string

No

Unique session identifier for maintaining audit conversation context

Quick Start -- JavaScript

npm install @chaingpt/smartcontractauditor
import { SmartContractAuditor } from "@chaingpt/smartcontractauditor";

const client = new SmartContractAuditor({
  apiKey: process.env.CHAINGPT_API_KEY,
});

const solidityCode = `
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

contract SimpleVault {
    mapping(address => uint256) public balances;

    function deposit() external payable {
        balances[msg.sender] += msg.value;
    }

    function withdraw(uint256 amount) external {
        require(balances[msg.sender] >= amount, "Insufficient balance");
        (bool success, ) = msg.sender.call{value: amount}("");
        require(success, "Transfer failed");
        balances[msg.sender] -= amount;
    }
}
`;

const audit = await client.createChatMessage({
  model: "smart_contract_auditor",
  question: solidityCode,
  chatHistory: "off",
});

console.log(audit.data.bot);

Follow-Up on Findings

Tips

  • The Auditor detects common vulnerabilities including reentrancy, integer overflow, access control issues, and gas inefficiencies.

  • Pair with the Smart Contract Generator for a generate-then-audit pipeline.

  • Use chat history to drill into specific findings and request corrected code, but note the doubled credit cost.

  • For the example above, the Auditor will flag the classic reentrancy vulnerability in the withdraw function (state update after external call).

Last updated

Was this helpful?