Skip to main content

Tutorial Intro

Let's discover PumpTrader.fun in less than 2 minutes!.

Step 1: Generate a new wallet

First, let's generate a new disposable wallet. We can use a wallet extension like Phantom to generate a new wallet, or we can use the api to generate a new wallet for us.

The api is secure as it does not store any data. The wallets are generated on the fly and the transactions and requests are not saved anywhere. But it is still recommended to dispose of the wallet after we are done trading.

const fetch = require('node-fetch');

const response = await fetch("https://pumptrader.fun/wallets", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({number: 1}) // You can generate up to 40 wallets at once
})

const data = await response.json();
const wallet = data.wallets[0];

Response structure:

{
"status": 200,
"wallets": [
{
"publicKey": "ABCDEFG1234567890HIJKLMNOPQRSTUV",
"privateKey": "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ"
}
]
}

Step 2: Transfer funds to the new wallet

Now that we have a wallet, we can transfer funds to it to start trading. We can use Phantom wallet extension to transfer funds to our new disposable wallet.

phantom transfer

Or we can programatically transfer funds using a solana api. Let's say we have transferred around 0.3 SOL to our disposable wallet for this example.

Step 3: Buy a token

There's multiple ways to buy a token. In this example we just want to spend 50% of our wallet solana balance on that token. It's pretty simple to do that using the trade endpoint:

const fetch = require('node-fetch');

const payload = {
tradeType: "buy",
mint: "BiVrV4ziFCtaTYP6RgYwypxzKYjm2nbePu1pZZ3vpump", // The token mint address
solsPercentage: 50, // around 0.15 sols
slippage: 5,
fee: 0.003,
privateKey: "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ" // Our newly generated private key
};

const response = await fetch("https://pumptrader.fun/trade", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(payload)
})

const data = await response.json();

Example response structure:

{
"status": 200,
"signature": "A13k5iYpLrgUgRhevscyudq5sbTXNZhEtZjhH4YNmt9u"
}

we can then check the transaction on solscan by visiting the following url:

https://solscan.io/tx/A13k5iYpLrgUgRhevscyudq5sbTXNZhEtZjhH4YNmt9u

we traded with solsPercentage to spend half of our wallet on tokens, but we could instead have traded a specific amount of sols or bought a specific amount of tokens. On sale trades we can also specify the tokensPercentage to sell a specific percentage of our tokens. Check the trade documentation for more information about the payload options.

Step 4: Check the tokens value in sols

This amazing feature allows us to check the value of our tokens (in sols) in real time. Allowing us to make better decisions when trading. So on the previous request we spent 50% of our wallet on tokens, let's check how much those tokens are worth now.

const fetch = require('node-fetch');

const url = "https://pumptrader.fun/estimate-tokens-in-wallet/BiVrV4ziFCtaTYP6RgYwypxzKYjm2nbePu1pZZ3vpump";
const payload = {
privateKey: "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ"
};

fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(payload)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => handleError(error));

This returns

{
"status": 200,
"wallet": {
"tokensInWallet": 23644775.161841,
"estimatedSolsValue": 0.194123107
},
"token": {
... // token information, see the documentation for more information
}
}

The response status indicates that the request was successful, and the wallet object contains around 23.6 million tokens, which are worth around 0.194 sols. so we made a marginal profit of around 0.044 sols (ignoring slippage and fees). This is an indication that the token price has increased since we bought it.

We can now sell the tokens to make a profit.

Step 5: Sell the tokens

So we know the value of our tokens is around 0.194 sols, and we want to sell 0.1 sols of the current value. The api will automatically calculate the amount of tokens to sell based on the current token price.

const fetch = require('node-fetch');

const payload = {
tradeType: "sell",
mint: "BiVrV4ziFCtaTYP6RgYwypxzKYjm2nbePu1pZZ3vpump", // The token mint address
sols: 0.1,
slippage: 5,
fee: 0.003,
privateKey: "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ" // Our newly generated private key
};

const response = await fetch("https://pumptrader.fun/trade", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(payload)
})

const data = await response.json();

Or if we wanted to sell 75% of our tokens:

const payload = {
tokensPercentage: 75,
....
};

Or exactly 15 million tokens:

const payload = {
tokens: 15000000,
....
};

We have multiple options to specify the amount of tokens to buy or sell. Check the trade endpoint documentation for more information!

Congrats you have successfully traded on the Solana blockchain using PumpTrader.fun!.

Take a look at the documentation for more information on the endpoints and how to use them.