
Security News
Risky Biz Podcast: Making Reachability Analysis Work in Real-World Codebases
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
@chaingpt/smartcontractgenerator
Advanced tools
This library provides convenient access to the ChainGPT Smart Contract Generator REST API from TypeScript or JavaScript.
npm install --save @chaingpt/smartcontractgenerator
# or
yarn add smartcontractgenerator
Generate a smart contract as a stream:
import { SmartContractGenerator } from "@chaingpt/smartcontractgenerator";
const smartcontractgenerator = new SmartContractGenerator({
apiKey: 'Your ChainGPT API Key',
});
async function main() {
const stream = await smartcontractgenerator.createSmartContractStream({
question: 'Write a smart contract that counts. It will have two functions. One for incrementing. Other for decrementing.',
chatHistory: "off"
});
stream.on('data', (chunk: any) => console.log(chunk.toString()));
stream.on('end', () => console.log("Stream ended"));
}
main();
Generate a smart contract as a blob:
import { SmartContractGenerator } from "@chaingpt/smartcontractgenerator";
const smartcontractgenerator = new SmartContractGenerator({
apiKey: 'Your ChainGPT API Key',
});
async function main() {
const response = await smartcontractgenerator.createSmartContractBlob({
question: 'Write a smart contract that counts. It will have two functions. One for incrementing. Other for decrementing.',
chatHistory: "off"
})
console.log(response.data.bot);
}
main();
Retrieve smart contract generation history:
import { SmartContractGenerator } from "@chaingpt/smartcontractgenerator";
const smartcontractgenerator = new SmartContractGenerator({
apiKey: 'Your ChainGPT API Key',
});
async function main() {
const response = await smartcontractgenerator.getChatHistory({
limit: 10,
offset: 0,
sortBy: "createdAt",
sortOrder: "DESC"
})
console.log(response.data.rows);
}
main();
When the library is unable to connect to the API,
or if the API returns a non-success status code (i.e., 4xx or 5xx response),
and error of the class SmartContractGeneratorError
will be thrown:
import { Errors } from '@chaingpt/smartcontractgenerator';
async function main() {
try {
const stream = await smartcontractgenerator.createSmartContractStream({
question: 'Write a smart contract that counts. It will have two functions. One for incrementing. Other for decrementing.',
chatHistory: "on"
});
stream.on('data', (chunk: any) => console.log(chunk.toString()));
stream.on('end', () => console.log("Stream ended"));
} catch(error) {
if(error instanceof Errors.SmartContractGeneratorError) {
console.log(error.message)
}
}
}
main();
sdkUniqueId
parameter along with the chat history. This applies to both streaming and blob cases.import { SmartContractGenerator } from "@chaingpt/smartcontractgenerator";
const smartcontractgenerator = new SmartContractGenerator({
apiKey: 'Your ChainGPT API Key',
});
const uniqueUUid="907208eb-0929-42c3-a372-c21934fbf44f" // your unique uuid of your specific user
async function main() {
const response = await smartcontractgenerator.createSmartContractBlob({
question: 'Write a smart contract that counts. It will have two functions. One for incrementing. Other for decrementing.',
chatHistory: "on",
sdkUniqueId:uniqueUUid
})
console.log(response.data.bot);
}
main();
FAQs
SDK for Smart Contract Generator
The npm package @chaingpt/smartcontractgenerator receives a total of 0 weekly downloads. As such, @chaingpt/smartcontractgenerator popularity was classified as not popular.
We found that @chaingpt/smartcontractgenerator demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.