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
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/smartcontractgeneratorimport { 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
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.
Last updated
Was this helpful?