mertimus / nft-sales-bot

A short sales bot/script for tracking NFT sales on Solana
69 stars 42 forks source link

TypeError: Cannot read properties of undefined (reading 'length') #6

Open asdasdasdasdasdasdasdad opened 2 years ago

asdasdasdasdasdasdasdad commented 2 years ago

Hi. I need to trigger the bot for NEW sales. I modified code:

const runSalesBot = async () => {
    console.log("starting sales bot...");
    const mostRecentSignature = await solanaConnection.getSignaturesForAddress(projectPubKey, { limit: 1 });
    const options = { until: mostRecentSignature[0].signature }

    let signatures;
    let lastKnownSignature;
    //const options = {};
    while (true) {
        try {
            const signatures = await solanaConnection.getSignaturesForAddress(projectPubKey, options);
            if (!signatures.length) {
                console.log("polling...")
                await timer(pollingInterval);
                continue;
            }
        } catch (err) {
            console.log("error fetching signatures: ", err);
            continue;
        }

Output:

starting sales bot...
polling...
polling...
polling...
polling...
polling...
polling...
polling...
polling...
polling...
polling...
polling...
/home/opc/nft-sales-bot/sales_bot.js:46
        for (let i = signatures.length - 1; i >= 0; i--) {
                                ^

TypeError: Cannot read properties of undefined (reading 'length')
    at runSalesBot (/home/opc/nft-sales-bot/sales_bot.js:46:33)

What i need to do? Thanks in advance

Brandon1419 commented 2 years ago

Same issue

AndreaZero commented 11 months ago

same.. any news?