-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
45 lines (40 loc) · 1.46 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { RPC_URL, PRIVATE_KEY, PUBLIC_KEY, TOKEN_ADDRESS } from "./consts.js";
import { VersionedTransaction, Connection, Keypair } from "@solana/web3.js";
import bs58 from "bs58";
const connection = new Connection(RPC_URL, "confirmed");
const keypair = Keypair.fromSecretKey(bs58.decode(PRIVATE_KEY));
async function sendPumpTransaction() {
const response = await fetch(`http://api.plankton.cash`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
mint: TOKEN_ADDRESS, // Token address from pump.fun
publicKey: PUBLIC_KEY, // Your wallet public key
amountInSol: 0.01, // Amount of SOL, (0.1 SOL)
slippagePercent: 0.25, // Percent slippage allowed (25%)
priorityFee: 0.00001, // Priority fee (0.00001 SOl) - the lower priority fee, the lower chance to be taken by solana network
}),
});
if (response.status === 200) {
const data = await response.arrayBuffer();
const tx = VersionedTransaction.deserialize(new Uint8Array(data));
tx.sign([keypair]);
const signature = await connection.sendTransaction(tx);
console.log("Transaction: https://solscan.io/tx/" + signature);
} else {
console.log(await response.json());
}
}
async function main() {
while (true) {
try {
await sendPumpTransaction();
} catch (e) {
console.error(`An error occurred: ${e}`);
}
await new Promise((r) => setTimeout(r, 1000)); // sleep for 1 second
}
}
main();