
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
@chaingpt/nft
Advanced tools
This library provides convenient access to the ChainGPT AI NFT REST API from TypeScript or JavaScript.
npm install --save @chaingpt/nft
# or
yarn add @chaingpt/nft
Generate a text to image using Velogen
const { Nft } = require('@chaingpt/nft');
const fs = require('fs');
const nftInstance = new Nft({
apiKey: 'Your ChainGPT API Key',
});
async function main() {
const generatedImage = await nftInstance.generateImage({
prompt: 'cars racing to the finish', // Prompt to be used to generate the NFT art
model: 'velogen', // Model to be used to generate the NFT art
enhance: 'original', // enhance image once pass '1x' or twice pass '2x'
steps: 2, // steps parameter passed while image generation
height: 512, //height of the resulting image
width: 512, // width of the resulting image
style: 'cinematic', //sample value for style
});
// Save the buffer directly to a file
fs.writeFileSync('generated-image.jpg', Buffer.from(generatedImage.data.data));
}
main();
Generate an image to image using Velogen
const { Nft } = require('@chaingpt/nft');
const fs = require('fs');
const nftInstance = new Nft({
apiKey: 'Your ChainGPT API Key',
});
async function main() {
const generatedImage = await nftInstance.generateImage({
prompt: "medieval fantasy knight, wearing armor", // Prompt to be used to generate the NFT art
image: "https://chaingpt.s3.dualstack.us-east-2.amazonaws.com/sdk/cgpt-bot.jpg",
model: 'velogen', // Model to be used to generate the NFT art
enhance: 'original', // enhance image once pass '1x' or twice pass '2x'
steps: 3,
height: 1024, //height of the resulting image
width: 1024, // width of the resulting image
});
// Save the buffer directly to a file
fs.writeFileSync('generated-image.jpg', Buffer.from(generatedImage.data.data));
}
main();
Generate a text to image using nebula forge
const { Nft } = require('@chaingpt/nft');
const fs = require('fs');
const nftInstance = new Nft({
apiKey: 'Your ChainGPT API Key',
});
async function main() {
const generatedImage = await nftInstance.generateImage({
prompt: 'cars racing to the finish', // Prompt to be used to generate the NFT art
model: 'nebula_forge_xl', // Model to be used to generate the NFT art
enhance: 'original', // enhance image once pass '1x' or twice pass '2x'
steps: 25, // steps parameter passed while image generation
height: 1024, //height of the resulting image
width: 1024, // width of the resulting image
});
// Save the buffer directly to a file
fs.writeFileSync('generated-image.jpg', Buffer.from(generatedImage.data.data));
}
main();
Generate an image to image using nebula forge
const { Nft } = require('@chaingpt/nft');
const fs = require('fs');
const nftInstance = new Nft({
apiKey: 'Your ChainGPT API Key',
});
async function main() {
const generatedImage = await nftInstance.generateImage({
prompt: "medieval fantasy knight, wearing armor", // Prompt to be used to generate the NFT art
image: "https://chaingpt.s3.dualstack.us-east-2.amazonaws.com/sdk/cgpt-bot.jpg",
model: 'nebula_forge_xl', // Model to be used to generate the NFT art
enhance: 'original', // enhance image once pass '1x' or twice pass '2x'
steps: 20,
height: 1024, //height of the resulting image
width: 1024, // width of the resulting image,
});
// Save the buffer directly to a file
fs.writeFileSync('generated-image.jpg', Buffer.from(generatedImage.data.data));
}
main();
Generate a text to image using visionary forge
const { Nft } = require('@chaingpt/nft');
const fs = require('fs');
const nftInstance = new Nft({
apiKey: 'Your ChainGPT API Key',
});
async function main() {
const generatedImage = await nftInstance.generateImage({
prompt: 'cars racing to the finish, realistic and higly detailed image', // Prompt to be used to generate the NFT art
model: 'VisionaryForge', // Model to be used to generate the NFT art
enhance: 'original', // enhance image once pass '1x' or twice pass '2x'
height: 1024, //height of the resulting image
width: 1024, // width of the resulting image
});
// Save the buffer directly to a file
fs.writeFileSync('generated-image.jpg', Buffer.from(generatedImage.data.data));
}
main();
Generate an image to image using visionary forge
const { Nft } = require('@chaingpt/nft');
const fs = require('fs');
const nftInstance = new Nft({
apiKey: 'Your ChainGPT API Key',
});
async function main() {
const generatedImage = await nftInstance.generateImage({
prompt: "medieval fantasy knight, wearing armor", // Prompt to be used to generate the NFT art
image: "https://chaingpt.s3.dualstack.us-east-2.amazonaws.com/sdk/cgpt-bot.jpg",
model: 'VisionaryForge', // Model to be used to generate the NFT art
enhance: 'original', // enhance image once pass '1x' or twice pass '2x'
height: 1024, //height of the resulting image
width: 1024, // width of the resulting image
});
// Save the buffer directly to a file
fs.writeFileSync('generated-image.jpg', Buffer.from(generatedImage.data.data));
}
main();
Character Reference NFT Image Generation
const { Nft } = require('@chaingpt/nft');
const fs = require('fs');
const nftInstance = new Nft({
apiKey: 'Your ChainGPT API Key',
});
async function main() {
const generatedImage = await nftInstance.generateImage({
prompt: "musician playing guitar under stage lights", // Prompt to be used to generate the NFT art
image: "https://chaingpt.s3.dualstack.us-east-2.amazonaws.com/sdk/cgpt-bot.jpg",
model: 'velogen', // Allowed models velogen, VisionaryForge, nebula_forge_xl
enhance: 'original', // enhance image once pass '1x' or twice pass '2x'
steps: 3,
height: 1024, //height of the resulting image
width: 1024, // width of the resulting image
isCharacterPreserve: true // to preserve the character
});
// Save the buffer directly to a file
fs.writeFileSync('generated-image.jpg', Buffer.from(generatedImage.data.data));
}
main();
Note: If
isCharacterPreserve
is set totrue
, you must also provide a validimage
URL.
Generate an image using Dale3
const { Nft } = require('@chaingpt/nft');
const fs = require('fs');
const nftInstance = new Nft({
apiKey: 'Your ChainGPT API Key',
});
async function main() {
const generatedImage = await nftInstance.generateImage({
prompt: 'cars racing to the finish', // Prompt to be used to generate the NFT art
model: 'Dale3', // Model to be used to generate the NFT art
upscale: true, // enhance image once pass '1x' or twice pass '2x'
height: 1024, //height of the resulting image
width: 1024, // width of the resulting image
style: 'cinematic', //sample value for style
traits: [
//optional traits
{
trait_type: 'Background',
value: [
{ value: 'Heaven', ratio: 20 },
{ value: 'Hell', ratio: 60 },
{ value: 'Pakistan', ratio: 20 },
],
},
{
trait_type: 'contrast',
value: [
{ value: 'dark', ratio: 20 },
{ value: 'light', ratio: 80 },
],
},
],
});
// Save the buffer directly to a file
fs.writeFileSync('generated-image.jpg', Buffer.from(generatedImage.data.data));
}
main();
get chains to generate NFT on a chain, to get testNet chains aswell pass true as parameter
const { Nft } = require('@chaingpt/nft');
const nftInstance = new Nft({
apiKey: 'Your ChainGPT API Key',
});
async function main() {
const chains = await nftInstance.getChains(false); // true for testnet
console.log(chains);
}
main();
Generate an NFT
const { Nft } = require('@chaingpt/nft');
const nftInstance = new Nft({
apiKey: 'Your ChainGPT API Key',
});
async function main() {
const generatedNFT = await nftInstance.generateNft({
walletAddress: '<your wallet address>', // Public Key of the wallet that will mint NFT
prompt: 'a car being modified', // Prompt to be used to generate the NFT art
model: 'velogen', // Model to be used to generate the NFT art
enhance: 'original', // enhance image once pass '1x' or twice pass '2x'
steps: 3, // steps parameter passed while image generation
height: 1024, //height of the resulting image
width: 1024, // width of the resulting image
chainId: 97, //chain id
amount: 1, // no of images to generate
style: 'cinematic', //sample value for style
traits: [
{
trait_type: 'contrast', // set trait name
value: [
// set ratio for values
{ value: 'dark', ratio: 20 },
{ value: 'light', ratio: 80 },
],
},
],
});
console.log(generatedNFT);
}
main();
Generate an NFT from image
const { Nft } = require('@chaingpt/nft');
const fs = require('fs');
const nftInstance = new Nft({
apiKey: 'Your ChainGPT API Key',
});
async function main() {
const generatedImage = await nftInstance.generateNft({
prompt: 'cars racing to the finish', // Prompt to be used to generate the NFT art
model: 'velogen', // Model to be used to generate the NFT art
enhance: 'original', // enhance image once pass '1x' or twice pass '2x'
steps: 2, // steps parameter passed while image generation
height: 512, //height of the resulting image
width: 512, // width of the resulting image
image: 'https://dywmmvb02wrr8.cloudfront.net/document/532d6f9608fa33feeb3455a6ba788483.jpg-1726748667979.jpeg', // URL of image Only JPEG/JPG Format Supported.
});
}
main();
Generate an NFT and queue the generation instead of waiting for it to complete
const { Nft } = require('@chaingpt/nft');
const nftInstance = new Nft({
apiKey: 'Your ChainGPT API Key',
});
async function main() {
const generatedNFTQueue = await nftInstance.generateNftWithQueue({
walletAddress: '<your wallet address>', // Public Key of the wallet that will mint NFT
prompt: 'dragon', // Prompt to be used to generate the NFT art
model: 'Dale3', // Model to be used to generate the NFT art
upscale: true, // upscale image
height: 1024, //height of the resulting image
width: 1024, // width of the resulting image
chainId: 56, //chain id
amount: 2, //no of images to generate
style: 'cinematic', //sample value for style
traits: [
{
trait_type: 'contrast', // set trait name
value: [
// set ratio for values
{ value: 'dark', ratio: 20 },
{ value: 'light', ratio: 80 },
],
},
],
});
console.log(generatedNFTQueue);
}
main();
Check the creation progress of your NFT Generation (useful with generateNftWithQueue()
)
const { Nft } = require('@chaingpt/nft');
const nftInstance = new Nft({
apiKey: 'Your ChainGPT API Key',
});
async function main() {
const getProgress = await nftInstance.getNftProgress({
collectionId: '<collection id>', // your NFT generation collection ID
});
console.log(getProgress);
}
main();
Enhances your prompt by adding more details and context to improve image generation quality.
const { Nft } = require('@chaingpt/nft');
const nftInstance = new Nft({
apiKey: 'Your ChainGPT API Key',
});
async function main() {
const enhancedPrompt = await nftInstance.enhancePrompt({
prompt: 'lion in jungle',
});
console.log(enhancedPrompt);
}
main();
Generate a random prompt for NFT creation
const { Nft } = require('@chaingpt/nft');
const nftInstance = new Nft({
apiKey: 'Your ChainGPT API Key',
});
async function main() {
const randomPrompt = await nftInstance.surpriseMe();
// Returns a randomly generated prompt that can be used for NFT creation
console.log(randomPrompt);
}
main();
Get collections generated by your api key with optional filters
const { Nft } = require('@chaingpt/nft');
const nftInstance = new Nft({
apiKey: 'Your ChainGPT API Key',
});
async function main() {
const collections = await nftInstance.getCollections({
walletAddress: '<wallet address>', // Wallet address to filter collections
isPublic: true, // Filter by public status
// isDraft: false, // Filter by draft status (addtional filter)
// isMinted: false, // Filter by minted status (addtional filter)
// name: "<name>", // Filter by collection name (addtional filter)
// symbol: "<symbol>", // Filter by collection symbol (addtional filter)
page: 1, // Page number for pagination
limit: 10, // Number of items per page
});
}
main();
Toggle NFT visibility (make public/private)
const { Nft } = require('@chaingpt/nft');
const nftInstance = new Nft({
apiKey: 'Your ChainGPT API Key',
});
async function main() {
const response = await nftInstance.toggleNftVisibility({
collectionId: '<collection id>', // ID of the collection to toggle visibility
});
console.log(response);
}
main();
Retrieving required data to mint the generated NFT
const { Nft } = require('@chaingpt/nft');
const nftInstance = new Nft({
apiKey: 'Your ChainGPT API Key',
});
async function main() {
const mint = await nftInstance.mintNft({
collectionId: '<collection Id>', // Your NFT generation Collection ID
ids: [1], // collection to mint from generated images starting from 1
name: '<name>', // A name for your NFT
description: '<description>', // A description for your NFT
symbol: '<symbol>', // symbol
});
console.log(mint);
}
main();
Retrieving the NFT Mint Factory Contract ABI to call the Mint function
const { Nft } = require('@chaingpt/nft');
const nftInstance = new Nft({
apiKey: 'Your ChainGPT API Key',
});
async function main() {
const abi = await nftInstance.abi();
console.log(abi);
}
main();
Here is a list of supported models:
You can enhance your image once or twice by using enhance property
Models that support enhancement:
Steps property can be used to refine image verious times.
Each model supports specific resolutions for optimal results.
Here is a list of supported models:
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),
an error of the class NftError
will be thrown:
import { Errors } from '@chaingpt/nft';
async function main() {
try {
const response = await nftInstance.abi();
console.log(response.data);
} catch (error) {
if (error instanceof Errors.NftError) {
console.log(error.message);
}
}
}
main();
FAQs
SDK for Nft
We found that @chaingpt/nft demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 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
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
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.