Smart Contract Generator
Updated May 29, 2026, 12:30 PM
Smart Contract Generator
Smart Contract Generator
Generate production-ready Solidity smart contracts from natural language descriptions. Powered by the same streaming endpoint as the LLM chatbot, using a specialized model fine-tuned for smart contract generation.
Key Facts
| Endpoint | POST /chat/stream |
| Model | smart_contract_generator |
| Cost | 1 credit per request (2 with chat history enabled) |
| SDK | @chaingpt/smartcontractgenerator |
| Output | Solidity source code |
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Must be "smart_contract_generator" |
question | string | Yes | Natural language description of the contract you want |
chatHistory | string | No | "on" or "off" (string, not boolean). Enables iterative refinement. Doubles cost to 2 credits. Default: "off" |
sdkUniqueId | string | No | Unique session identifier for maintaining conversation context |
Quick Start -- JavaScript
npm install @chaingpt/smartcontractgenerator
import { SmartContractGenerator } from "@chaingpt/smartcontractgenerator";
const client = new SmartContractGenerator({
apiKey: process.env.CHAINGPT_API_KEY,
});
const response = await client.createChatMessage({
model: "smart_contract_generator",
question:
"Create an ERC-721 NFT contract with a max supply of 10,000, " +
"0.05 ETH mint price, and an owner-only withdraw function. " +
"Include a merkle proof whitelist for presale.",
chatHistory: "off",
});
console.log(response.data.bot);
Iterative Refinement with Chat History
// First request: generate the base contract
const base = await client.createChatMessage({
model: "smart_contract_generator",
question: "Create a simple ERC-20 token with 1 billion supply and 2% burn on transfer",
chatHistory: "on",
sdkUniqueId: "session-contract-001",
});
console.log(base.data.bot);
// Follow-up: modify the contract
const revised = await client.createChatMessage({
model: "smart_contract_generator",
question: "Add a 1% reflection mechanism and an anti-whale max transaction limit of 1%",
chatHistory: "on",
sdkUniqueId: "session-contract-001",
});
console.log(revised.data.bot);
Tips
- Be specific in your descriptions -- include token standards (ERC-20, ERC-721, ERC-1155), access control requirements, and any special mechanisms.
- Use chat history for iterative refinement: generate a base contract, then request modifications in follow-up messages.
- Always pipe the generated output into the Smart Contract Auditor before deploying. The Generator + Auditor combo is the most natural pairing in the suite.
- For offline or self-hosted Solidity generation, see the Solidity LLM.