GithubHelp home page GithubHelp logo

plsummers / nft-sales-bot Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mertimus/nft-sales-bot

0.0 0.0 0.0 48 KB

A short sales bot/script for tracking NFT sales on Solana

JavaScript 100.00%

nft-sales-bot's Introduction

Solana NFT Sales Bot

A short sales bot/script for tracking NFT sales on Solana for a given collection and posting the sale details to Discord.

The code here isn't great and is primarily meant for illustrating concepts. Please see this accompanying post which explains all parts of the bot.

Usage

Once you've got a project address and a Discord webhook URL, simply run:

PROJECT_ADDRESS=insert-address DISCORD_URL=insert-webhook node sales_bot.js

Caveats

The way the bot is currently set up, it fetches the last 1000 signatures by default. This is on purpose - as I like backfilling historic sales when I add a bot to Discord.

If you do NOT want to do this, i.e., if you want to ONLY trigger the bot for NEW sales, you will need to modify the code.

There are a few ways to do this.

You can simply call getSignaturesForAddress before booting up the bot to get the most recent transaction and then pass this signature to the getSignaturesForAddress in the until option.

For example:

  const runSalesBot = async () => {
    const mostRecentSignature = await solanaConnection.getSignaturesForAddress(projectPubKey, { limit: 1 });
    const options = { until: mostRecentSignature[0].signature }
 
    // ... more stuff
    
    while(true) {
      let signatures = await solanaConnection.getSignaturesForAddress(projectPubKey, options);
      // ... rest of the code
    }

Alternatively, you can set a new Date during bootup and make sure that new sales occured after this date.

Issues

Sometimes there are problems with the Metaplex API, if this happens, please use the Magic Eden API for getting the metadata (I go over this in the Medium post), i.e., https://api-mainnet.magiceden.io/rpc/getNFTByMintAddress/{paste-mint-address-here

nft-sales-bot's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.