Create a Token
The PumpFunAPI class provides createTokenAndBuy function to create a token on pump.fun instantly without any timeouts.
You can create a token and initiate a dev buy also using this function.
createTokenAndBuy(creator, buyAmount, tokenKeyPair, tokenName, tokenSymbol, tokenImageUrl, description, twitterUrl, telegramUrl, websiteUrl)
TokenKeyPair
Token key pair are regular wallet keypairs that can be generated using solana/web3js packages, initiate a Keypair instance and send to the client you can generate a custom wallet / token address using solana cli
Parameters
creator (string): Creator's private key.
buyAmount (number): Amount to buy.
tokenKeyPair (Object): Token key pair.
tokenName (string): Token name.
tokenSymbol (string): Token symbol.
tokenImageUrl (string): Token image URL.
description (string): Token description.
twitterUrl (string): Twitter URL.
telegramUrl (string): Telegram URL.
websiteUrl (string): Website URL.
How to create a token on pump.fun using api?
the below example will show how to create a token using pumpfunapi.xyz package
const PumpFunAPI = require('pumpfunapi.xyz');
const client = new PumpFunAPI('https://api.mainnet-beta.solana.com', 'your-private-key');
//private key mentioned in client is only used to pay fees of the api
//keep this wallet loaded with sol. fee of 0.002 SOL will be deducted after successfull execution
client.createTokenAndBuy(
'creator-private-key', // this will be used as the dev wallet on pumpfun
`0.01`, // this is the buy amount in sol
{ publicKey: 'token-public-key', secretKey: 'token-secret-key' }, //tokenKeypair
'TokenName',//tokenName
'TKN',//tokenSymbol
'https://example.com/token.png',//token image as url. this must be a active HTTPS url
'Token description',// required, token description
'https://twitter.com/token', //optional
'https://t.me/token',//optional
'https://token.com'//optional
);