Create a Token
The PumpFun API has a variety of ways of creating a token.
In this example, you will setup a developer wallet with enough SOL to pay for launch fees on pump.fun, buy the token, and pay for network fees. This wallet will be used to launch the token.
The PumpFun API will automatically generate a contract address for this token, but you can chose to pass a private key for the account used for the token contract address as well.
Create your first token
// Testing the PumpFun API
const axios = require('axios');
async function createToken() {
try {
const pumpfunApi = axios.create({
baseURL: 'https://pumpfun.landerlabs.xyz',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
});
const response = await pumpfunApi.post('/api/v1/token/create', {
// sample request body
walletPrivateKey: "<wallet private key base58 encoded>",
name: "Forged Common",
symbol: "FORGE",
description: "An attempt at forging by the legendary blacksmith.",
devBuyAmountSol: 0.1,
// an image url could be provided instead of the base64 encoded image bytes
// imageUrl: "https://example.com/image.png",
imageFileBase64: "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=",
imageFilename: "image.png",
// the devnet flag is optional, it will default to false if not provided
devNet: true
});
console.log('Response:', response.data);
} catch (error) {
console.error('Error making request:', error.response.data);
}
}
createToken();
The API will respond with an output in the following format:
{
"status": "success",
"message": "Token created successfully",
"mintPublicKey": "4AXfwLFZZmxA6Vsch3DAeFhrPB6q7HDL9SyWg3maFnwA",
"mintPrivateKey": "<base58 encoded private key of the token account>",
"devPublicKey": "2cJksRdG5hgzQGAYd36SiDf6kYvymGePS443rQ6fSpC5",
"devPrivateKey": "<base58 encoded private key of the dev account>",
"pumpUrl": "https://pump.fun/coin/4AXfwLFZZmxA6Vsch3DAeFhrPB6q7HDL9SyWg3maFnwA"
}
You can use the pump.fun url returned to check your newly created coin.
You can also use the returned mint private and public keys to perform any other actions you want with your token, such as selling.