Closed tn-darkcode closed 7 months ago
Please refer to the type of config object
type buyConfig = {
RPC_ENDPOINT: string;
WALLET_PRIVATE_KEY: string;
ADDRESS_OF_TOKEN_TO_BUY: string;
AMOUNT_OF_SOLANA_TO_SPEND: number;
SLIPPAGE: number;
}
i did exactly that object type and i was debugging your package and all the args are typed right
const buy_token = (config) => __awaiter(void 0, void 0, void 0, function* () {
const { RPC_ENDPOINT, WALLET_PRIVATE_KEY, ADDRESS_OF_TOKEN_TO_BUY, AMOUNT_OF_SOLANA_TO_SPEND, SLIPPAGE = 1 } = config;
try {
const connection = (0, swapper_helper_1.createConnection)(RPC_ENDPOINT);
console.log("Connection established 🚀");
const wallet = new anchor_1.Wallet(web3_js_1.Keypair.fromSecretKey(bs58_1.default.decode(WALLET_PRIVATE_KEY)));
console.log("Wallet fetched ✅");
console.log(`Trying to buy token using ${AMOUNT_OF_SOLANA_TO_SPEND} SOL...`);
yield (0, buy_helper_1.buyToken)(ADDRESS_OF_TOKEN_TO_BUY, AMOUNT_OF_SOLANA_TO_SPEND, SLIPPAGE, connection, wallet);
}
catch (error) {
throw new Error(error.message);
}
});
this function im takling about
Yeah this is the function I wrote
Can you instead share how you use it? Paste the code in which you create the config object and call this function
Also
The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined
who throws this error ? Which line? Which function?
You should include a bit more context or it becomes hard to help 😁
@tn-darkcode Fixed? Can i close this? :)
i got this error The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined
im passing a config object = { string, string, string, number //0.005, 1 }